Skip to content

hfsaito/safe-batch-stream

Repository files navigation

safe-batch-stream

Safely creates an array of elements inside a stream. It prevents backpressuring in streams by waiting the drain after reaching a limit of batches built

Example

import { SafeBatchStream } from 'safe-batch-stream';

// Default batch size 1
// Default batch limit 1
const safeBatchStream = new SafeBatchStream();
const writable = new Writable({
  objectMode: true, // required to the next writable after safeBatchStream
  write: (chunk, encoding, callback) => {
    // Do someting
  }
})

sourceStream
  .pipe(safeBatchStream)
  .pipe(writable);

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published