@balena/odata-parser 4.3.9 → 4.3.10

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.
@@ -1,3 +1,16 @@
1
+ - commits:
2
+ - subject: Add a fast path for matching `QuotedText` sections without apostrophes
3
+ hash: 6655906fe3b5af9d77087746f19c0f47cc52807f
4
+ body: |
5
+ This should be by far the most common case and avoids continuously
6
+ calling into the `Apostrophe` rule unnecessarily
7
+ footer:
8
+ Change-type: patch
9
+ change-type: patch
10
+ author: Pagan Gazzard
11
+ version: 4.3.10
12
+ title: ""
13
+ date: 2026-10-06T13:27:29.325Z
1
14
  - commits:
2
15
  - subject: Remove unnecessary `decodeURIComponent` for `ResourceName`
3
16
  hash: 5beaa8a5d4d98d05076ba70f5a0d1dd5b896e143
@@ -10,7 +23,7 @@
10
23
  author: Pagan Gazzard
11
24
  version: 4.3.9
12
25
  title: ""
13
- date: 2026-10-06T13:23:03.213Z
26
+ date: 2026-10-06T13:26:26.058Z
14
27
  - commits:
15
28
  - subject: Remove unnecessary `reset` function as every parse call reinitializes
16
29
  hash: a7f397c715f87e9b8879f9de25522c6a25bb50a8
package/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file
4
4
  automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
5
5
  This project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
+ # v4.3.10
8
+ ## (2026-10-06)
9
+
10
+ * Add a fast path for matching `QuotedText` sections without apostrophes [Pagan Gazzard]
11
+
7
12
  # v4.3.9
8
13
  ## (2026-10-06)
9
14
 
