yps

2.0.4 • Public • Published

yps

a reversible, transparent spy for functions/methods

Build Status npm version

Infiltration

functions

var logHello = function () { console.log('Hello!'); };
logHello = yps.infiltrate(logHello);

methods

var scope = {
  logHello: function () { console.log('Hello!'); }
};
yps.infiltrate(scope, 'logHello');

Reports

Once a spy has infiltrated, it will record the arguments for each call.

logHello(42, 'purple');
logHello();
logHello.calls;  // [[42, 'purple'], []]

You can purge the calls (in case your spy gets burned).

logHello.purge();
logHello.calls;  // []

Exfiltration

Remove your spy and any trace that it ever existed.

functions

logHello = yps.exfiltrate(logHello);

methods

yps.exfiltrate(scope, 'logHello');

Package Sidebar

Install

npm i yps

Weekly Downloads

0

Version

2.0.4

License

ISC

Last publish

Collaborators

  • reergymerej