Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.