first-chunk-min-size-stream

3.0.0 • Public • Published

first-chunk-min-size-stream

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 first-chunk-min-size-stream

Usage

import fs from 'node:fs';
import FirstChunkMinSize from '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

The minimum size of the first chunk.

Dependencies (0)

    Dev Dependencies (3)

    Package Sidebar

    Install

    npm i first-chunk-min-size-stream

    Weekly Downloads

    0

    Version

    3.0.0

    License

    MIT

    Unpacked Size

    3.56 kB

    Total Files

    4

    Last publish

    Collaborators

    • sindresorhus