
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
callback-queue
Advanced tools
Put your callbacks into queue to make sure that concurrent requests that you might want to perform will only be executed once
Node.js callback queue. Can be used with browserify as well.
Idea is to queue callbacks, when same function wants to be called at the same time by different callers.
One example would be conserving resources spent on outgoing http requests.
npm install callback-queue -S
callbackQueue.add(String, Function)
: queues callbacks based on key attributecallbackQueue.remove(String, Error)
: calls queued callbacks with Error argumentconst callbackQueue = require('callback-queue');
const request = require('request');
function performOutgoingRequest(url, next) {
const callback = callbackQueue.add(url, next);
if (!callback) {
return;
}
request(url, callback);
}
for (let i = 0; i < 100; i++) {
// request itself will be performed just once
performOutgoingRequest('https://google.com', function niceCallback(err, resp, body) {
// will be called 100 times
});
}
for (let x = 0; x < 100; x++) {
// request itself will be performed just once
performOutgoingRequest('https://google.com', function niceCallback(err, resp, body) {
// will be called 100 times with Error object
});
}
callbackQueue.remove('https://google.com', new Error('cancel it!'));
FAQs
Put your callbacks into queue to make sure that concurrent requests that you might want to perform will only be executed once
We found that callback-queue 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.