Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
highlight words in vim, then do `:'<,'>!rewrite-js platoon-to-tape.js`
module.exports = {
':root > expr > assign > lookup + call:contains(platoon) > function > block > expr:first-child': annotate_name
, ':root > expr > assign > lookup + call:contains(platoon) > function:last-child': rewrite_exports
, 'call:contains(async) > function:last-child': rewrite_async
}
function annotate_name(node) {
node.update('')
}
function rewrite_exports(node) {
var assign = node.parent.parent
, platoon = assign.right.arguments.slice(1)
node.parent.parent.parent.update(
platoon.map(function(subnode) {
var body = subnode.body.body
, val = JSON.stringify(body[0].expression.value)
subnode.body.body = subnode.body.body.slice(1)
return 'test('+val+', '+subnode.source()+'\n)'
}).join('\n\n')
)
return false
}
function rewrite_async(node) {
node.parent.update(node.source())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.