JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 708689
  • Score
    100M100P100Q173570F

Eliminate extra properties from AST output

Package Exports

  • espurify

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (espurify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

espurify

Eliminate extra properties from AST output

EXAMPLE

var espurify = require('espurify'),
    esprima = require('esprima'),
    assert = require('assert');

var jsCode = 'assert("foo")';
var ast = esprima.parse(jsCode, {tolerant: true, loc: true});
var purified = espurify(ast);

// original AST
assert.deepEqual(ast, {
    type: 'Program',
    body: [
        {
            type: 'ExpressionStatement',
            expression: {
                type: 'CallExpression',
                callee: {
                    type: 'Identifier',
                    name: 'assert',
                    loc: {
                        start: {
                            line: 1,
                            column: 0
                        },
                        end: {
                            line: 1,
                            column: 6
                        }
                    }
                },
                arguments: [
                    {
                        type: 'Literal',
                        value: 'foo',
                        raw: '"foo"',
                        loc: {
                            start: {
                                line: 1,
                                column: 7
                            },
                            end: {
                                line: 1,
                                column: 12
                            }
                        }
                    }
                ],
                loc: {
                    start: {
                        line: 1,
                        column: 0
                    },
                    end: {
                        line: 1,
                        column: 13
                    }
                }
            },
            loc: {
                start: {
                    line: 1,
                    column: 0
                },
                end: {
                    line: 1,
                    column: 13
                }
            }
        }
    ],
    loc: {
        start: {
            line: 1,
            column: 0
        },
        end: {
            line: 1,
            column: 13
        }
    },
    errors: []
});

// Extra properties eliminated from AST output
assert.deepEqual(purified, {
    type: 'Program',
    body: [
        {
            type: 'ExpressionStatement',
            expression: {
                type: 'CallExpression',
                callee: {
                    type: 'Identifier',
                    name: 'assert'
                },
                arguments: [
                    {
                        type: 'Literal',
                        value: 'foo'
                    }
                ]
            }
        }
    ]
});

INSTALL

via npm

Install

$ npm install --save espurify

Use

var espurify = require('espurify');

via bower

Install

$ bower install --save espurify

Load (espurify function is exported)

<script type="text/javascript" src="./path/to/bower_components/espurify/build/espurify.js"></script>

AUTHOR

LICENSE

Licensed under the MIT license.