
Security News
Node.js Drops Bug Bounty Rewards After Funding Dries Up
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.
Promise.all([].map(() => {})).then(results => {}), serial! (or even concurent)
const Mapromise = require('mapromise');
const iterable = ['first', 'middle', 'last'];
function iterationCallback(value, index) {
return new Promise((resolve) => {
global.setTimeout(() => {
resolve(value);
}, (Math.random() * 10));
});
}
Mapromise(iterable, iterationCallback).then(results => {
console.log(results);
});
// > [first, middle, last]
const Mapromise = require('mapromise');
const iterable = ['first', 'middle', 'last'];
function iterationCallback(value, index) {
return new Promise((resolve) => {
global.setTimeout(() => {
resolve(value);
}, (Math.random() * 10));
});
}
Mapromise(Iterable, iterationCallback, {concurency: 50}).then(results => {
console.log(results);
});
// > [first, middle, last], order of execution is not guaranteed, but order of results is
{
collect: true, // Do you want to collect results of each iteration (Array.map behavior)
concurrency: 1 // For the concurrent variant
}
Promise, duh!
Everything that implements iterator interface (has next method), or has Symbol.iterator method defined.
Because I had some uses for this behavior. Async.mapSeries is the best comparison.
Promises didn't offer this functionality natively and I don't know if Bluebird does.
There are some. Though, they are mostly just pure smoke tests and slight torture/heap-explosion ones.
index.js is the simplest implementation of mapping promises using async/await I came up with, but it has one problem.
It starts to suck on higher concurrency numbers.
That is caused by holding promise references and await Promise.all[] which sucks up a lot of memory compared to more complex implementation using some kind of defered resolution.
perf.js uses a single defered promise to manage iteration state and is much more memory efficient on higher concurrency numbers.
See perf-test
FAQs
Use promise async funtions to map over collection.
The npm package mapromise receives a total of 1 weekly downloads. As such, mapromise popularity was classified as not popular.
We found that mapromise 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
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.