1.0.1 • Published 5 years ago

asttv v1.0.1

Weekly downloads
2,379
License
MIT
Repository
github
Last release
5 years ago

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.