parallel-transform

WebJar for parallel-transform

License

License

MIT
Categories

Categories

ORM Data
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

parallel-transform
Last Version

Last Version

1.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

parallel-transform
WebJar for parallel-transform
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/mafintosh/parallel-transform

Download parallel-transform

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/parallel-transform/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>parallel-transform</artifactId>
    <version>1.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/parallel-transform/
implementation 'org.webjars.npm:parallel-transform:1.2.0'
// https://jarcasting.com/artifacts/org.webjars.npm/parallel-transform/
implementation ("org.webjars.npm:parallel-transform:1.2.0")
'org.webjars.npm:parallel-transform:jar:1.2.0'
<dependency org="org.webjars.npm" name="parallel-transform" rev="1.2.0">
  <artifact name="parallel-transform" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='parallel-transform', version='1.2.0')
)
libraryDependencies += "org.webjars.npm" % "parallel-transform" % "1.2.0"
[org.webjars.npm/parallel-transform "1.2.0"]

Dependencies

compile (3)

Group / Artifact Type Version
org.webjars.npm : cyclist jar [1.0.1,2)
org.webjars.npm : inherits jar [2.0.3,3)
org.webjars.npm : readable-stream jar [2.1.5,3)

Project Modules

There are no modules declared in this project.

parallel-transform

Transform stream for Node.js that allows you to run your transforms in parallel without changing the order of the output.

npm install parallel-transform

It is easy to use

var transform = require('parallel-transform');

var stream = transform(10, function(data, callback) { // 10 is the parallism level
	setTimeout(function() {
		callback(null, data);
	}, Math.random() * 1000);
});

for (var i = 0; i < 10; i++) {
	stream.write(''+i);
}
stream.end();

stream.on('data', function(data) {
	console.log(data); // prints 0,1,2,...
});
stream.on('end', function() {
	console.log('stream has ended');
});

If you run the above example you'll notice that it runs in parallel (does not take ~1 second between each print) and that the order is preserved

Stream options

All transforms are Node 0.10 streams. Per default they are created with the options {objectMode:true}. If you want to use your own stream options pass them as the second parameter

var stream = transform(10, {objectMode:false}, function(data, callback) {
	// data is now a buffer
	callback(null, data);
});

fs.createReadStream('filename').pipe(stream).pipe(process.stdout);

Unordered

Passing the option {ordered:false} will output the data as soon as it's processed by a transform, without waiting to respect the order.

License

MIT

Versions

Version
1.2.0
1.1.0