Skip to content

convert an esprima ast object/literal to an real object

License

Notifications You must be signed in to change notification settings

cspa-exam/esprima-to-value

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

convert an esprima ast object/literal to an real object

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%