@dnlup/cut

1.0.0 • Public • Published

cut

A stream size validator

Installation

$ npm i @dnlup/cut

Usage

const cut = require('@dnlup/cut')
const { pipeline } = require('stream')

const readable = getReadableSomeHow()

pipeline([
  readable,
  cut() // Default max size is 1024 * 1024 bytes
  // ...Other streams in the pipeline here
], error => {
  if (error) {
    if (error.message === 'Maximum size reached') {
      console.error('File exceeded size limit')
    }
  }
})

API

cut([options])

create a new validator

  • options: Object. Configuration options.
    • options.size: Number. The maximum number of bytes that are allowed to flow in the stream.
    • options.*: See stream.Transform options.

Readme

Keywords

Package Sidebar

Install

npm i @dnlup/cut

Weekly Downloads

3

Version

1.0.0

License

ISC

Unpacked Size

4.11 kB

Total Files

5

Last publish

Collaborators

  • dnlup