yps
v2.0.4
Published
a reversible, transparent spy for functions/methods
Downloads
12
Maintainers
Readme
yps
a reversible, transparent spy for functions/methods
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');