Closed sindresorhus closed 10 years ago
the remove()
on rocambole-token
only removes tokens. the rocambole-node module will have methods for manipulating the AST itself but it still doesn't have a remove
method.
a simple way to remove all the tokens from a node is to: token.eachInBetween(node.startToken, node.endToken, token.remove)
another way would be to remove the links like:
function removeNodeContent(node){
var prev = node.startToken.prev;
var next = node.endToken.next;
node.startToken = prev;
prev.next = next;
next.prev = prev;
node.endToken = next;
}
that way the ast.toString
would not include any content from the node (even tho it would still be part of the AST).
I tried this:
I would have expected it to remove the debugger statement.
However, this seems to work:
But manual labor isn't fun.