Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

first-chunk-min-size-stream

2.0.0 • Public • Published

first-chunk-min-size-stream Build Status

Set the minimum size of the first chunk in a stream

Useful if you want to do something to the first chunk and need it to be of a certain size.

Install

$ npm install --save first-chunk-min-size-stream

Usage

const fs = require('fs');
const FirstChunkMinSize = require('first-chunk-min-size-stream');
 
fs.createReadStream('unicorn.txt', {highWaterMark: 1}) // `highWaterMark: 1` means it will only read 1 byte at the time
    .pipe(new FirstChunkMinSize({minSize: 7}))
    .once('data', data => {
        console.log(data.length);
        //=> 7
    });

API

firstChunkMinSize(options)

options

Type: Object

minSize

Required
Type: number

Minimum size of the first chunk.

License

MIT © Sindre Sorhus

install

npm i first-chunk-min-size-stream

Downloadsweekly downloads

6

version

2.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar