
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
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
The npm package function-filter receives a total of 1 weekly downloads. As such, function-filter popularity was classified as not popular.
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
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.