2.1.5 • Published 7 months ago

compact-js-ast v2.1.5

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

Synopsis

Outputs a compact string representation of the espree AST of an input program.

casiano@sanclemente-2 compact-js-ast % compast -h                    
Usage: compast [options] [filename]

Arguments:
  filename                   file with the original code

Options:
  -V, --version              output the version number
  -o, --output <filename>    file name of the JS input program
  -p, --program <JSprogram>  JS input program
  -d --depth <number>        depth <number> Specifies the number of times to recurse while formatting object. 
                             This is useful for inspecting large objects. 
  -c --colors                If true, the output is styled with ANSI color codes (default: false)
  -z --compact               The most 3 inner elements are united on a single line
  -h, --help                 display help for command

Here is another example:

casiano@sanclemente-2 compact-js-ast % ./cast.cjs example.js -zc -d 3
[ 'Program',
  [ 'IfStatement',
    [ 'Literal', true ],
    [ 'ExpressionStatement', [ 'AssignmentExpression', '=', [Array], [Array] ] ],
    [ 'ExpressionStatement', [ 'AssignmentExpression', '=', [Array], [Array] ] ] ] ]

Install

npm i -g compact-js-ast

Examples

Geting the input for the argument:

 compast -p 'while (x == 1) {}'
[
  'Program',
  [
    'WhileStatement',
    [
      'BinaryExpression',
      '==',
      [ 'Identifier', 'x' ],
      [ 'Literal', 1 ]
    ],
    [ 'BlockStatement' ]
  ]
]

Compressed, only depth 2 and output in file salida.js:

āœ— compast -zd 2 cast.cjs -o salida.js

See Also

2.1.5

7 months ago

2.1.4

7 months ago

2.1.3

7 months ago

2.1.2

7 months ago

2.1.1

7 months ago

2.1.0

7 months ago

2.0.1

7 months ago

2.0.0

7 months ago

1.0.0

7 months ago