JSPM

ecmascript-version-detector

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 27
  • Score
    100M100P100Q122670F
  • License MIT

ecmascript version detector

Package Exports

  • ecmascript-version-detector

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 (ecmascript-version-detector) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ecmascript-version-detector Build Status

ECMAScript Version Detection library.

Online demo

screenshot

Go to https://azu.github.io/ecmascript-version-detector/

Install

Install with npm:

npm install ecmascript-version-detector

Usage

parse(code: string): {selector:string, version:string, node: Object, en: Object}[]

Parse code and return results.

const parse = require("ecmascript-version-detector").parse;
parse(`const x = 1 ** 2;`);
/*
[
    {
        "selector": "//BinaryExpression[@operator=='**']",
        "version": "2016",
        "en": {
            "name": "BinaryExpression exponentiation operator"
        },
        "node": {
            "type": "BinaryExpression",
            "start": 0,
            "end": 6,
            "loc": {
                "start": {
                    "line": 1,
                    "column": 0
                },
                "end": {
                    "line": 1,
                    "column": 6
                }
            },
            "left": {
                "type": "NumericLiteral",
                "start": 0,
                "end": 1,
                "loc": {
                    "start": {
                        "line": 1,
                        "column": 0
                    },
                    "end": {
                        "line": 1,
                        "column": 1
                    }
                },
                "extra": {
                    "rawValue": 1,
                    "raw": "1"
                },
                "value": 1
            },
            "operator": "**",
            "right": {
                "type": "NumericLiteral",
                "start": 5,
                "end": 6,
                "loc": {
                    "start": {
                        "line": 1,
                        "column": 5
                    },
                    "end": {
                        "line": 1,
                        "column": 6
                    }
                },
                "extra": {
                    "rawValue": 2,
                    "raw": "2"
                },
                "value": 2
            }
        }
    },
    ....
]
*/

Contributing

Pull requests and stars are always welcome.

How to add data?

  1. mkdir data/<new-node-type>
  2. add index.js to data/<new-node-type>
  3. npm run build
  4. Pull Request!!

index.js is following format:

// BooleanLiteral is `true` or `false`
// This is available since ECMAScript version 3
// Display name is "BooleanLiteral"
module.exports = {
    "selector": "//BooleanLiteral",
    "version": "3",
    "en": {
        "name": "BooleanLiteral",
        "link": "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean"
    }
};
  • selector: the selector match the node type.
    • This project use ASTq query engine
    • This is similar to XPath query.
  • version: the feature is available in the version
  • en
    • name: display name
    • link: related link. e.g.) MDN link

For bugs and feature requests, please create an issue.

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Resources

Changelog

See Releases page.

Running tests

Install devDependencies and Run npm test:

npm i -d && npm test

Author

License

MIT © azu