Last active
August 29, 2015 14:03
-
-
Save davegurnell/8147ac53298506c789a1 to your computer and use it in GitHub Desktop.
sweet.js macro for inserting angular.js dependency injection annotations
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
macro di { | |
case { | |
_(function ($args (,) ...) { | |
$body... | |
}) | |
} => { | |
letstx $names... = _.map( | |
#{ $args... }, | |
function(ident) { | |
return makeValue(ident.token.value, ident); | |
} | |
); | |
return #{ | |
[ | |
$names (,) ..., | |
function($args...) { | |
$body... | |
} | |
] | |
} | |
} | |
} | |
di(function(alpha, beta, gamma) { | |
return alpha + beta + gamma; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment