Skip to content
main
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

readme.md

cept

Build Coverage Downloads Size

Intercept method calls.

Install

npm:

npm install cept

Use

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 object
  • key (string) — Property where the original function lives
  • callback (Function) - Interceptor
Returns

Function — Used to revert back to the previous function.

License

MIT © Titus Wormer

You can’t perform that action at this time.