Skip to content

Instantly share code, notes, and snippets.

@ThomasG77
Forked from brianarn/maths.js
Created May 9, 2014 00:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThomasG77/d4a6d55663d524237c14 to your computer and use it in GitHub Desktop.
Save ThomasG77/d4a6d55663d524237c14 to your computer and use it in GitHub Desktop.
define([
'my/superModule',
'wrapper';
], function (superModule, wrapper) {
// Let's wrap it, aspect style
wrapper(superModule, 'superModule');
// Tada, all superModule methods will now log
});
define([
'underscore'
], function (_) {
return function (toWrap, identifier) {
_(toWrap)
.chain()
.functions()
.each(function (method) {
var oldMethod = toWrap[method];
toWrap[method] = function () {
var groupName = identifier + ': ' + method;
console.group(groupName);
console.log('%s args: %o', method, arguments);
var value = oldMethod.apply(this, arguments);
console.log('%s return value: %o', method, value);
console.groupEnd(groupName);
return value;
};
});
return toWrap;
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment