Skip to content

Instantly share code, notes, and snippets.

@gkucmierz
Last active August 29, 2015 14:02
Show Gist options
  • Save gkucmierz/5eaa044d57da4f97ef6f to your computer and use it in GitHub Desktop.
Save gkucmierz/5eaa044d57da4f97ef6f to your computer and use it in GitHub Desktop.
add aspect to object
_.each(that, function(fn, prop) {
if (typeof fn === 'function') {
that[prop] = function() {
console.log('call: ' + prop);
return fn.apply(that, arguments);
};
}
});
(function() {
var indent = [];
_.each(that, function(fn, prop) {
if (typeof fn === 'function') {
that[prop] = function() {
console.log(indent.join('') + 'call: ' + prop);
indent.push(' ');
var res = fn.apply(that, arguments);
indent.pop();
return res;
};
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment