collect-parallel
Run N things in parallel and collect results
Last updated 12 years ago by raynos .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install collect-parallel 
SYNC missed versions from official npm registry.

collect-parallel

Run N things in parallel and collect results

Example

var collectParallel = require("collect-parallel/array");

collectParallel([
    50,
    100,
    200
], function doTimer(value, i, callback) {
    setTimeout(onTimer, value);

    function onTimer() {
        callback(null, value);
    }
}, function onResults(err, results) {
    // err is always `null`
    // results is an array;
    // it contains `Result()` objects with `err` and `value`
    console.log(results[1].value);
});

Example object

var collectParallelObject = require("collect-parallel/object");

collectParallelObject({
    50: 50,
    100: 100,
    200: 200
}, function doTimer(value, i, callback) {
    setTimeout(onTimer, value);

    function onTimer() {
        callback(null, value);
    }
}, function onResults(err, results) {
    // err is always `null`
    // results is an object;
    // it contains `Result()` objects with `err` and `value`
    console.log(results['100'].value);
});

Installation

npm install collect-parallel

Tests

npm test

Contributors

  • Raynos

MIT Licensed

Current Tags

  • 1.0.1                                ...           latest (12 years ago)

1 Versions

  • 1.0.1                                ...           12 years ago
Maintainers (1)
Downloads
Total 3
Today 0
This Week 0
This Month 3
Last Day 0
Last Week 3
Last Month 0
Dependencies (1)
Dev Dependencies (7)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE