Skip to content

Instantly share code, notes, and snippets.

@monolithed
Last active December 20, 2015 07:49
Show Gist options
  • Save monolithed/6096449 to your computer and use it in GitHub Desktop.
Save monolithed/6096449 to your computer and use it in GitHub Desktop.
Function.prototype.decorate = function(fn, context) {
return fn.bind(context || this, this);
};
var foo = function() {
return 1;
}
.decorate(function(callback) {
return '<a>' + callback() + '</a>';
})
.decorate(function(callback) {
return '<b>' + callback() + '</b>';
});
foo(); // "<b><a>1</a></b>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment