asttv

1.0.1 • Public • Published

asttv - abstract syntax tree to value

What does it do?

It converts abstract syntax tree nodes to values, e.g.

{
  type: 'ArrayExpression',
  elements: [
    { type: 'Literal', value: 1 },
    { type: 'Literal', value: 2 },
    { type: 'Literal', value: 3 },
    { type: 'Literal', value: 4 },
    { type: 'Literal', value: 5 }
  ]
}

would be converted to:

[1, 2, 3, 4, 5]

Installation

npm install asttv

Usage

import convert from 'asttv'
 
const value = convert({ type: 'Literal', value: 42 })
console.log(value) // 42

What works?

Array, Boolean, Error, Infinity, Map, NaN, Number, Object, RegExp, Set, String, Symbol, WeakMap, WeakSet, undefined, null

Contributions are welcome.

Package Sidebar

Install

npm i asttv

Weekly Downloads

3

Version

1.0.1

License

MIT

Unpacked Size

11.1 kB

Total Files

21

Last publish

Collaborators

  • emilos