
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
promise-parallelizer
Advanced tools
A lightweight library to parallelize promises.
$ npm install promise-parallelizer
function parallelize(tasks, mode = "STREAMING", concurrency = 1, delay = 0, callback = null) Promise({ started: int, ended: int })
const promiseParallelizer = require('promise-parallelizer');
const mode = "BATCH"
const concurrency = 3;
const tasks = [1,2,3,4,5,6].map(function(index) {
return function () {
return new Promise((resolve, reject) => {
setTimeout(() => {
counter++;
resolve(index);
}, 1000 * (index % 3 +1));
});
};
});
(async function() {
// all of the promises should be resolved after 6 seconds in BATCH mode
const result = await promiseParallelizer.parallelize(tasks, "BATCH", 3);
})();
(async function() {
// all of the promises should be resolved after 8 seconds in BATCH mode ( 2 seconds delay between consecutive batches)
const result = await promiseParallelizer.parallelize(tasks, "BATCH", 3, 2);
})();
(async function() {
// callback should log 2 times the intermediary result in BATCH mode ( once after each batch )
const result = await promiseParallelizer.parallelize(tasks, "BATCH", 3, 0, (intermediaryResult) => {
console.log("intermediary result : " + intermediaryResult)
});
})();
const mode = "STREAMING"
const concurrency = 3;
const tasks = [1,2,3,4,5,6].map(function(index) {
return function () {
return new Promise((resolve, reject) => {
setTimeout(() => {
counter++;
resolve(index);
}, 1000 * (index % 3 +1));
});
};
})
(async function() {
// all of the promises should be resolved after 5 seconds in STREAMING mode
const result = await promiseParallelizer.parallelize(tasks, "STREAMING", 3);
})();
(async function() {
// all of the promises should be resolved after 6 seconds in STREAMING mode ( 2 seconds delay to flush after a promise ends)
const result = await promiseParallelizer.parallelize(tasks, "STREAMING", 3, 2);
})();
(async function() {
// callback should log 6 times the intermediary result in STREAMING mode ( once at each promise resolution )
const result = await promiseParallelizer.parallelize(tasks, "STREAMING", 3, 0, (intermediaryResult) => {
console.log("intermediary result : " + intermediaryResult)
});
})();
MIT
FAQs
A lightweight library to parallelize promises.
The npm package promise-parallelizer receives a total of 2 weekly downloads. As such, promise-parallelizer popularity was classified as not popular.
We found that promise-parallelizer 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.