Skip to content

Instantly share code, notes, and snippets.

@rockymeza
Created May 13, 2015 16:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rockymeza/1640881211bcc9742586 to your computer and use it in GitHub Desktop.
Save rockymeza/1640881211bcc9742586 to your computer and use it in GitHub Desktop.
A function decorator to make function decorators
// Based on idea from @nolsto
function makeDecorator(decorator) {
return function(target, key, descriptor) {
if (typeof descriptor !== 'undefined') {
descriptor.value = decorator(descriptor.value);
return descriptor
} else {
return decorator(target);
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment