Socket
Book a DemoInstallSign in
Socket

esprima-to-value

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esprima-to-value

convert an ast(object) to its object for Esprima

latest
Source
npmnpm
Version
1.0.5
Version published
Maintainers
1
Created
Source

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

  • Yorkie Lui

License

MIT

Keywords

esprima

FAQs

Package last updated on 25 Sep 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts