p-gather
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.
Installation
$ npm install p-gather
Example
const gather = ;const thread = gatherthread; { return { ; };} let index = 0; { let i = index++; await ; if Math > 05 throw 'error'; return i;} { const ret = await ; console;};
=>
[
{ 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] }
]
API
gather(Promise, [concurrency])
Execute Promise
array in parallel, with the given concurrency defaulting to 5, and gather the result
gather.thread(Function, [concurrency])
Run a function in parallel N times. Function must return a Promise Object.
License
MIT