Created
March 6, 2012 10:55
-
-
Save podgorniy/1985671 to your computer and use it in GitHub Desktop.
Simple function decorator
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
function decorate (initial, decorate_before, decorate_after) { | |
return function () { | |
var initial_call_result; | |
if (typeof decorate_before === 'function') { | |
decorate_before(); | |
} | |
initial_call_result = initial.apply(this, arguments); | |
if (typeof decorate_after === 'function') { | |
decorate_after(); | |
} | |
return initial_call_result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment