
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Wrap functions with before and after functions in order to perform measurements. This code is written to work using node callback style and assumes that if the last argument passed to a function is a function, then it is a callback function and the wrapped function is an asynchronous function.
var hug = require('hug');
var runCount = 0;
var after = function(start, duration) {
console.log('This function took '+duration+' ms to run');
runCount++;
}
var function = someAsyncFunction(callback) {
// Do Work...
callback();
}
var wrapped = hug(someAsyncFunction, null, null, after);
wrapped(function() {});
Returns a wrapped function
Note that while the after function is called after the wrapped function, it is called before the callback when an async function is wrapped.
// install mocha
npm install mocha
mocha --reporter spec test/hug.js
FAQs
Wrap functions with before and after functions to observe system state
We found that hug 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
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.