cept
Intercept method calls.
Install
npm:
npm install ceptUse
var cept = require('cept')
// Intercept:
var stop = cept(console, 'log', noop)
// From now on `console.log` is ignored:
console.log('foo bar baz')
// No longer ignored!
stop()
function noop() {}API
stop = intercept(context, key, callback)
Intercept all calls to context[key] (e.g., console.log).
From now on, when the original method would be invoked, callback is used
instead.
Invoking stop reverts everything back to normal.
Parameters
context(Object) — Context objectkey(string) — Property where the original function livescallback(Function) - Interceptor
Returns
Function — Used to revert back to the previous function.