convert an esprima ast object/literal to an real object
$ npm install esprima-to-value --save
const esprima = require('esprima');
const toValue = require('esprima-to-value');
const ast = esprima.parse(code);
console.log(ast.body);
/**
* [
* { type: 'Literal', value: 10 },
* { type: 'ObjectExpression', properties: ... },
* { type: 'ArrayExpression', elements: ... },
* { type: 'FunctionExpression', body: { type: 'ReturnStatement', ... } },
* ]
*/
console.log(toValue(ast.body));
/**
* will output:
* [ 10, { ... }, [ ... ], 'res.body' ]
*/
MIT