Skip to content

Instantly share code, notes, and snippets.

@kunle
Created July 4, 2017 20:34
Show Gist options
  • Save kunle/b6e5d2dcf638fe1e407a7660184c4365 to your computer and use it in GitHub Desktop.
Save kunle/b6e5d2dcf638fe1e407a7660184c4365 to your computer and use it in GitHub Desktop.
Wrapper for Logging service calls
let wrapper = function (bb, context) {
this.doWrap(bb, context);
};
wrapper.prototype.doWrap = function(bb, context) {
for(let key in bb){
if(typeof bb[key] === 'function') {
wrapper.prototype[key] = function() {
console.log('before', context);
bb[key].apply(null,arguments);
console.log('after', context);
};
} else {
wrapper.prototype[key] = bb[key];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment