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 AST.

    Parameters

    • node: any

      AST node or array of nodes

    • transformations: {} | ((arg0, arg1, arg2, arg3) => any) | ({} | ((arg0, arg1, arg2, arg3) => any))[]

      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: string | Function | string[];
          only: string | Function | string[];
      }
      • except: string | Function | string[]

        Ignore walking nodes of these types

      • only: string | Function | string[]

        Only walk nodes of this type

    Returns any

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

Generated using TypeDoc