
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
function-filter
Advanced tools
function-filter is an efficient and lightweight way to allow logic to be extended across different concerns of your application. By wrapping a function in a filter, it is possible to dynamically intercept and optionally modify parameter and return values to the underlying function.
In addition, filters can call alternative logic, or nothing at all, depending on the use case.
Some examples of why you may want to do this include:
npm install function-filter
Usage under ES5 and ES6 is essentially the same:
ES5:
var filter = require('function-filter').default;
var myFn = filter(function(chain, argA, argB) {
console.log(argA, argB);
});
myFn("Hello", "World!");
// Hello World!
myFn.addFilter(function(chain, argA, argB) {
console.log("Originally called with:", argA, argB);
return chain.next(chain, "Goodbye", argB);
});
myFn("Hello", "World!");
// Originally called with Hello World!
// Goodbye World!
ES6:
import filter from 'function-filter';
const myFn = filter((chain, argA, argB) => {
console.log(argA, argB);
});
myFn("Hello", "World!");
// Hello World!
myFn.addFilter((chain, argA, argB) => {
console.log("Originally called with:", argA, argB);
return chain.next(chain, "Goodbye", argB);
});
myFn("Hello", "World!");
// Originally called with Hello World!
// Goodbye World!
This project adheres to Semantic Versioning. For a list of detailed changes, please refer to CHANGELOG.md.
Please see CONTRIBUTING.md.
This implementation is heavily inspired by li3's filter system.
function-filter is released under the BSD 3-clause “New” License.
FAQs
Simple AOP using filterable function wrappers
We found that function-filter 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

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.