Skip to content

[RFC] Node.prototype.wrap #11

Description

@aleclarson
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions