asttv
v1.0.1
Published
asttv - abstract syntax tree to value
Downloads
5
Maintainers
Readme
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.