Created
December 8, 2015 14:56
-
-
Save snowmantw/f6ae1533f31bb820dbc5 to your computer and use it in GitHub Desktop.
Static decorator check.
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 procedure(instance, method, description) { | |
//console.log(description) | |
description.value.__procedure = true; | |
var org = description.value; | |
if (instance.__procedureDefined) { | |
throw new Error('Already has one procedure'); | |
} | |
instance.__procedureDefined = true; | |
description.value = function() { | |
console.log('>>>>> wrapped'); | |
return org.apply(this, arguments) | |
} | |
} | |
class Clz{ | |
@procedure | |
main() { | |
console.log('>>>> original'); | |
return 3; | |
} | |
//@procedure | |
notmain() { | |
console.log('<<<< should not happen'); | |
} | |
} | |
var c = new Clz(); | |
c.main(); | |
console.log(c.main.__procedure); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment