Created
May 16, 2014 12:53
-
-
Save Unitech/fd9561765bd3bc0d61d1 to your computer and use it in GitHub Desktop.
Wrapping functions
This file contains hidden or 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
function before(fn) { | |
var ret = null; | |
return function() { | |
try { | |
ret = fn.apply(this, arguments); | |
} catch(e) { | |
console.error(e); | |
} | |
return ret; | |
}; | |
} | |
Object.keys(WatchDog).forEach(function(key) { | |
if (typeof WatchDog[key] == 'function') | |
WatchDog[key] = before(WatchDog[key]); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment