unstream
v2.0.0
Published
buffer, transform, and re-stream
Downloads
8,899
Readme
unstream
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 isInfinity
. 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 thedata
to the destination. This allows you to perform a transform on the fully buffered data, and re-stream it.
License
MIT