Name: p-gather
Owner: node_modules
Description: Execute Promise in parallel with concurrency support and gather all the results.
Created: 2018-03-27 07:19:38.0
Updated: 2018-03-27 10:21:49.0
Pushed: 2018-03-27 10:21:51.0
Homepage: null
Size: 8
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Execute Promise in parallel with concurrency support and gather all the results.
p-gather
is similar with co-parallel, but p-gather
will gather all the result of these Promise, even those Promise throw error.
m install p-gather
t gather = require('p-gather');
t thread = gather.thread;
tion sleep(n) {
turn new Promise(resolve => {
setTimeout(resolve, n);
;
index = 0;
c function random() {
t i = index++;
ait sleep(Math.random() * 100);
(Math.random() > 0.5) {
throw new Error('error');
turn i;
nc =>{
nst ret = await gather(thread(random, 10));
nsole.log(ret);
;
=>
isError: true, error: [Error: error] },
isError: true, error: [Error: error] },
isError: true, error: [Error: error] },
isError: true, error: [Error: error] },
isError: true, error: [Error: error] },
isError: false, value: 5 },
isError: false, value: 6 },
isError: false, value: 7 },
isError: true, error: [Error: error] },
isError: true, error: [Error: error] }
Execute Promise
array in parallel, with the given concurrency defaulting to 5, and gather the result
Run a function in parallel N times. Function must return a Promise Object.
MIT