goldstein 5.22.0 → 5.22.1

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.
package/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ 2024.12.22, v5.22.1
2
+
3
+ feature:
4
+ - 6e95200 goldstein: keyword-broken-string: goldstein methods
5
+
1
6
  2024.12.22, v5.22.0
2
7
 
3
8
  feature:
package/README.md CHANGED
@@ -460,11 +460,6 @@ When you accidentally broke string, Goldstein will fix it:
460
460
  +const a = 'hello world';
461
461
  ```
462
462
 
463
- to:
464
-
465
- ```js
466
- ```
467
-
468
463
  ### Missing Initializer
469
464
 
470
465
  Forget to add assignment (`=`), not problem!
package/bin/gs.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "goldstein",
3
- "version": "5.22.0",
3
+ "version": "5.22.1",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "JavaScript with no limits",
@@ -12,6 +12,7 @@ export default function keywordBrokenString(Parser) {
12
12
 
13
13
  return super.getTokenFromCode(code);
14
14
  }
15
+
15
16
  parseVarStatement(node, kind, allowMissingInitializer) {
16
17
  this.next();
17
18
  this.parseVar(node, false, kind, allowMissingInitializer);
@@ -20,6 +21,18 @@ export default function keywordBrokenString(Parser) {
20
21
  return this.finishNode(node, 'VariableDeclaration');
21
22
  }
22
23
 
24
+ goldsteinWrongQuoteStart(ch) {
25
+ if (!ch)
26
+ return true;
27
+
28
+ return ch === QUOTE || ch === MOBILE_CLOSE_QUOTE;
29
+ }
30
+
31
+ goldsteinWrongQuoteEnd() {
32
+ if (this.input[this.pos - 1] === ';')
33
+ --this.pos;
34
+ }
35
+
23
36
  readString(quote) {
24
37
  let out = '';
25
38
  let chunkStart = ++this.pos;
@@ -27,18 +40,13 @@ export default function keywordBrokenString(Parser) {
27
40
  for (;;) {
28
41
  const ch = this.input.charCodeAt(this.pos);
29
42
 
30
- if (!ch)
31
- break;
32
-
33
- if (ch === QUOTE || ch === MOBILE_CLOSE_QUOTE)
43
+ if (this.goldsteinWrongQuoteStart(ch))
34
44
  break;
35
45
 
36
46
  /* c8 ignore start */
37
47
  if (ch === quote)
38
48
  break;
39
- /* c8 ignore end */
40
49
 
41
- /* c8 ignore start */
42
50
  if (ch === 92) {
43
51
  // '\'
44
52
  out += this.input.slice(chunkStart, this.pos);
@@ -57,9 +65,7 @@ export default function keywordBrokenString(Parser) {
57
65
  /* c8 ignore end */
58
66
  } else {
59
67
  if (isNewLine(ch)) {
60
- if (this.input[this.pos - 1] === ';')
61
- --this.pos;
62
-
68
+ this.goldsteinWrongQuoteEnd();
63
69
  break;
64
70
  }
65
71
 
@@ -80,3 +86,4 @@ function isNewLine(code) {
80
86
  || code === 0x2028
81
87
  || code === 0x2029;
82
88
  }
89
+