
Product
Announcing Precomputed Reachability Analysis in Socket
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
at-a-time
allows you to do do asynchronous operations simultaneously but with a max number of operations going at any one time.
Promise.all()
allows you to simultaneously do asynchronous operations and a for
loop in an async function allows you to sequentially do asynchronous operations. But, sometimes you have more operations than you can handle at once and it would take too long to handle them sequentially. at-a-time
allows you to do do asynchronous operations simultaneously but with a max number of operations going at any one time.
$ npm install at-a-time
// import library
const atATime = require('at-a-time');
const endpoints = [
'https://api.something.com/12345',
'https://api.something.com/23451',
'https://api.something.com/34512',
'https://api.something.com/45123',
'https://api.something.com/51234',
'https://api.something.com/23456',
'https://api.something.com/62345',
'https://api.something.com/56234',
'https://api.something.com/45623',
'https://api.something.com/34562'
];
// create an array of Promise-returning functions
const operations = endpoints
.map(e => () => request.get(e));
// Work through the operations keeping two
// simultaneous operations going at a time.
// Usage with manual Promise handling
atATime(2, operations)
.then(res => {
console.log(res); // array of responses in order
})
.catch(err => {
// handle error
});
// Usage within an sync function
async function() {
try {
const res = await atATime(2, operations);
console.log(res); // array of responses in order
} catch(err) {
// handle error
}
};
// Usage within a generator function
co(function*() {
try {
const res = yield atATime(2, operations);
console.log(res); // array of responses in order
} catch(err) {
// handle error
}
});
$ npm install
$ npm test
Apache License Version 2.0
FAQs
at-a-time
The npm package at-a-time receives a total of 0 weekly downloads. As such, at-a-time popularity was classified as not popular.
We found that at-a-time 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.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.