esanimate

2.0.0 • Public • Published

esanimate

NPM version Build Status Coverage Status Dependency Status

Convert back and forth between esprima/SpiderMonkey ASTs and JavaScript objects.

Example:

require('esanimate').astify({ foo: 'bar', quux: 123 });

Returns:

{ type: 'ObjectExpression',
  properties:
   [ { kind: 'init',
       key: { type: 'Identifier', name: 'foo' },
       value: { type: 'Literal', value: 'bar' } },
     { kind: 'init',
       key: { type: 'Identifier', name: 'quux' },
       value: { type: 'Literal', value: 123 } } ] }

And the other way around:

esanimate.objectify({
  type: 'ObjectExpression',
  properties: [
    {
      kind: 'init',
      key: { type: 'Identifier', name: 'foo' },
      value: { type: 'Literal', value: 'bar' },
    },
  ],
});

Output:

{ foo: 'bar' }

License

3-clause BSD license -- see the LICENSE file for details.

Readme

Keywords

none

Package Sidebar

Install

npm i esanimate

Weekly Downloads

4,042

Version

2.0.0

License

BSD-3-Clause

Unpacked Size

14.2 kB

Total Files

11

Last publish

Collaborators

  • papandreou