Skip to content

Instantly share code, notes, and snippets.

View jmcollin's full-sized avatar

Jean-Marie Collin jmcollin

View GitHub Profile
function interceptFunction (object, fnName, options) {
var noop = function () {};
var fnToWrap = object[fnName];
var before = options.before || noop;
var after = options.after || noop;
object[fnName] = function () {
before.apply(this, arguments);
var result = fnToWrap.apply(this, arguments);
after.apply(this, arguments);