p-each-series
Advanced tools
Comparing version 1.0.0 to 2.0.0
15
index.js
'use strict'; | ||
const pReduce = require('p-reduce'); | ||
module.exports = (iterable, iterator) => pReduce(iterable, (a, b, i) => iterator(b, i)).then(() => iterable); | ||
const pEachSeries = async (iterable, iterator) => { | ||
let index = 0; | ||
for (const value of iterable) { | ||
// eslint-disable-next-line no-await-in-loop | ||
await iterator(await value, index++); | ||
} | ||
return iterable; | ||
}; | ||
module.exports = pEachSeries; | ||
module.exports.default = pEachSeries; |
{ | ||
"name": "p-each-series", | ||
"version": "1.0.0", | ||
"description": "Iterate over promises serially", | ||
"license": "MIT", | ||
"repository": "sindresorhus/p-each-series", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"promise", | ||
"foreach", | ||
"for-each", | ||
"for", | ||
"each", | ||
"collection", | ||
"iterable", | ||
"iterator", | ||
"fulfilled", | ||
"async", | ||
"await", | ||
"promises", | ||
"serial", | ||
"serially", | ||
"series", | ||
"bluebird" | ||
], | ||
"dependencies": { | ||
"p-reduce": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"delay": "^1.3.1", | ||
"time-span": "^1.0.0", | ||
"xo": "*" | ||
}, | ||
"xo": { | ||
"esnext": true | ||
} | ||
"name": "p-each-series", | ||
"version": "2.0.0", | ||
"description": "Iterate over promises serially", | ||
"license": "MIT", | ||
"repository": "sindresorhus/p-each-series", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=8" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava && tsd-check" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"index.d.ts" | ||
], | ||
"keywords": [ | ||
"promise", | ||
"foreach", | ||
"for-each", | ||
"for", | ||
"each", | ||
"collection", | ||
"iterable", | ||
"iterator", | ||
"fulfilled", | ||
"async", | ||
"await", | ||
"promises", | ||
"serial", | ||
"serially", | ||
"series", | ||
"bluebird" | ||
], | ||
"devDependencies": { | ||
"ava": "1.3.1", | ||
"delay": "^4.1.0", | ||
"time-span": "^3.0.0", | ||
"tsd-check": "^0.3.0", | ||
"xo": "^0.24.0" | ||
} | ||
} |
@@ -11,3 +11,3 @@ # p-each-series [![Build Status](https://travis-ci.org/sindresorhus/p-each-series.svg?branch=master)](https://travis-ci.org/sindresorhus/p-each-series) | ||
``` | ||
$ npm install --save p-each-series | ||
$ npm install p-each-series | ||
``` | ||
@@ -27,8 +27,8 @@ | ||
const iterator = el => saveToDiskPromise(el); //=> Promise | ||
const iterator = async el => saveToDiskPromise(el); | ||
pEachSeries(keywords, iterator).then(result => { | ||
console.log(result); | ||
(async () => { | ||
console.log(await pEachSeries(keywords, iterator)); | ||
//=> ['unicorn', 'rainbow', 'pony'] | ||
}); | ||
})(); | ||
``` | ||
@@ -45,3 +45,3 @@ | ||
Type: `Iterable<Promise|any>` | ||
Type: `Iterable<Promise | unknown>` | ||
@@ -60,3 +60,5 @@ Iterated over serially in the `iterator` function. | ||
- [p-map-series](https://github.com/sindresorhus/p-map-series) - Map over promises serially | ||
- [p-series](https://github.com/sindresorhus/p-series) - Run promise-returning & async functions in series | ||
- [p-pipe](https://github.com/sindresorhus/p-pipe) - Compose promise-returning & async functions into a reusable pipeline | ||
- [p-waterfall](https://github.com/sindresorhus/p-waterfall) - Run promise-returning & async functions in series, each passing its result to the next | ||
- [p-reduce](https://github.com/sindresorhus/p-reduce) - Reduce a list of values using promises into a promise for a value | ||
@@ -63,0 +65,0 @@ - [p-map](https://github.com/sindresorhus/p-map) - Map over promises concurrently |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
4774
0
5
21
68
0
5
- Removedp-reduce@^1.0.0
- Removedp-reduce@1.0.0(transitive)