Function transform

  • Recursively execute a callback on this node and all its children. If the callback returns a non-undefined value, it will overwrite the node. This function will not modify the root node of the input tree.

    Parameters

    • node: Node | Node[]

      Node or array of nodes

    • transformations: ((node, property, parent, originalNode) => Node) | ((node, property, parent, originalNode) => Node)[]

      A map of node types to callbacks, or a single callback that will be called for all node types, or a list of either, which will be applied in order

    • Optional o: {
          except: Function | Function[];
          only: Function | Function[];
      }
      • except: Function | Function[]

        Ignore walking nodes of these types

      • only: Function | Function[]

        Only walk nodes of this type

    Returns Node | Node[]

    The transformation's return value on the root node(s) of the input tree, or the root node(s) if the transformation did not return a value

Generated using TypeDoc