map-stream-2-limited
v0.0.1
Published
Build a limited concurrency through2 stream from an async function
Downloads
4
Maintainers
Readme
map-stream-2-limited
Limited concurrency map-stream
implementation. Inspired by
map-stream-limit
but built on through2
and additionally allows the concurrency to be changed
after instantiation.
Somewhat experimental and likely to be caught out by edge cases...
Install
$ npm install map-stream-2-limited
Usage
var mapLimited = require('map-stream-2-limited')
var transform = mapLimited(function (data, callback) {
callback(null, data)
// or
callback(new Error('something failed'))
}, 10) // initial concurrency limit of 10
someStream
.pipe(transform)
// Modify concurrency limit by supplying a transform function
transform.changeLimit(function (limit) {
return limit + 1 // Will throw if you attempt to change the limit to < 1
})