nebu
nebu copied to clipboard
[RFC] Node.prototype.wrap
node.wrap('try {\n', '\n}')
// identical to:
node.before('try {\n')
node.after('\n}')
You can wrap the node with anything, but the main use cases are blocks and call expressions.
Do we have a separate method for "block wrapping" that indents the wrapped node and implicitly adds the newline characters seen above? Or maybe passing true as the third argument can do that?
node.wrap('try {', '}', true)
// or
node.bwrap('try {', '}')
Not a big fan of the name bwrap though.