Add a serialize method
emilos opened this issue · 0 comments
emilos commented
Context
Sometimes it's useful to serialize an abstract syntax tree node to a value/object.
For example:
{
type: 'ArrayExpression',
elements: [
{ type: 'Literal', value: 1 },
{ type: 'Literal', value: 2 },
{ type: 'Literal', value: 3 },
{ type: 'Literal', value: 4 },
{ type: 'Literal', value: 5 }
]
}
can be serialized to:
[1, 2, 3, 4, 5]
Acceptance criteria
- install
asttv
(https://github.com/buxlabs/asttv) - add a static
serialize
method - accept a node, use asstv and return the result
- add specs
- update README