node package manager
Easy sharing. Manage teams and permissions with one click. Create a free org »

first-chunk-min-size-stream

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