summaryrefslogtreecommitdiffstats
path: root/node_modules/parallel-transform/README.md
diff options
context:
space:
mode:
authorGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
committerGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
commite06ec920f7a5d784e674c4c4b4e6d1da3dc7391d (patch)
tree55713f725f77b44ebfec86e4eec3ce33e71458ca /node_modules/parallel-transform/README.md
downloadwebsite_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.gz
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.bz2
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.zip
api, login, auth
Diffstat (limited to 'node_modules/parallel-transform/README.md')
-rw-r--r--node_modules/parallel-transform/README.md54
1 files changed, 54 insertions, 0 deletions
diff --git a/node_modules/parallel-transform/README.md b/node_modules/parallel-transform/README.md
new file mode 100644
index 0000000..f53e130
--- /dev/null
+++ b/node_modules/parallel-transform/README.md
@@ -0,0 +1,54 @@
+# parallel-transform
+
+[Transform stream](http://nodejs.org/api/stream.html#stream_class_stream_transform_1) 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
+
+``` js
+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
+
+``` js
+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 \ No newline at end of file