Created
July 4, 2017 20:34
-
-
Save kunle/b6e5d2dcf638fe1e407a7660184c4365 to your computer and use it in GitHub Desktop.
Wrapper for Logging service calls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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