Created
May 13, 2015 16:00
-
-
Save rockymeza/1640881211bcc9742586 to your computer and use it in GitHub Desktop.
A function decorator to make function decorators
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
// 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