meriyah 4.5.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/CHANGELOG.md +340 -449
  2. package/README.md +22 -28
  3. package/dist/meriyah.amd.js +8916 -8806
  4. package/dist/meriyah.amd.min.js +1 -1
  5. package/dist/meriyah.cjs +8916 -8806
  6. package/dist/meriyah.cjs.js +8916 -8806
  7. package/dist/meriyah.cjs.min.js +1 -1
  8. package/dist/meriyah.esm.js +8916 -8806
  9. package/dist/meriyah.esm.min.js +1 -1
  10. package/dist/meriyah.esm.min.mjs +1 -1
  11. package/dist/meriyah.esm.mjs +8916 -8806
  12. package/dist/meriyah.iife.js +8916 -8806
  13. package/dist/meriyah.iife.min.js +1 -1
  14. package/dist/meriyah.min.cjs +1 -1
  15. package/dist/meriyah.system.js +8916 -8806
  16. package/dist/meriyah.system.min.js +1 -1
  17. package/dist/meriyah.umd.cjs +8916 -8806
  18. package/dist/meriyah.umd.es5.js +8925 -8830
  19. package/dist/meriyah.umd.es5.min.js +1 -1
  20. package/dist/meriyah.umd.js +8916 -8806
  21. package/dist/meriyah.umd.min.cjs +1 -1
  22. package/dist/meriyah.umd.min.js +1 -1
  23. package/dist/src/chars.d.ts +135 -135
  24. package/dist/src/common.d.ts +201 -200
  25. package/dist/src/common.d.ts.map +1 -1
  26. package/dist/src/errors.d.ts +188 -187
  27. package/dist/src/errors.d.ts.map +1 -1
  28. package/dist/src/estree.d.ts +515 -507
  29. package/dist/src/estree.d.ts.map +1 -1
  30. package/dist/src/lexer/charClassifier.d.ts +24 -24
  31. package/dist/src/lexer/charClassifier.d.ts.map +1 -1
  32. package/dist/src/lexer/comments.d.ts +14 -14
  33. package/dist/src/lexer/common.d.ts +26 -26
  34. package/dist/src/lexer/decodeHTML.d.ts +1 -1
  35. package/dist/src/lexer/decodeHTML.d.ts.map +1 -1
  36. package/dist/src/lexer/identifier.d.ts +8 -8
  37. package/dist/src/lexer/index.d.ts +9 -9
  38. package/dist/src/lexer/jsx.d.ts +6 -6
  39. package/dist/src/lexer/jsx.d.ts.map +1 -1
  40. package/dist/src/lexer/numeric.d.ts +5 -5
  41. package/dist/src/lexer/regexp.d.ts +3 -3
  42. package/dist/src/lexer/scan.d.ts +6 -6
  43. package/dist/src/lexer/scan.d.ts.map +1 -1
  44. package/dist/src/lexer/string.d.ts +12 -12
  45. package/dist/src/lexer/template.d.ts +4 -4
  46. package/dist/src/meriyah.d.ts +7 -7
  47. package/dist/src/meriyah.d.ts.map +1 -1
  48. package/dist/src/parser.d.ts +119 -118
  49. package/dist/src/parser.d.ts.map +1 -1
  50. package/dist/src/token.d.ts +167 -167
  51. package/dist/src/unicode.d.ts +5 -5
  52. package/package.json +32 -27
  53. package/src/common.ts +42 -49
  54. package/src/errors.ts +3 -1
  55. package/src/estree.ts +11 -1
  56. package/src/lexer/comments.ts +1 -1
  57. package/src/lexer/decodeHTML.ts +3 -5
  58. package/src/lexer/identifier.ts +4 -4
  59. package/src/lexer/jsx.ts +13 -12
  60. package/src/lexer/numeric.ts +2 -2
  61. package/src/lexer/regexp.ts +3 -3
  62. package/src/lexer/scan.ts +8 -6
  63. package/src/lexer/string.ts +2 -2
  64. package/src/meriyah.ts +1 -2
  65. package/src/parser.ts +681 -533
package/README.md CHANGED
@@ -4,11 +4,8 @@
4
4
 
5
5
  <p align="center">
6
6
  <a href="https://www.npmjs.com/package/meriyah"><img src="https://img.shields.io/npm/v/meriyah.svg?style=flat-square" alt="Meriyah NPM"/></a>
7
- <a href="https://lgtm.com/projects/g/meriyah/meriyah/context:javascript"><img src="https://img.shields.io/lgtm/grade/javascript/g/meriyah/meriyah.svg?logo=lgtm&logoWidth=18" alt="GitHub license" /></a>
8
- <a href="https://lgtm.com/projects/g/meriyah/meriyah/alerts"><img src="https://img.shields.io/lgtm/alerts/g/meriyah/meriyah.svg?logo=lgtm&logoWidth=18" alt="Total alerts" /></a>
9
- <a href="https://circleci.com/gh/meriyah/meriyah"><img src="https://circleci.com/gh/meriyah/meriyah.svg?style=svg" alt="Circle" /></a>
7
+ <a href="https://github.com/meriyah/meriyah/actions/workflows/node.js.yml"><img src="https://github.com/meriyah/meriyah/actions/workflows/node.js.yml/badge.svg" alt="Node.js CI"/></a>
10
8
  <a href="https://github.com/meriyah/meriyah/blob/master/LICENSE.md"><img src="https://img.shields.io/github/license/meriyah/meriyah.svg" alt="License" /></a>
