{"_id":"@azariasb/escaya","_rev":"2-2cfbd0e87f371c03c72990eba4d5c95b","name":"@azariasb/escaya","dist-tags":{"latest":"0.0.63"},"versions":{"0.0.62":{"name":"@azariasb/escaya","version":"0.0.62","description":"A blazing fast 100% spec compliant, self-hosted incremental javascript parser written in Typescript","main":"dist/escaya.umd.min.js","module":"dist/escaya.esm.min.js","jsnext:main":"dist/escaya.esm.min.js","browser":"dist/escaya.umd.min.js","types":"dist/escaya.d.ts","typings":"dist/escaya.d.ts","author":{"name":"azariasb"},"license":"ISC","homepage":"https://github.com/AzariasB/escaya","repository":{"type":"git","url":"git+https://github.com/AzariasB/escaya.git"},"bugs":{"url":"https://github.com/AzariasB/escaya/issues"},"keywords":["lightweight"],"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"scripts":{"build":"tsc","build:watch":"tsc -w","lint":"eslint \"{src,test,scripts}/**/*.{ts,js}\" --fix","prettier":"node ./scripts/prettier.js write-changed","prettier-all":"node ./scripts/prettier.js write","bundle":"cross-env rimraf dist && node scripts/bundle.js","bundle:bench":"cross-env rimraf dist && node scripts/bundle.js bench","test":"mocha \"test/**/*.ts\"","test:single":"mocha","test:watch":"npm run test -- --watch --watch-extensions ts","test:verbose":"npm run test -- -R spec","test:watch:verbose":"npm run test:watch -- -R spec","prepare-nightly":"node scripts/bump-dev-version","coverage":"cross-env TS_NODE_PROJECT=\"test/tsconfig.json\" nyc -n \"src/**/*.ts\" -e .ts -i ts-node/register -r text-summary -r lcov -r html npm test","post_coverage":"cross-env cat ./coverage/lcov.info | coveralls"},"devDependencies":{"@types/mocha":"^8.2.0","@types/node":"^14.14.14","@typescript-eslint/eslint-plugin":"^4.10.0","@typescript-eslint/parser":"^4.10.0","chalk":"^4.1.0","coveralls":"^3.1.0","cross-env":"^7.0.3","eslint":"^7.15.0","eslint-plugin-import":"^2.22.1","eslint-plugin-node":"^11.1.0","glob":"^7.1.6","husky":"^4.3.6","mocha":"^8.2.1","nyc":"^15.1.0","path":"^0.12.7","prettier":"^2.2.1","rimraf":"^3.0.2","rollup":"^2.35.1","rollup-plugin-replace":"^2.2.0","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","source-map-support":"^0.5.19","test262-parser-tests":"0.0.5","ts-node":"9.1.1","tsconfig-paths":"^3.9.0","typescript":"^4.1.3","unicode-13.0.0":"^0.8.0"},"husky":{"hooks":{"pre-commit":"node ./scripts/prettier.js check-changed"}},"engines":{"node":">=6.0.0"},"directories":{"test":"test"},"dependencies":{},"gitHead":"03ab9b8def9b06fefea9f01804e116926af6211f","_id":"@azariasb/escaya@0.0.62","_nodeVersion":"14.3.0","_npmVersion":"6.14.8","dist":{"integrity":"sha512-g6nQesBhVrmShPhxWQ9APNMcDlOcRTtANs+rFOtedyuivwxHeSRjEcsoTFj2t9y/jvxXwSTZmO0JUtMEe5TbPw==","shasum":"770a351e357694c2150836ab0fb36f0ad564f5bf","tarball":"https://registry.npmjs.org/@azariasb/escaya/-/escaya-0.0.62.tgz","fileCount":146,"unpackedSize":433432,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf2jaxCRA9TVsSAnZWagAA4SUQAKOpNO9/TEN35Doqti6K\n2x4qwgqgr1rFv/2psKjTSNGs4QLvlSCM9xXatXLhJEqqGSTLIMmTELDw1+5U\nS7t0c01WyYyRc+VENudul/YPLHUGnRMcyWzsgq4rBsknTR4a208KaxU2FYz7\nb3hp+cRDd/s/j8NkUVZAaSYtboILAPKsMpoZ/uaajGDZfsFFzWf/UhqVe1Lc\n4g3Lc7DCljkCng3N99bXEFsepgCVp4KEQpd8LdxUVLj+QM8DHUXls1ObFCDt\npPD3n8RdOukkFQ9FBoI0zjIHEYtogqNRIlK+nso6a/Yi4OqVIn9/Hpse4jP1\nyz28Bu1z3iX45EnUVtr7FZpr9VduHNx1i9kXvGlXKLyynypkEFdbZkWxfy/x\n7Df5SF4WsneRV9hCPZOPXu3b7L0n5YmaqurJBjcK5VZO9Rupuk68Q+0dNiWM\nhuty/husKkAy64LCWUa4GdoUekuZlaPomawciE6OrA6wZbKnQ7qXFF8H2yPy\nFS4ytU+he08ReSn80YWRSwGArOvazvv1LzNQuoK8OyJ4MD4gYaDrpVwrq8+y\nIYhFuGimxh++gTf2OoorQt6i8oqCEiFP96gg90VySGDAOEBYN/NVVPaIdQCo\nuuVpaYvHCYfwXgh5un2DpmW0Yjhx5O7YqtKiHd5lMO2Jfcmwty1YXCBogNkN\nC4LM\r\n=de9x\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA9do30XemTnSXokjou0pPzQFJJPD8SZkyFyEpi9MWuDAiAVwjdEXYA3yrOcLT4ycZEVPTt88W6dH9SM/rJrSp2Frw=="}]},"_npmUser":{"name":"azariasb","email":"azarias.boutin@gmail.com"},"maintainers":[{"name":"azariasb","email":"azarias.boutin@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/escaya_0.0.62_1608136368792_0.6101839992657934"},"_hasShrinkwrap":false},"0.0.63":{"name":"@azariasb/escaya","version":"0.0.63","description":"A blazing fast 100% spec compliant, self-hosted incremental javascript parser written in Typescript","main":"dist/escaya.umd.min.js","module":"dist/escaya.esm.min.js","jsnext:main":"dist/escaya.esm.min.js","browser":"dist/escaya.umd.min.js","types":"dist/escaya.d.ts","typings":"dist/escaya.d.ts","author":{"name":"KFlash"},"license":"ISC","homepage":"https://github.com/AzariasB/escaya","repository":{"type":"git","url":"git+https://github.com/AzariasB/escaya.git"},"bugs":{"url":"https://github.com/AzariasB/escaya/issues"},"keywords":["lightweight"],"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"scripts":{"build":"tsc","build:watch":"tsc -w","lint":"eslint \"{src,test,scripts}/**/*.{ts,js}\" --fix","prettier":"node ./scripts/prettier.js write-changed","prettier-all":"node ./scripts/prettier.js write","bundle":"cross-env rimraf dist && node scripts/bundle.js","bundle:bench":"cross-env rimraf dist && node scripts/bundle.js bench","test":"mocha \"test/**/*.ts\"","test:single":"mocha","test:watch":"npm run test -- --watch --watch-extensions ts","test:verbose":"npm run test -- -R spec","test:watch:verbose":"npm run test:watch -- -R spec","prepare-nightly":"node scripts/bump-dev-version","coverage":"cross-env TS_NODE_PROJECT=\"test/tsconfig.json\" nyc -n \"src/**/*.ts\" -e .ts -i ts-node/register -r text-summary -r lcov -r html npm test","post_coverage":"cross-env cat ./coverage/lcov.info | coveralls"},"devDependencies":{"@types/mocha":"^8.2.0","@types/node":"^14.14.14","@typescript-eslint/eslint-plugin":"^4.10.0","@typescript-eslint/parser":"^4.10.0","chalk":"^4.1.0","coveralls":"^3.1.0","cross-env":"^7.0.3","eslint":"^7.15.0","eslint-plugin-import":"^2.22.1","eslint-plugin-node":"^11.1.0","glob":"^7.1.6","husky":"^4.3.6","mocha":"^8.2.1","nyc":"^15.1.0","path":"^0.12.7","prettier":"^2.2.1","rimraf":"^3.0.2","rollup":"^2.35.1","rollup-plugin-replace":"^2.2.0","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","source-map-support":"^0.5.19","test262-parser-tests":"0.0.5","ts-node":"9.1.1","tsconfig-paths":"^3.9.0","typescript":"^4.1.3","unicode-13.0.0":"^0.8.0"},"husky":{"hooks":{"pre-commit":"node ./scripts/prettier.js check-changed"}},"engines":{"node":">=6.0.0"},"directories":{"test":"test"},"dependencies":{},"gitHead":"0aeb972347769a9c9d91d03bbf4dd53a30ad2473","_id":"@azariasb/escaya@0.0.63","_nodeVersion":"14.3.0","_npmVersion":"6.14.8","dist":{"integrity":"sha512-ITsAs8x+A0b0lp3UhBtbR/Rh5qhc05+HAFOzIs6iA1nmp190zTuxEQtAQDB+c1BW3QADjzLMjkdARjcC9S3kEQ==","shasum":"06b43a5e8140ac4b17b3175a151a85d7c0f4ffba","tarball":"https://registry.npmjs.org/@azariasb/escaya/-/escaya-0.0.63.tgz","fileCount":146,"unpackedSize":433430,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf2jdFCRA9TVsSAnZWagAA3csP/1Przx4yClyFh1fBp2Ig\n7xTYS+VfUMgI3DNitDxEr0AdYhmWoSh5dqm6Lw3WtgUD/EtePkvJejoaJnGF\nCL1isCCi/37nOZqlfhNkeoCzo8/aE6L08NWG8lsDsX/O5bCso8e2wPo+3HkX\nLWQE7X3DcshNpCcWIebJlP3TnEo1E7EhHSXF5M0w0iCSRY7rf73ZupVBIITh\nzv2TNr8lEND60HiUzh7ZmxYowN6guBf/nQM9lu9dKnD+zIbaIBU9xfP8VBWi\nvwIdedemTMj2BV/94tB+E4ms3qvCxY3hIzKQMusYOtL0oriprjxHtBqKDfAg\n7HIlBebVF2rtIUSelug5ZJVDaCYmoQDmQxRoU/xv2zCzUmsjG/B3rN+dpnhO\nG2x8KNztOhw2W4akkMvJtIQWfq5e1U/lT13t2P8dAv/m45KbpE4tyyw4TMMP\nDFLWu77uq0sX1UT57sval8KlNd8X2/jPKb0A/rej4RywDeNlTKsf1v5HsgAJ\nfxYfy7OiTP82Bc4UKNXyeGZbqFOMDP3jAcEOua65WRu02iA2Dz/JrhsQcScG\nazigeYb6dnsvYEZd07IG/MeJyVmP0jyTOcZdLzY/OiITK+uf4Or0l3CvStJS\nMqHY1SfgM7aB3fWTn7j2zVcimYiAPANqiiME1D/FHY3tS9coZ3qj7Jkt+x71\nNavt\r\n=d+td\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDwymKh0TDpFe64zoUG2bkrTqU8ApOmbwg6QOZ5hoWRlAiEAk+v/ytfxCIz3Pc3nC0zh1hALJVA1xBrxqG6AQGpwbKA="}]},"_npmUser":{"name":"azariasb","email":"azarias.boutin@gmail.com"},"maintainers":[{"name":"azariasb","email":"azarias.boutin@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/escaya_0.0.63_1608136516373_0.14807693101214192"},"_hasShrinkwrap":false}},"time":{"created":"2020-12-16T16:32:48.725Z","0.0.62":"2020-12-16T16:32:48.959Z","modified":"2022-04-04T17:15:23.106Z","0.0.63":"2020-12-16T16:35:16.601Z"},"maintainers":[{"name":"azariasb","email":"azarias.boutin@gmail.com"}],"description":"A blazing fast 100% spec compliant, self-hosted incremental javascript parser written in Typescript","homepage":"https://github.com/AzariasB/escaya","keywords":["lightweight"],"repository":{"type":"git","url":"git+https://github.com/AzariasB/escaya.git"},"author":{"name":"KFlash"},"bugs":{"url":"https://github.com/AzariasB/escaya/issues"},"license":"ISC","readme":"<h1 align=\"center\">Escaya</h1>\n\n<p align=\"center\"> An blazing  fast 100% spec compliant, incremental javascript parser written in Typescript</p>\n\n<br>\n\n<p align=\"center\">\n    <a href=\"https://lgtm.com/projects/g/escaya/escaya/context:javascript\"><img src=\"https://img.shields.io/lgtm/grade/javascript/g/escaya/escaya.svg?logo=lgtm&logoWidth=18\" alt=\"GitHub license\" /></a>\n   <a href=\"https://circleci.com/gh/escaya/escaya\"><img src=\"https://circleci.com/gh/escaya/escaya.svg?style=svg\" alt=\"Circle\" /></a>\n   <a href=\"https://github.com/escaya/escaya/blob/master/LICENSE.md\"><img src=\"https://img.shields.io/github/license/escaya/escaya.svg\" alt=\"License\" /></a>\n</p>\n\n**Work in progress**\n\n## Features\n\n* Conforms to the standard ECMAScript® 2021 (ECMA-262 11th Edition) language specification\n* Support for additional ECMAScript features for Web Browsers\n* Optionally track syntactic node locations\n* Optionally concrete syntax\n* Emits an ECMAScript® 2021 compatible abstract syntax tree\n* Error recovery mode with incremental parsing support\n* Errors diagnostics\n* Supports JSON serializing\n* Possible to use a custom AST such as ESTree and Babel AST\n* No backtracking\n* Low memory usage\n* Optimized for use on handheld devices such as a mobile phone or tablet\n* Very well tested (~67 000 unit tests with full code coverage)\n* Lightweight - ~94 KB minified\n\n## API\n\nEscaya generates it's own `AST` that is close to the [ECMAScript® 2021 specs](https://tc39.es/ecma262/index.html), and can be used to perform [syntactic analysis](https://en.wikipedia.org/wiki/Parsing) (parsing) of a JavaScript program, and with `ES2015` and later a JavaScript program can be either [a script or a module](https://tc39.github.io/ecma262/index.html#sec-ecmascript-language-scripts-and-modules).\n\nExample usage:\n\n```ts\n\nimport { parseScript, parseModule } from './escaya';\n\nparseScript('({x: [y] = 0} = 1)', { impliedStrict: true });\n\nparseModule('({x: [y] = 0} = 1)');\n\n```\n\nThis is the available options:\n\n| Option        | Description |\n| ------------------- | ------------------------------------------------------------ |\n| `next`              | Enable stage 3 support (ESNext) |\n| `disableWebCompat`  | Disable web compatibility |\n| `loc`               | Enable line/column location information start and end offsets to each node |\n| `cst`               | Enable additional concrete syntax to each node |\n| `impliedStrict`     | Enable strict mode initial enforcement |\n| `module`            | Enable parsing in module goal in error recovery mode |\n\n\n### Comments\n\n`Escaya` lets you extract leading and trailing comments from a given position with either `extractCommentsScript` or `extractCommentsModule`. It takes the source code as it's first argument, the position within the source code where you want to extract the comments from as it's second argument. The last argument let's you decide if you want to extract leading or trailing comments - `collectCommentsScript(source, start, boolean);`\n\nHere is an example on how to get all trailing comments belonging to `bar`\n\n```ts\nimport { extractCommentsScript } from './escaya';\n\nextractCommentsScript('/* MultieLine */ bar /* trailing */', 20, true);\n\n```\n\nOutputs:\n\n```ts\n[{\n        comment: ' trailing ',\n        end: 35,\n        newLine: false,\n        start: 21,\n        type: 'MultiLine'\n}]\n```\n\n## Escaya AST\n\nThe AST used by `Escaya` represents the structure of an ECMAScript program as a tree and is designed to stay true to the [ECMAScript® 2021 specification](https://tc39.es/ecma262/index.html). The AST has been designed for performance, and it nearly eliminates the chance of accidentally creating an AST that does not represent an ECMAScript program while also requiring fewer bytes than an `ESTree AST` like `Babel` and `Acorn` produce, and `Babel parser's` own AST.\n\nThe `Escaya AST` doesn't try to follow the SpiderMonkey-compatible standard that `ESTree` strictly follows. For example it distinguish `Identifier` from `IdentifierPattern`. That makes it easier to calculate the free variables of a program.\n\n### Concrete syntax (CST)\n\nEscaya supports a simplified definition of \"concrete syntax\" that follows the [ECMAScript® 2021 specification](https://tc39.es/ecma262/index.html).\n\nA `ParenthesisExpression` has been added to represent the `( )` and everything in between. See [Primary Expression - Supplemental Syntax](https://tc39.es/ecma262/#sec-primary-expression)\n\nA `Elison` node has been added to represent a splice array in [12.2.5 Array Initializer](https://tc39.es/ecma262/#sec-array-initializer) and [13.3.3 Destructuring Binding Patterns - ArrayBindingPattern](https://tc39.es/ecma262/#prod-ArrayBindingPattern).\n\nA `Semicolon` node has been used  in [ClassElement](https://tc39.es/ecma262/#prod-ClassElement) to represent the `;` token.\n\n### Custom AST\n\nUse of `parseCustomScript` and `parseCustomModule` let you use whatever AST format you want.\n\nHere is an example on how to use `Babel AST`\n\n```ts\n\nimport { parseCustomScript } from './escaya';\n\nparseCustomScript('a = b', {\n        Script: function (source, directives, statements) {\n          return {\n            type: 'File',\n            errors: [],\n            program: {\n              type: 'Program',\n              sourceType: 'script',\n              body: statements\n            },\n            directives,\n            comments: [],\n            start: 0,\n            end: source.length\n          };\n        }\n    );\n  });\n\n```\n\n## Error recovery\n\nWhen Escaya parser is given an input that does not represent a valid JavaScript program, it throws an exception. If parsing in\nrecovery mode, the parser will continue parsing and produce a syntax tree that conforms to the standard [ECMAScript® 2021 specs](https://tc39.es/ecma262/index.html).\n\nHowever, Escaya will continue to do a full parse for every keystroke. To avoid this you can enable incremental parsing. This is best demonstrated with an example.\n\n```ts\n\nimport { recovery, update } from './escaya';\n\nconst rootNode = recovery('(foo);', 'filename.js', { module: true });\n\nconst ast = update(rootNode, '=> bar;', 'filename.js', { span: { start: 6, length: 0 }, newLength: 7 })\n\n```\n\nNow when incremental parsing has been enabled, Escaya will reuse nodes from the old tree if possible.\n\n### Options\n\nThe options for the recovery mode are about the same as  for `parseScript` and `parseModule` except you have to enable `{module: true}` if parsing in module goal.\n\nNo options can be set during an incremental update because it's only possible to reuse a node if it was parsed in the same context that parser are currently in.\n\n### AST\n\nOne of the design goals for Escaya has been that the abstract syntax tree (AST) shouldn't change. It should be the same either you are parsing in `normal mode` or `recovery mode` but there are a couple of exceptions.\n\nFor example, in `recovery mode` you are creating a `RootNode` instead of either a `Module` or `Script`. This `RootNode` has additional information such as diagnostics, context masks and mutual parser flags that you *carry over* from the recovery mode to the incremental parsing and let you continue to parse in the same context that you are currently in, unless you set a strict directive on the `RootNode`. If you do this, Escaya will parse in strict mode and you will not be able to recover any nodes from the old tree if you were first parsing in *sloppy mode*, because it's only possible to reuse a node if it was parsed with the same context that the parser used before.\n\n### EScaya recovery mode vs. Acorn loose\n\nThe main difference is that EScaya's recovery mode conforms to the [ECMAScript® 2021 specs](https://tc39.es/ecma262/index.html) , while `Acorn Loose` does not.\nIt's not even an JavaScript parser. You can play with `Acorn Loose`  on `ASTExplorer` and you will notice the differences.\n\nAs an example you will get a `BlockStatement` if you try to parse something like `try`.\n\n\n## Performance\n\n<p align=\"left\">\n  <img src=\"./media/bench.png\">\n</p>\n","readmeFilename":"README.md"}