py-ast - v1.16.0
    Preparing search index...

    Function walk

    Tree-traversal utilities modeled on Python's ast module.

    • walk — iterate over every node in a tree, breadth-first.
    • NodeVisitor — base class for read-only tree visitors.
    • NodeTransformer — base class for tree-rewriting visitors.
    • Recursively walks an AST node and all of its descendants, yielding each node in pre-order (a node is yielded before its children).

      Child nodes are discovered generically by inspecting each own property of the current node: array properties are scanned for elements that look like AST nodes (objects with a nodeType property), and object properties are recursed into directly if they look like an AST node. The nodeType property itself is skipped.

      Parameters

      • node: ASTNodeUnion

        The root AST node to start walking from.

      Returns Generator<ASTNodeUnion>

      A generator that lazily yields node and every descendant node, in pre-order.

      for (const node of walk(moduleNode)) {
      console.log(node.nodeType);
      }