Skip to content

Instantly share code, notes, and snippets.

@davegurnell
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davegurnell/8147ac53298506c789a1 to your computer and use it in GitHub Desktop.
Save davegurnell/8147ac53298506c789a1 to your computer and use it in GitHub Desktop.
sweet.js macro for inserting angular.js dependency injection annotations
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