Popularity
1.7
Growing
Activity
0.0
Stable
74
5
11

Code Quality Rank: L5
Programming language: JavaScript
License: MIT License
Tags: Streams     Parallel     Transform     Streams2     Concurrency     Through     Through2    

through2-concurrent alternatives and similar modules

Based on the "Streams" category.
Alternatively, view through2-concurrent alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of through2-concurrent or a related project?

Add another 'Streams' Module

README

through2-concurrent

NPM

A simple way to create a Node.JS Transform stream which processes in parallel. You can limit the concurrency (default is 16) and order is not preserved (so chunks/objects can end up in a different order to the order they started in if the transform functions take different amounts of time).

Built using through2 and has the same API with the addition of a maxConcurrency option.

Non-objectMode streams are supported for completeness but I'm not sure they'd be useful for anything.

Written by Thomas Parslow (almostobsolete.net and tomparslow.co.uk) as part of Active Inbox (activeinboxhq.com).

Build Status

Install

npm install --save through2-concurrent

Examples

Process lines from a CSV in parallel. The order the results end up in the all variable is not deterministic.

var through2Concurrent = require('through2-concurrent');

var all = [];

fs.createReadStream('data.csv')
  .pipe(csv2())
  .pipe(through2Concurrent.obj(
    {maxConcurrency: 10},
    function (chunk, enc, callback) {
      var self = this;
      someThingAsync(chunk, function (newChunk) {
        self.push(newChunk);
        callback();
      });
  }))
  .on('data', function (data) {
    all.push(data)
  })
  .on('end', function () {
    doSomethingSpecial(all)
  })

Contributing

Fixed or improved stuff? Great! Send me a pull request through GitHub or get in touch on Twitter @almostobsolete or email at [email protected]