swift-transform
v1.0.0
Published
Parallelized transform streams for everyone!
Downloads
298
Maintainers
Readme
swift-transform
Parallelized transform streams for everyone!
NOTE: Order is not guaranteed!
Installation
$ npm install swift-transform
Usage
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);
Tests
$ npm test
License
Released under the MIT License.