
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
observe-function
Advanced tools
Observe when a function is called and assign callbacks before and after the function is called.
Observe when a function is called and assign callbacks before and after the function is called.
$ npm install --save observe-function
var observeFunction = require('observe-function');
var observedFunction = function (arg1, arg2){
console.log('I am observed');
return arg1 + arg2;
};
//Simply wrap the function you want to observe
var observer = observeFunction(observedFunction);
//assign callback to be called before function executes
observer.before(function(){
console.log('I am called before');
});
//... and after it executes
observer.after(function(){
console.log('I am called after');
});
//call the observer just as you would the regular function
var three = observer(1, 2);
//=>I am called before
//=>I am observed
//=>I am called after
console.log(three);
//=> 3
Assigns the function to be observed. Returns a function that can be called just like the provided function.
Assigns a callback to be called before the function is called. An observer can be assigned multiple "before" callbacks.
Assigns a callback to be called after the function is called. An observer can be assigned multiple "after" callbacks.
Removes the specified callback from the list of "before" callbacks
Removes the specified callback from the list of "after" callbacks
Removes all callbacks from the list of "before" callbacks
Removes all callbacks from the list of "after" callbacks
Removes all "before" and "after" callbacks
FAQs
Observe when a function is called and assign callbacks before and after the function is called.
We found that observe-function 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
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.