Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

p-map-series

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

p-map-series - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

index.d.ts

20

index.js
'use strict';
const pReduce = require('p-reduce');
module.exports = (iterable, iterator) => {
const ret = [];
const pMapSeries = async (iterable, mapper) => {
const result = [];
let index = 0;
return pReduce(iterable, (a, b, i) => {
return Promise.resolve(iterator(b, i)).then(val => {
ret.push(val);
});
}).then(() => ret);
for (const value of iterable) {
// eslint-disable-next-line no-await-in-loop
result.push(await mapper(await value, index++));
}
return result;
};
module.exports = pMapSeries;
module.exports.default = pMapSeries;

86

package.json
{
"name": "p-map-series",
"version": "1.0.0",
"description": "Map over promises serially",
"license": "MIT",
"repository": "sindresorhus/p-map-series",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"promise",
"map",
"collection",
"iterable",
"iterator",
"fulfilled",
"serial",
"serially",
"async",
"await",
"promises",
"bluebird"
],
"dependencies": {
"p-reduce": "^1.0.0"
},
"devDependencies": {
"ava": "*",
"delay": "^1.3.1",
"time-span": "^1.0.0",
"xo": "*"
},
"xo": {
"esnext": true
}
"name": "p-map-series",
"version": "2.0.0",
"description": "Map over promises serially",
"license": "MIT",
"repository": "sindresorhus/p-map-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",
"map",
"collection",
"iterable",
"iterator",
"fulfilled",
"serial",
"serially",
"async",
"await",
"promises",
"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-map-series [![Build Status](https://travis-ci.org/sindresorhus/p-map-series.svg?branch=master)](https://travis-ci.org/sindresorhus/p-map-series)

```
$ npm install --save p-map-series
$ npm install p-map-series
```

@@ -29,3 +29,4 @@

const mapper = keyword => fetchScore(keyword).then(score => {
const mapper = async keyword => {
const score = await fetchScore(keyword);
scores.push(score);

@@ -35,17 +36,21 @@ return {keyword, score};

pMapSeries(keywords, mapper).then(result => {
console.log(result);
(async () => {
console.log(await pMapSeries(keywords, mapper));
/*
[{
keyword: 'unicorn',
score: 99
}, {
keyword: 'rainbow',
score: 70
}, {
keyword: 'pony',
score: 79}
[
{
keyword: 'unicorn',
score: 99
},
{
keyword: 'rainbow',
score: 70
},
{
keyword: 'pony',
score: 79
}
]
*/
});
})();
```

@@ -62,3 +67,3 @@

Type: `Iterable<Promise|any>`
Type: `Iterable<Promise | unknown>`

@@ -65,0 +70,0 @@ Mapped over serially in the `mapper` function.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc