1.0.5 • Published 9 years ago

esprima-to-value v1.0.5

Weekly downloads
11
License
MIT
Repository
github
Last release
9 years ago

esprima-to-value

convert an esprima ast object/literal to an real object

Install

$ npm install esprima-to-value --save

Usage

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' ]
 */

Author

License

MIT

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago