1.0.2 • Published 4 years ago

safe-batch-stream v1.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

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);