1.0.0 • Published 8 years ago

swift-transform v1.0.0

Weekly downloads
83
License
MIT
Repository
github
Last release
8 years ago

swift-transform

NPM version Downloads Build Status Coverage Status Dependency status Dev Dependency status

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.