
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
sequential-promise-map
Advanced tools
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.
npm install sequential-promise-map
sequentialPromiseMap(arrayOfValues, promiseGenerator, /*batchSize*/).then(....)
arrayOfValues
should be an Array
of elements that will be asynchronously processedpromiseGenerator
parameter should be a function to process each element of the array, receiving up to three arguments:promiseGenerator = function(currentElement, indexOfCurrent, originalArray) {
...
}
batchSize
is an optional argument, a positive integer specifying the maximum batch size for parallel processing. If not set, the elements will be processed one by one. Set this to a value greater than 1 to allow for parallelisation.The function will resolve will contain an array of Promise
results, in the same order as the arguments, or reject with the first rejection.
const sequentialPromiseMap = require('sequential-promise-map');
const fruits = ['apples', 'oranges', 'grapes'];
const invert = function (name/*, index, array*/) {
return new Promise(resolve => {
resolve(name.split('').reverse().join(''));
});
};
sequentialPromiseMap(fruits, invert).then(results => console.log('got results', results));
MIT
FAQs
A simple sequential version of Promise.map
The npm package sequential-promise-map receives a total of 4,462 weekly downloads. As such, sequential-promise-map popularity was classified as popular.
We found that sequential-promise-map demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.