Skip to content

Instantly share code, notes, and snippets.

@podgorniy
Created March 6, 2012 10:55
Show Gist options
  • Save podgorniy/1985671 to your computer and use it in GitHub Desktop.
Save podgorniy/1985671 to your computer and use it in GitHub Desktop.
Simple function decorator
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