Security News
CISA Brings KEV Data to GitHub
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
You can do the following without having to insert code into the function or wrap every call
var beforecb = require("beforecb");
var wrapped = beforecb(options, function original, function beforeCbFunction);
Arguments:
options
- Optional - An object with any of the following options:
original
- The function you want to wrap.beforeCbFunction
- A function to call just before the wrapped functions callback.options.async
is not set)args
on the callback passed to the beforeCbFunction argumentvar beforefn = require("beforefn"); // https://github.com/timoxley/beforefn
var beforecb = require("../");
function slowFunc(callback) {
for (var i = 0; i < 10e7; i++) {}
callback();
}
// Time calls to this function without inserting any new code into the function or wrapping calls to it
// Warning: This won't work if you call slowFunc multiple times in parallel.
var startTime;
slowFunc = beforefn(slowFunc, function() {
startTime = Date.now();
});
slowFunc = beforecb(slowFunc, function() {
console.log("Total time: " + (Date.now() - startTime));
});
// Call the function as usual, and see timings added
slowFunc(function() {
console.log("done");
});
FAQs
Wrap a function to call a function before its callback is called
The npm package beforecb receives a total of 12 weekly downloads. As such, beforecb popularity was classified as not popular.
We found that beforecb 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
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.