esanimate

Helpers for converting back and forth between esprima/SpiderMonkey ASTs and JavaScript objects.

BSD-3-Clause 7 个版本
安装
npm install esanimate
yarn add esanimate
pnpm add esanimate
bun add esanimate
README

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.

版本列表
2.0.0 2020-11-22
1.1.1 2019-09-01
1.1.0 2016-06-15
1.0.3 2015-10-11
1.0.2 2015-10-09
1.0.1 2015-10-08
1.0.0 2015-10-07