package/odata-parser.js CHANGED
@@ -343,6 +343,7 @@ function peg$parse(input, options) {
343
343
  const peg$r2 = /^[^:\/?#[\]@!$*&()+,;= %]/;
344
344
  const peg$r3 = /^[0-9]/;
345
345
  const peg$r4 = /^[^:\/?#[\]@!$*&()+,;=]/;
346
+ const peg$r5 = /^[^'%]/;
346
347
 
347
348
  const peg$e0 = peg$literalExpectation("/$metadata", false);
348
349
  const peg$e1 = peg$literalExpectation("/", false);
@@ -450,10 +451,11 @@ function peg$parse(input, options) {
450
451
  const peg$e103 = peg$literalExpectation("-", false);
451
452
  const peg$e104 = peg$literalExpectation("'", false);
452
453
  const peg$e105 = peg$literalExpectation("%27", false);
453
- const peg$e106 = peg$anyExpectation();
454
- const peg$e107 = peg$literalExpectation("datetime", false);
455
- const peg$e108 = peg$literalExpectation(" ", false);
456
- const peg$e109 = peg$literalExpectation("%20", false);
454
+ const peg$e106 = peg$classExpectation(["'", "%"], true, false, false);
455
+ const peg$e107 = peg$anyExpectation();
456
+ const peg$e108 = peg$literalExpectation("datetime", false);
457
+ const peg$e109 = peg$literalExpectation(" ", false);
458
+ const peg$e110 = peg$literalExpectation("%20", false);
457
459
 
458
460
  function peg$f0(tree) { return { tree, binds } }
459
461
  function peg$f1() {
@@ -4862,52 +4864,34 @@ function peg$parse(input, options) {
4862
4864
  if (s1 !== peg$FAILED) {
4863
4865
  s2 = [];
4864
4866
  s3 = peg$currPos;
4865
- s4 = peg$currPos;
4866
- peg$silentFails++;
4867
- s5 = peg$parseApostrophe();
4868
- peg$silentFails--;
4869
- if (s5 === peg$FAILED) {
4870
- s4 = undefined;
4867
+ s4 = [];
4868
+ s5 = input.charAt(peg$currPos);
4869
+ if (peg$r5.test(s5)) {
4870
+ peg$currPos++;
4871
4871
  } else {
4872
- peg$currPos = s4;
4873
- s4 = peg$FAILED;
4872
+ s5 = peg$FAILED;
4873
+ if (peg$silentFails === 0) { peg$fail(peg$e106); }
4874
4874
  }
4875
- if (s4 !== peg$FAILED) {
4876
- if (input.length > peg$currPos) {
4875
+ if (s5 !== peg$FAILED) {
4876
+ while (s5 !== peg$FAILED) {
4877
+ s4.push(s5);
4877
4878
  s5 = input.charAt(peg$currPos);
4878
- peg$currPos++;
4879
- } else {
4880
- s5 = peg$FAILED;
4881
- if (peg$silentFails === 0) { peg$fail(peg$e106); }
4882
- }
4883
- if (s5 !== peg$FAILED) {
4884
- s3 = s5;
4885
- } else {
4886
- peg$currPos = s3;
4887
- s3 = peg$FAILED;
4888
- }
4889
- } else {
4890
- peg$currPos = s3;
4891
- s3 = peg$FAILED;
4892
- }
4893
- if (s3 === peg$FAILED) {
4894
- s3 = peg$currPos;
4895
- s4 = peg$parseApostrophe();
4896
- if (s4 !== peg$FAILED) {
4897
- s5 = peg$parseApostrophe();
4898
- if (s5 !== peg$FAILED) {
4899
- s3 = s5;
4879
+ if (peg$r5.test(s5)) {
4880
+ peg$currPos++;
4900
4881
  } else {
4901
- peg$currPos = s3;
4902
- s3 = peg$FAILED;
4882
+ s5 = peg$FAILED;
4883
+ if (peg$silentFails === 0) { peg$fail(peg$e106); }
4903
4884
  }
4904
- } else {
4905
- peg$currPos = s3;
4906
- s3 = peg$FAILED;
4907
4885
  }
4886
+ } else {
4887
+ s4 = peg$FAILED;
4908
4888
  }
4909
- while (s3 !== peg$FAILED) {
4910
- s2.push(s3);
4889
+ if (s4 !== peg$FAILED) {
4890
+ s3 = input.substring(s3, peg$currPos);
4891
+ } else {
4892
+ s3 = s4;
4893
+ }
4894
+ if (s3 === peg$FAILED) {
4911
4895
  s3 = peg$currPos;
4912
4896
  s4 = peg$currPos;
4913
4897
  peg$silentFails++;
@@ -4925,7 +4909,7 @@ function peg$parse(input, options) {
4925
4909
  peg$currPos++;
4926
4910
  } else {
4927
4911
  s5 = peg$FAILED;
4928
- if (peg$silentFails === 0) { peg$fail(peg$e106); }
4912
+ if (peg$silentFails === 0) { peg$fail(peg$e107); }
4929
4913
  }
4930
4914
  if (s5 !== peg$FAILED) {
4931
4915
  s3 = s5;
@@ -4954,6 +4938,84 @@ function peg$parse(input, options) {
4954
4938
  }
4955
4939
  }
4956
4940
  }
4941
+ while (s3 !== peg$FAILED) {
4942
+ s2.push(s3);
4943
+ s3 = peg$currPos;
4944
+ s4 = [];
4945
+ s5 = input.charAt(peg$currPos);
4946
+ if (peg$r5.test(s5)) {
4947
+ peg$currPos++;
4948
+ } else {
4949
+ s5 = peg$FAILED;
4950
+ if (peg$silentFails === 0) { peg$fail(peg$e106); }
4951
+ }
4952
+ if (s5 !== peg$FAILED) {
4953
+ while (s5 !== peg$FAILED) {
4954
+ s4.push(s5);
4955
+ s5 = input.charAt(peg$currPos);
4956
+ if (peg$r5.test(s5)) {
4957
+ peg$currPos++;
4958
+ } else {
4959
+ s5 = peg$FAILED;
4960
+ if (peg$silentFails === 0) { peg$fail(peg$e106); }
4961
+ }
4962
+ }
4963
+ } else {
4964
+ s4 = peg$FAILED;
4965
+ }
4966
+ if (s4 !== peg$FAILED) {
4967
+ s3 = input.substring(s3, peg$currPos);
4968
+ } else {
4969
+ s3 = s4;
4970
+ }
4971
+ if (s3 === peg$FAILED) {
4972
+ s3 = peg$currPos;
4973
+ s4 = peg$currPos;
4974
+ peg$silentFails++;
4975
+ s5 = peg$parseApostrophe();
4976
+ peg$silentFails--;
4977
+ if (s5 === peg$FAILED) {
4978
+ s4 = undefined;
4979
+ } else {
4980
+ peg$currPos = s4;
4981
+ s4 = peg$FAILED;
4982
+ }
4983
+ if (s4 !== peg$FAILED) {
4984
+ if (input.length > peg$currPos) {
4985
+ s5 = input.charAt(peg$currPos);
4986
+ peg$currPos++;
4987
+ } else {
4988
+ s5 = peg$FAILED;
4989
+ if (peg$silentFails === 0) { peg$fail(peg$e107); }
4990
+ }
4991
+ if (s5 !== peg$FAILED) {
4992
+ s3 = s5;
4993
+ } else {
4994
+ peg$currPos = s3;
4995
+ s3 = peg$FAILED;
4996
+ }
4997
+ } else {
4998
+ peg$currPos = s3;
4999
+ s3 = peg$FAILED;
5000
+ }
5001
+ if (s3 === peg$FAILED) {
5002
+ s3 = peg$currPos;
5003
+ s4 = peg$parseApostrophe();
5004
+ if (s4 !== peg$FAILED) {
5005
+ s5 = peg$parseApostrophe();
5006
+ if (s5 !== peg$FAILED) {
5007
+ s3 = s5;
5008
+ } else {
5009
+ peg$currPos = s3;
5010
+ s3 = peg$FAILED;
5011
+ }
5012
+ } else {
5013
+ peg$currPos = s3;
5014
+ s3 = peg$FAILED;
5015
+ }
5016
+ }
5017
+ }
5018
+ }
4957
5019
  s3 = peg$parseApostrophe();
4958
5020
  if (s3 !== peg$FAILED) {
4959
5021
  peg$savedPos = s0;
@@ -5080,7 +5142,7 @@ function peg$parse(input, options) {
5080
5142
  peg$currPos += 8;
5081
5143
  } else {
5082
5144
  s2 = peg$FAILED;
5083
- if (peg$silentFails === 0) { peg$fail(peg$e107); }
5145
+ if (peg$silentFails === 0) { peg$fail(peg$e108); }
5084
5146
  }
5085
5147
  if (s2 !== peg$FAILED) {
5086
5148
  peg$savedPos = s1;
@@ -5340,7 +5402,7 @@ function peg$parse(input, options) {
5340
5402
  peg$currPos++;
5341
5403
  } else {
5342
5404
  s0 = peg$FAILED;
5343
- if (peg$silentFails === 0) { peg$fail(peg$e108); }
5405
+ if (peg$silentFails === 0) { peg$fail(peg$e109); }
5344
5406
  }
5345
5407
  if (s0 === peg$FAILED) {
5346
5408
  if (input.substr(peg$currPos, 3) === peg$c102) {
@@ -5348,7 +5410,7 @@ function peg$parse(input, options) {
5348
5410
  peg$currPos += 3;
5349
5411
  } else {
5350
5412
  s0 = peg$FAILED;
5351
- if (peg$silentFails === 0) { peg$fail(peg$e109); }
5413
+ if (peg$silentFails === 0) { peg$fail(peg$e110); }
5352
5414
  }
5353
5415
  if (s0 === peg$FAILED) {
5354
5416
  if (input.charCodeAt(peg$currPos) === 43) {
@@ -678,9 +678,13 @@ Apostrophe =
678
678
  QuotedText =
679
679
  Apostrophe
680
680
  text:(
681
+ // A quick scan of multiple characters that cannot match the `Apostrophe` rule, which is the most common case (it's pretty rare for strings to contain `'`/`%`)
682
+ $[^'%]+
683
+ / // Match % characters that could not be quick matched, but do not resolve to an apostrophe
681
684
  !Apostrophe
682
685
  @.
683
- / Apostrophe @Apostrophe
686
+ / // And finally match double up apostrophes which is how you escape them
687
+ Apostrophe @Apostrophe
684
688
  )*
685
689
  Apostrophe
686
690
  { return decodeURIComponent(text.join('')) }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@balena/odata-parser",
3
- "version": "4.3.9",
3
+ "version": "4.3.10",
4
4
  "description": "An OData parser written in OMeta",
5
5
  "type": "commonjs",
6
6
  "main": "odata-parser.js",
@@ -39,6 +39,6 @@
39
39
  "npm": ">=8.1.0"
40
40
  },
41
41
  "versionist": {
42
- "publishedAt": "2026-10-06T13:23:03.282Z"
42
+ "publishedAt": "2026-10-06T13:27:29.426Z"
43
43
  }
44
44
  }