Skip to main content

ASTGenerator

ASTGenerator is a fork of Astring. The original author is David Bonnet and Astring is released under an MIT license. This version is only available by the MPLv2.0 license. Please see the original source.

@see

https://github.com/davidbonnet/astring.git

Eventually once ASTGenerator is feature complete for Babylon & ESTree AST and further modularized it will be released as a separate NPM module supporting plugins.

Please note that not all of the Babylon AST nodes are currently supported. astParser is currently only used by typhonjs-escomplex for realizing computed method names and associated Halstead operands and operators.

Index

Constructors

Methods

Constructors

constructor

Methods

staticparse

  • parse(node: any, options?: { indent: string; lineEnd: string; startingIndentLevel: number }): default
  • ASTGenerator returns an instance of ParserData containing a string representing the rendered code of the provided AST node. In addition Halstead operators and operands are available via ParserData.


    Parameters

    • node: any

      An ESTree or Babylon AST node.

    • options: { indent: string; lineEnd: string; startingIndentLevel: number } = ...

      Optional parameters for source code formatting.

    Returns default

staticparseNodes

  • parseNodes(nodes: any[], options?: { indent: string; lineEnd: string; startingIndentLevel: number }): default
  • ASTGenerator returns an instance of ParserData containing a string representing the rendered code of the provided AST nodes. In addition Halstead operators and operands are available via ParserData.


    Parameters

    • nodes: any[]

      An array of ESTree or Babylon AST nodes to parse.

    • options: { indent: string; lineEnd: string; startingIndentLevel: number } = ...

      Optional parameters for source code formatting.

    Returns default