npm

Share private packages across your team with npm Orgs, now with simplified billing via the aws marketplace!Learn more »

cept

1.0.4 • Public • Published

cept

Build Coverage Downloads Size

Intercept method calls.

Installation

npm:

npm install cept

Usage

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

install

npm i cept

Downloadsweekly downloads

43

version

1.0.4

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability