Parallelized transform streams for everyone!
NOTE: Order is not guaranteed!
$ npm install swift-transform
The swift transform stream is a drop-in replacement to nodejs TransformStream
and adds a concurrency
option that allows you to control the number of concurrent transformations.
var SwiftTransformStream = require('swift-transform').Transform;
function MyTransformStream() {
SwiftTransformStream.call(this, { objectMode: true, concurrency: 5 });
}
util.inherits(MyTransformStream, SwiftTransformStream);
// ------------------------------------
MyTransformStream.prototype._transform = function (data, encoding, callback) {
// ..
};
MyTransformStream.prototype._flush = function (callback) {
// ..
};
module.exports = MyTransformStream;
In cases you have a transform stream which you do not own but want to parallelize it:
var swiftTransform = require('swift-transform');
readableStream
.pipe(swiftTransform(transformStream, 10))
.pipe(writableStream);
$ npm test
$ npm test-cov
to get coverage report
Released under the MIT License.