Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Hey I just met you, and this is crazy, but here's my callback, so definitely call it once, and once only.
This tiny module is meant to help debug pesky asynchronous code by making sure your callbacks are called just once. It also checks if the given callback is undefined or if it's called in the same event loop.
This is meant to be used during testing, not production code. But could be used to help debug.
var callme = require('callme');
function asyncMethod(a, b, callback) {
callback = callme(callback);
someIO(a, b, function(err, result) {
if (err) callback(err);
result = permuteTheResult(result);
// this will throw if there is an error since it will be
// the second time the callback is called.
// a `return` was forgotten on the error check above.
callback(err, result);
});
}
The callme
function returned is also an instance of EventEmitter
. If you prefer to listen to the error
event instead, you can do so.
function asyncMethod(a, b, callback) {
callback = callme(callback);
callback.on('error', function(err) {
// do something with `err`
});
someIO(a, b, function() {
// etc
});
}
It also supports a timeout
option, make sure your callbacks are definitely called.
function asyncMethod(a, b, callback) {
callback = callme(callback, 2000); // set timeout to 2 seconds
callback.on('error', function(err) {
// this will fire in 2 seconds since `callback` is never called
});
}
npm install callme
Tests are written with mocha
npm test
MIT
FAQs
Hey I just met you, and this is crazy, but here's my callback.
The npm package callme receives a total of 0 weekly downloads. As such, callme popularity was classified as not popular.
We found that callme 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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.