šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

sequential-promise-map

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sequential-promise-map

A simple sequential version of Promise.map

1.0.4
Source
npm
Version published
Weekly downloads
5.5K
5.5%
Maintainers
1
Weekly downloads
Ā 
Created
Source

sequential-promise-map

A simple sequential version of Promise.map, useful to transform an array of values into asynchronous promises, when you need to limit parallel execution of promise generators (eg to prevent hitting external resource thresholds, or to guarantee that things need to happen in a particular sequence).

The function has no dependencies so it will work in Node or browsers, as long as native Promises are supported.

Installation

npm install sequential-promise-map

Usage

sequentialPromiseMap(arrayOfValues, promiseGenerator).then(....) 

The function will resolve will contain an array of Promise results, in the same order as the arguments, or reject with the first rejection.

Example

const sequentialPromiseMap = require('sequential-promise-map');

const fruits = ['apples', 'oranges', 'grapes'];

const invert = function (name) {
  return new Promise(resolve => {
    resolve(name.split('').reverse().join(''));
  });
};

sequentialPromiseMap(fruits, invert).then(results => console.log('got results', results));

License

MIT

Keywords

Promise

FAQs

Package last updated on 04 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts