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 2.0.0 to 2.1.0

78

index.d.ts

@@ -1,14 +0,66 @@

/**
Map over promises serially.
declare const pMapSeries: {
/**
Map over promises serially.
@param input - Mapped over serially in the `mapper` function.
@param mapper - Expected to return a value. If it's a `Promise`, it's awaited before continuing with the next iteration.
@returns Fulfills when all promises in `input` and ones returned from `mapper` are fulfilled, or rejects if any of the promises reject.
*/
export default function pMapSeries<ValueType, MappedValueType>(
input: Iterable<PromiseLike<ValueType> | ValueType>,
mapper: (
element: ValueType,
index: number
) => PromiseLike<MappedValueType> | MappedValueType
): Promise<MappedValueType[]>;
@param input - Mapped over serially in the `mapper` function.
@param mapper - Expected to return a value. If it's a `Promise`, it's awaited before continuing with the next iteration.
@returns Fulfills when all promises in `input` and ones returned from `mapper` are fulfilled, or rejects if any of the promises reject.
@example
```
import pMapSeries = require('p-map-series');
const keywords = [
getTopKeyword() //=> Promise
'rainbow',
'pony'
];
let scores = [];
const mapper = async keyword => {
const score = await fetchScore(keyword);
scores.push(score);
return {keyword, score};
});
(async () => {
console.log(await pMapSeries(keywords, mapper));
// [
// {
// keyword: 'unicorn',
// score: 99
// },
// {
// keyword: 'rainbow',
// score: 70
// },
// {
// keyword: 'pony',
// score: 79
// }
// ]
})();
```
*/
<ValueType, MappedValueType>(
input: Iterable<PromiseLike<ValueType> | ValueType>,
mapper: (
element: ValueType,
index: number
) => PromiseLike<MappedValueType> | MappedValueType
): Promise<MappedValueType[]>;
// TODO: Remove this for the next major release, refactor the whole definition to:
// declare function pMapSeries<ValueType, MappedValueType>(
// input: Iterable<PromiseLike<ValueType> | ValueType>,
// mapper: (
// element: ValueType,
// index: number
// ) => PromiseLike<MappedValueType> | MappedValueType
// ): Promise<MappedValueType[]>;
// export = pMapSeries;
default: typeof pMapSeries;
};
export = pMapSeries;

@@ -16,2 +16,3 @@ 'use strict';

module.exports = pMapSeries;
// TODO: Remove this for the next major release
module.exports.default = pMapSeries;

8

package.json
{
"name": "p-map-series",
"version": "2.0.0",
"version": "2.1.0",
"description": "Map over promises serially",

@@ -16,3 +16,3 @@ "license": "MIT",

"scripts": {
"test": "xo && ava && tsd-check"
"test": "xo && ava && tsd"
},

@@ -38,8 +38,8 @@ "files": [

"devDependencies": {
"ava": "^1.3.1",
"ava": "^1.4.1",
"delay": "^4.1.0",
"time-span": "^3.0.0",
"tsd-check": "^0.3.0",
"tsd": "^0.7.2",
"xo": "^0.24.0"
}
}
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