unstream

buffer, transform, and re-stream

Usage no npm install needed!

<script type="module">
  import unstream from 'https://cdn.skypack.dev/unstream';
</script>

README

unstream

Build Status Coverage Status

Like concat-stream, or bl except it returns a transform stream, allowing you to continue streaming after concat-buffering.

Currently unstream doesn't support object-mode.

unstream(options, transformFn (body, callback(err, data)) { })

var unstream = require('unstream');

fs.createReadStream('file')
  .pipe(unstream({ limit: 1024 }, function (data, callback) {
    callback(null, data.toUpperCase());
  }))
  .pipe(process.stdout);

options

Options object. Same as TransformStream options, plus some extras:

  • limit [Number] - maximum number of bytes to buffer. The default is Infinity. Set this to a hard limit to prevent memory leaks.

transformFn (body, callback) { }

Function that gets called when the buffering is complete.

  • body [Buffer] - fully buffered data from the source stream.
  • callback(err, data) - Call this to continue streaming the data to the destination. This allows you to perform a transform on the fully buffered data, and re-stream it.

License

MIT