11
-
12
9
  </p>
13
10
 
14
11
  <br>
@@ -17,25 +14,23 @@
17
14
 
18
15
  ## Features
19
16
 
20
- * Conforms to the standard ECMAScript® 2021 (ECMA-262 11th Edition) language specification
21
- * Support TC39 proposals via option
22
- * Support for additional ECMAScript features for Web Browsers
23
- * JSX support via option
24
- * Does **not** support TypeScript or Flow
25
- * Optionally track syntactic node locations
26
- * Emits an ESTree-compatible abstract syntax tree
27
- * No backtracking
28
- * Low memory usage
29
- * Very well tested (~99 000 unit tests with full code coverage)
30
- * Lightweight - ~90 KB minified
17
+ - Conforms to the standard ECMAScript® 2021 (ECMA-262 11th Edition) language specification
18
+ - Support TC39 proposals via option
19
+ - Support for additional ECMAScript features for Web Browsers
20
+ - JSX support via option
21
+ - Does **not** support TypeScript or Flow
22
+ - Optionally track syntactic node locations
23
+ - Emits an ESTree-compatible abstract syntax tree
24
+ - No backtracking
25
+ - Low memory usage
26
+ - Very well tested (~99 000 unit tests with full code coverage)
27
+ - Lightweight - ~90 KB minified
31
28
 
32
29
  ## ESNext features
33
30
 
34
- * [Decorators](https://github.com/tc39/proposal-decorators)
35
- * [Class Public Instance Fields & Private Instance Fields](https://github.com/tc39/proposal-class-fields)
36
- * [Hashbang grammar](https://github.com/tc39/proposal-hashbang)
37
- * [Private methods](https://github.com/tc39/proposal-private-methods)
38
- * [Static class fields and private static methods](https://github.com/tc39/proposal-static-class-features/)
31
+ - [Decorators](https://github.com/tc39/proposal-decorators)
32
+ - [Import Attributes](https://github.com/tc39/proposal-import-attributes)
33
+ - [JSON Modules](https://github.com/tc39/proposal-json-modules)
39
34
 
40
35
  **Note:** These features need to be enabled with the `next` option.
41
36
 
@@ -83,13 +78,13 @@ This is the available options:
83
78
  impliedStrict: false;
84
79
 
85
80
  // Allows comment extraction. Accepts either a function or array
86
- onComment: []
81
+ onComment: [];
87
82
 
88
83
  // Allows detection of automatic semicolon insertion. Accepts a callback function that will be passed the charater offset where the semicolon was inserted
89
- onInsertedSemicolon: (pos) => {}
84
+ onInsertedSemicolon: (pos) => {};
90
85
 
91
86
  // Allows token extraction. Accepts either a function or array
92
- onToken: []
87
+ onToken: [];
93
88
 
94
89
  // Enable non-standard parenthesized expression node
95
90
  preserveParens: false;
@@ -100,13 +95,13 @@ This is the available options:
100
95
  // Adds a source attribute in every node’s loc object when the locations option is `true`
101
96
  source: false;
102
97
 
103
- // Enable React JSX parsing
104
- jsx: false
98
+ // Enable React JSX parsing
99
+ jsx: false;
105
100
  }
106
-
107
101
  ```
108
102
 
109
103
  ### onComment and onToken
104
+
110
105
  If an array is supplied, comments/tokens will be pushed to the array, the item in the array contains `start/end/range` information when ranges flag is true, it will also contain `loc` information when loc flag is true.
111
106
 
112
107
  If a function callback is supplied, the signature must be
@@ -120,6 +115,7 @@ declare function onToken(token: string, start: number, end: number, loc: SourceL
120
115
  Note the `start/end/loc` information are provided to the function callback regardless of the settings on ranges and loc flags. onComment callback has one extra argument `value: string` for the body string of the comment.
121
116
 
122
117
  ### onInsertedSemicolon
118
+
123
119
  If a function callback is supplied, the signature must be
124
120
 
125
121
  ```ts
@@ -129,11 +125,9 @@ declare function onInsertedSemicolon(position: number): void;
129
125
  ## Example usage
130
126
 
131
127
  ```js
132
-
133
128
  import { parseScript } from './meriyah';
134
129
 
135
130
  parseScript('({x: [y] = 0} = 1)');
136
-
137
131
  ```
138
132
 
139
133
  This will return when serialized in json: