nebu icon indicating copy to clipboard operation
nebu copied to clipboard

[RFC] Node.prototype.wrap

Open aleclarson opened this issue 7 years ago • 0 comments

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.

aleclarson avatar May 30 '18 14:05 aleclarson