XuelesszzZ 94af2b8e7b 6-30-5 | 1 rok temu | |
---|---|---|
.. | ||
index.js | 1 rok temu | |
license | 1 rok temu | |
package.json | 1 rok temu | |
readme.md | 1 rok temu |
Iterate over promises serially
Useful as a side-effect iterator. Prefer p-map
if you don't need side-effects, as it's concurrent.
$ npm install --save p-each-series
const pEachSeries = require('p-each-series');
const keywords = [
getTopKeyword() //=> Promise
'rainbow',
'pony'
];
const iterator = el => saveToDiskPromise(el); //=> Promise
pEachSeries(keywords, iterator).then(result => {
console.log(result);
//=> ['unicorn', 'rainbow', 'pony']
});
Returns a Promise
that is fulfilled when all promises in input
and ones returned from iterator
are fulfilled, or rejects if any of the promises reject. The fulfillment value is the original input
.
Type: Iterable<Promise|any>
Iterated over serially in the iterator
function.
Type: Function
Return value is ignored unless it's Promise
, then it's awaited before continuing with the next iteration.
MIT © Sindre Sorhus