json-p3 2.2.1 → 2.3.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 (46) hide show
  1. package/README.md +0 -1
  2. package/dist/json-p3.browser.js +5303 -0
  3. package/dist/json-p3.browser.min.js +2 -0
  4. package/dist/json-p3.browser.min.js.map +1 -0
  5. package/dist/json-p3.cjs.js +110 -109
  6. package/dist/json-p3.esm.js +110 -109
  7. package/dist/json-p3.iife.min.js +1 -1
  8. package/dist/json-p3.iife.min.js.map +1 -1
  9. package/package.json +11 -24
  10. package/dist/deep_equals.d.ts +0 -10
  11. package/dist/index.d.ts +0 -10
  12. package/dist/json-p3.iife.js +0 -5338
  13. package/dist/patch/errors.d.ts +0 -11
  14. package/dist/patch/index.d.ts +0 -11
  15. package/dist/patch/patch.d.ts +0 -161
  16. package/dist/path/environment.d.ts +0 -165
  17. package/dist/path/errors.d.ts +0 -65
  18. package/dist/path/expression.d.ts +0 -101
  19. package/dist/path/extra/expression.d.ts +0 -6
  20. package/dist/path/extra/index.d.ts +0 -0
  21. package/dist/path/extra/selectors.d.ts +0 -35
  22. package/dist/path/functions/count.d.ts +0 -7
  23. package/dist/path/functions/function.d.ts +0 -26
  24. package/dist/path/functions/has.d.ts +0 -44
  25. package/dist/path/functions/index.d.ts +0 -11
  26. package/dist/path/functions/length.d.ts +0 -7
  27. package/dist/path/functions/match.d.ts +0 -33
  28. package/dist/path/functions/pattern.d.ts +0 -2
  29. package/dist/path/functions/search.d.ts +0 -34
  30. package/dist/path/functions/value.d.ts +0 -7
  31. package/dist/path/index.d.ts +0 -76
  32. package/dist/path/lex.d.ts +0 -69
  33. package/dist/path/lru_cache.d.ts +0 -10
  34. package/dist/path/node.d.ts +0 -84
  35. package/dist/path/parse.d.ts +0 -61
  36. package/dist/path/path.d.ts +0 -42
  37. package/dist/path/segments.d.ts +0 -39
  38. package/dist/path/selectors.d.ts +0 -85
  39. package/dist/path/serialize.d.ts +0 -6
  40. package/dist/path/token.d.ts +0 -70
  41. package/dist/path/types.d.ts +0 -46
  42. package/dist/pointer/errors.d.ts +0 -42
  43. package/dist/pointer/index.d.ts +0 -24
  44. package/dist/pointer/pointer.d.ts +0 -106
  45. package/dist/tsconfig.tsbuildinfo +0 -1
  46. package/dist/types.d.ts +0 -25
@@ -1,5 +1,5 @@
1
1
  /*
2
- * json-p3 version 2.2.1
2
+ * json-p3 version 2.3.0
3
3
  * https://github.com/jg-rp/json-p3
4
4
  *
5
5
  * MIT License
@@ -335,10 +335,7 @@ class JSONPointer {
335
335
  }
336
336
  static encode(tokens) {
337
337
  if (!tokens.length) return "";
338
- return (
339
- // eslint-disable-next-line prefer-template
340
- "/" + tokens.map(token => token.replaceAll("~", "~0").replaceAll("/", "~1")).join("/")
341
- );
338
+ return "/" + tokens.map(token => token.replaceAll("~", "~0").replaceAll("/", "~1")).join("/");
342
339
  }
343
340
 
344
341
  /**
@@ -355,8 +352,7 @@ class JSONPointer {
355
352
  * If the value pointed to by _pointer_ does not exist in _value_, and
356
353
  * no fallback value is given.
357
354
  */
358
- resolve(value) {
359
- let fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : UNDEFINED;
355
+ resolve(value, fallback = UNDEFINED) {
360
356
  try {
361
357
  return this.tokens.reduce(this.getItem.bind(this), value);
362
358
  } catch (error) {
@@ -461,10 +457,7 @@ class JSONPointer {
461
457
  * @returns A new JSON Pointer that is the concatenation of all tokens or
462
458
  * "parts".
463
459
  */
464
- join() {
465
- for (var _len = arguments.length, tokens = new Array(_len), _key = 0; _key < _len; _key++) {
466
- tokens[_key] = arguments[_key];
467
- }
460
+ join(...tokens) {
468
461
  if (!tokens.length) {
469
462
  return this;
470
463
  }
@@ -513,7 +506,7 @@ class JSONPointer {
513
506
  }
514
507
  }
515
508
  const RE_RELATIVE_POINTER = /(?<ORIGIN>\d+)(?<INDEX_G>(?<SIGN>[+-])(?<INDEX>\d))?(?<POINTER>.*)/s;
516
- const RE_INT = /(0|[1-9][0-9]*)/;
509
+ const RE_INT = /(0|[1-9]\d*)/;
517
510
 
518
511
  /**
519
512
  * A relative JSON Pointer.
@@ -632,8 +625,7 @@ class RelativeJSONPointer {
632
625
  * @throws {@link JSONPointerSyntaxError}
633
626
  * If _pointer_ is malformed according to RFC 6901.
634
627
  */
635
- function resolve(pointer, value) {
636
- let fallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : UNDEFINED;
628
+ function resolve(pointer, value, fallback = UNDEFINED) {
637
629
  return new JSONPointer(pointer).resolve(value, fallback);
638
630
  }
639
631
 
@@ -737,10 +729,7 @@ class JSONPathNode {
737
729
  ...defaultSerializationOptions,
738
730
  ...options
739
731
  };
740
- return (
741
- // eslint-disable-next-line prefer-template
742
- "$" + this.location.map(s => isString(s) ? this.decodeNameLocation(s, opts) : `[${s}]`).join("")
743
- );
732
+ return "$" + this.location.map(s => isString(s) ? this.decodeNameLocation(s, opts) : `[${s}]`).join("");
744
733
  }
745
734
 
746
735
  /**
@@ -1135,16 +1124,16 @@ var expression = /*#__PURE__*/Object.freeze({
1135
1124
  });
1136
1125
 
1137
1126
  class Count {
1138
- argTypes = (() => [FunctionExpressionType.NodesType])();
1139
- returnType = (() => FunctionExpressionType.ValueType)();
1127
+ argTypes = [FunctionExpressionType.NodesType];
1128
+ returnType = FunctionExpressionType.ValueType;
1140
1129
  call(nodes) {
1141
1130
  return nodes.length;
1142
1131
  }
1143
1132
  }
1144
1133
 
1145
1134
  class Length {
1146
- argTypes = (() => [FunctionExpressionType.ValueType])();
1147
- returnType = (() => FunctionExpressionType.ValueType)();
1135
+ argTypes = [FunctionExpressionType.ValueType];
1136
+ returnType = FunctionExpressionType.ValueType;
1148
1137
  call(value) {
1149
1138
  if (isArray(value) || isString(value)) return value.length;
1150
1139
  if (isObject(value)) return Object.keys(value).length;
@@ -1156,9 +1145,7 @@ class Length {
1156
1145
  * A Least Recently Used cache, implemented as an extended Map.
1157
1146
  */
1158
1147
  class LRUCache extends Map {
1159
- constructor() {
1160
- let maxSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 128;
1161
- let entries = arguments.length > 1 ? arguments[1] : undefined;
1148
+ constructor(maxSize = 128, entries) {
1162
1149
  if (entries !== undefined) {
1163
1150
  super(entries);
1164
1151
  } else {
@@ -2476,11 +2463,10 @@ var check_1 = {
2476
2463
  var check$1 = check_1.check;
2477
2464
 
2478
2465
  class Match {
2479
- argTypes = (() => [FunctionExpressionType.ValueType, FunctionExpressionType.ValueType])();
2480
- returnType = (() => FunctionExpressionType.LogicalType)();
2466
+ argTypes = [FunctionExpressionType.ValueType, FunctionExpressionType.ValueType];
2467
+ returnType = FunctionExpressionType.LogicalType;
2481
2468
  #cache;
2482
- constructor() {
2483
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2469
+ constructor(options = {}) {
2484
2470
  this.options = options;
2485
2471
  this.cacheSize = options.cacheSize ?? 10;
2486
2472
  this.throwErrors = options.throwErrors ?? false;
@@ -2525,11 +2511,10 @@ class Match {
2525
2511
  }
2526
2512
 
2527
2513
  class Search {
2528
- argTypes = (() => [FunctionExpressionType.ValueType, FunctionExpressionType.ValueType])();
2529
- returnType = (() => FunctionExpressionType.LogicalType)();
2514
+ argTypes = [FunctionExpressionType.ValueType, FunctionExpressionType.ValueType];
2515
+ returnType = FunctionExpressionType.LogicalType;
2530
2516
  #cache;
2531
- constructor() {
2532
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2517
+ constructor(options = {}) {
2533
2518
  this.options = options;
2534
2519
  this.cacheSize = options.cacheSize ?? 10;
2535
2520
  this.throwErrors = options.throwErrors ?? false;
@@ -2574,8 +2559,8 @@ class Search {
2574
2559
  }
2575
2560
 
2576
2561
  class Value {
2577
- argTypes = (() => [FunctionExpressionType.NodesType])();
2578
- returnType = (() => FunctionExpressionType.ValueType)();
2562
+ argTypes = [FunctionExpressionType.NodesType];
2563
+ returnType = FunctionExpressionType.ValueType;
2579
2564
  call(nodes) {
2580
2565
  if (nodes.length === 1) return nodes.nodes[0].value;
2581
2566
  return Nothing;
@@ -2591,6 +2576,7 @@ let TokenKind = /*#__PURE__*/function (TokenKind) {
2591
2576
  TokenKind["COMMA"] = "TOKEN_COMMA";
2592
2577
  TokenKind["CURRENT"] = "TOKEN_CURRENT_VALUE";
2593
2578
  TokenKind["CURRENT_KEY"] = "TOKEN_CURRENT_KEY";
2579
+ // non-standard, default `#`
2594
2580
  TokenKind["DDOT"] = "TOKEN_DDOT";
2595
2581
  TokenKind["DOT"] = "TOKEN_DOT";
2596
2582
  TokenKind["DOUBLE_QUOTE_STRING"] = "TOKEN_DOUBLE_QUOTE_STRING";
@@ -2604,10 +2590,15 @@ let TokenKind = /*#__PURE__*/function (TokenKind) {
2604
2590
  TokenKind["GT"] = "TOKEN_GT";
2605
2591
  TokenKind["INDEX"] = "TOKEN_INDEX";
2606
2592
  TokenKind["KEY"] = "TOKEN_KEY";
2593
+ // non-standard, default `~<name>`
2607
2594
  TokenKind["KEY_DOUBLE_QUOTE_STRING"] = "TOKEN_KEY_DOUBLE_QUOTE_STRING";
2595
+ // non-standard, `~"<name>"`
2608
2596
  TokenKind["KEY_SINGLE_QUOTE_STRING"] = "TOKEN_KEY_SINGLE_QUOTE_STRING";
2597
+ // non-standard, `~'<name>'`
2609
2598
  TokenKind["KEYS"] = "TOKEN_KEYS";
2599
+ // non-standard, default `~`
2610
2600
  TokenKind["KEYS_FILTER"] = "TOKEN_KEYS_FILTER";
2601
+ // non-standard, `~?<expression>`
2611
2602
  TokenKind["LBRACKET"] = "TOKEN_LBRACKET";
2612
2603
  TokenKind["LE"] = "TOKEN_LE";
2613
2604
  TokenKind["LG"] = "TOKEN_LG";
@@ -2691,7 +2682,7 @@ class TokenStream {
2691
2682
  const exponentPattern = /[eE][+-]?\d+/y;
2692
2683
  const functionNamePattern = /[a-z][a-z_0-9]*/y;
2693
2684
  const indexPattern = /-?\d+/y;
2694
- const intPattern = /-?[0-9]+/y;
2685
+ const intPattern = /-?\d+/y;
2695
2686
  const namePattern = /[\u0080-\uFFFFa-zA-Z_][\u0080-\uFFFFa-zA-Z0-9_-]*/y;
2696
2687
  const whitespace = new Set([" ", "\n", "\t", "\r"]);
2697
2688
  const nameFirstPattern = /[\u0080-\uFFFFa-zA-Z_]/; // don't set sticky bit
@@ -2716,7 +2707,13 @@ class Lexer {
2716
2707
  * If the stack is empty, we are not in a function call. Remember that
2717
2708
  * function arguments can use arbitrarily nested in parentheses.
2718
2709
  */
2719
- parenStack = [];
2710
+ funcCallStack = [];
2711
+
2712
+ /**
2713
+ * A stack of parentheses and square brackets used to check for balanced
2714
+ * brackets.
2715
+ */
2716
+ bracketStack = [];
2720
2717
 
2721
2718
  /** Tokens resulting from tokenizing a JSONPath query. */
2722
2719
  tokens = [];
@@ -2845,9 +2842,19 @@ function lex(environment, path) {
2845
2842
  function tokenize(environment, path) {
2846
2843
  const [lexer, tokens] = lex(environment, path);
2847
2844
  lexer.run();
2845
+
2846
+ // If there's an error, it will be the last token with kind set to ERROR.
2848
2847
  if (tokens.length && tokens[tokens.length - 1].kind === TokenKind.ERROR) {
2849
2848
  throw new JSONPathSyntaxError(tokens[tokens.length - 1].value, tokens[tokens.length - 1]);
2850
2849
  }
2850
+
2851
+ // If the bracket stack is not empty, we hav unbalanced brackets.
2852
+ // This might not be reachable.
2853
+ if (lexer.bracketStack.length !== 0) {
2854
+ const [ch, index] = lexer.bracketStack[lexer.bracketStack.length - 1];
2855
+ const msg = "unbalanced brackets";
2856
+ throw new JSONPathSyntaxError(msg, new Token(TokenKind.ERROR, ch, index, path));
2857
+ }
2851
2858
  return tokens;
2852
2859
  }
2853
2860
  function lexRoot(l) {
@@ -2877,6 +2884,7 @@ function lexSegment(l) {
2877
2884
  }
2878
2885
  return lexDotSelector;
2879
2886
  case "[":
2887
+ l.bracketStack.push(["[", l.start]);
2880
2888
  l.emit(TokenKind.LBRACKET);
2881
2889
  return lexInsideBracketedSelection;
2882
2890
  default:
@@ -2933,6 +2941,7 @@ function lexDescendantSelection(l) {
2933
2941
  l.emit(TokenKind.WILD);
2934
2942
  return lexSegment;
2935
2943
  case "[":
2944
+ l.bracketStack.push(["[", l.start]);
2936
2945
  l.emit(TokenKind.LBRACKET);
2937
2946
  return lexInsideBracketedSelection;
2938
2947
  default:
@@ -2991,7 +3000,6 @@ function lexInsideBracketedSelection(l) {
2991
3000
  continue;
2992
3001
  }
2993
3002
  if (!l.environment.strict && l.acceptMatchRun(l.environment.keysPattern)) {
2994
- // FIXME: fall back to legacy behavior if keysPattern is not the default
2995
3003
  switch (l.peek()) {
2996
3004
  case "'":
2997
3005
  l.ignore(); // ~
@@ -3014,6 +3022,12 @@ function lexInsideBracketedSelection(l) {
3014
3022
  const ch = l.next();
3015
3023
  switch (ch) {
3016
3024
  case "]":
3025
+ if (l.bracketStack.length === 0 || l.bracketStack[l.bracketStack.length - 1][0] !== "[") {
3026
+ l.backup();
3027
+ l.error("unbalanced brackets");
3028
+ return null;
3029
+ }
3030
+ l.bracketStack.pop();
3017
3031
  l.emit(TokenKind.RBRACKET);
3018
3032
  return lexSegment;
3019
3033
  case "":
@@ -3055,17 +3069,13 @@ function lexInsideFilter(l) {
3055
3069
  return null;
3056
3070
  case "]":
3057
3071
  l.filterLevel -= 1;
3058
- if (l.parenStack.length === 1) {
3059
- l.error("unbalanced parentheses");
3060
- return null;
3061
- }
3062
3072
  l.backup();
3063
3073
  return lexInsideBracketedSelection;
3064
3074
  case ",":
3065
3075
  l.emit(TokenKind.COMMA);
3066
3076
  // If we have unbalanced parens, we are inside a function call and a
3067
3077
  // comma separates arguments. Otherwise a comma separates selectors.
3068
- if (l.parenStack.length) continue;
3078
+ if (l.funcCallStack.length) continue;
3069
3079
  l.filterLevel -= 1;
3070
3080
  return lexInsideBracketedSelection;
3071
3081
  case "'":
@@ -3073,18 +3083,25 @@ function lexInsideFilter(l) {
3073
3083
  case '"':
3074
3084
  return lexDoubleQuoteStringInsideFilterExpression;
3075
3085
  case "(":
3086
+ l.bracketStack.push(["(", l.start]);
3076
3087
  l.emit(TokenKind.LPAREN);
3077
3088
  // Are we in a function call? If so, a function argument contains parens.
3078
- if (l.parenStack.length) l.parenStack[l.parenStack.length - 1] += 1;
3089
+ if (l.funcCallStack.length) l.funcCallStack[l.funcCallStack.length - 1] += 1;
3079
3090
  continue;
3080
3091
  case ")":
3092
+ if (l.bracketStack.length === 0 || l.bracketStack[l.bracketStack.length - 1][0] !== "(") {
3093
+ l.backup();
3094
+ l.error("unbalanced brackets");
3095
+ return null;
3096
+ }
3097
+ l.bracketStack.pop();
3081
3098
  l.emit(TokenKind.RPAREN);
3082
3099
  // Are we closing a function call or a parenthesized expression?
3083
- if (l.parenStack.length) {
3084
- if (l.parenStack[l.parenStack.length - 1] === 1) {
3085
- l.parenStack.pop();
3100
+ if (l.funcCallStack.length) {
3101
+ if (l.funcCallStack[l.funcCallStack.length - 1] === 1) {
3102
+ l.funcCallStack.pop();
3086
3103
  } else {
3087
- l.parenStack[l.parenStack.length - 1] -= 1;
3104
+ l.funcCallStack[l.funcCallStack.length - 1] -= 1;
3088
3105
  }
3089
3106
  }
3090
3107
  continue;
@@ -3181,8 +3198,9 @@ function lexInsideFilter(l) {
3181
3198
  // functions
3182
3199
  if (l.acceptMatchRun(functionNamePattern) && l.peek() === "(") {
3183
3200
  // Keep track of parentheses for this function call.
3184
- l.parenStack.push(1);
3201
+ l.funcCallStack.push(1);
3185
3202
  l.emit(TokenKind.FUNCTION);
3203
+ l.bracketStack.push(["(", l.start]);
3186
3204
  l.next();
3187
3205
  l.ignore();
3188
3206
  continue;
@@ -3373,10 +3391,7 @@ class SliceSelector extends JSONPathSelector {
3373
3391
  const step = this.step ? this.step : "1";
3374
3392
  return `${start}:${stop}:${step}`;
3375
3393
  }
3376
- checkRange() {
3377
- for (var _len = arguments.length, indices = new Array(_len), _key = 0; _key < _len; _key++) {
3378
- indices[_key] = arguments[_key];
3379
- }
3394
+ checkRange(...indices) {
3380
3395
  for (const index of indices) {
3381
3396
  if (index !== undefined && (index < this.environment.minIntIndex || index > this.environment.maxIntIndex)) {
3382
3397
  throw new JSONPathIndexError("index out of range", this.token);
@@ -3663,53 +3678,45 @@ class DescendantSegment extends JSONPathSegment {
3663
3678
  toString(options) {
3664
3679
  return `..[${this.selectors.map(s => s.toString(options)).join(", ")}]`;
3665
3680
  }
3666
- visit(node) {
3667
- var _this = this;
3668
- let depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
3669
- return function* () {
3670
- if (depth >= _this.environment.maxRecursionDepth) {
3671
- throw new JSONPathRecursionLimitError("recursion limit reached", _this.token);
3681
+ *visit(node, depth = 1) {
3682
+ if (depth >= this.environment.maxRecursionDepth) {
3683
+ throw new JSONPathRecursionLimitError("recursion limit reached", this.token);
3684
+ }
3685
+ yield node;
3686
+ if (isArray(node.value)) {
3687
+ for (let i = 0; i < node.value.length; i++) {
3688
+ const _node = new JSONPathNode(node.value[i], node.location.concat(i), node.root);
3689
+ yield* this.visit(_node, depth + 1);
3690
+ }
3691
+ } else if (isObject(node.value)) {
3692
+ for (const [key, value] of this.environment.entries(node.value)) {
3693
+ const _node = new JSONPathNode(value, node.location.concat(key), node.root);
3694
+ yield* this.visit(_node, depth + 1);
3672
3695
  }
3696
+ }
3697
+ }
3698
+ *nondeterministicVisit(root, depth = 1) {
3699
+ let queue = Array.from(this.nondeterministicChildren(root)).map(node => [node, depth]);
3700
+ yield root;
3701
+ while (queue.length) {
3702
+ const [node, _depth] = queue.shift();
3673
3703
  yield node;
3674
- if (isArray(node.value)) {
3675
- for (let i = 0; i < node.value.length; i++) {
3676
- const _node = new JSONPathNode(node.value[i], node.location.concat(i), node.root);
3677
- yield* _this.visit(_node, depth + 1);
3678
- }
3679
- } else if (isObject(node.value)) {
3680
- for (const [key, value] of _this.environment.entries(node.value)) {
3681
- const _node = new JSONPathNode(value, node.location.concat(key), node.root);
3682
- yield* _this.visit(_node, depth + 1);
3683
- }
3704
+ if (_depth >= this.environment.maxRecursionDepth) {
3705
+ throw new JSONPathRecursionLimitError("recursion limit reached", this.token);
3684
3706
  }
3685
- }();
3686
- }
3687
- nondeterministicVisit(root) {
3688
- var _this2 = this;
3689
- let depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
3690
- return function* () {
3691
- let queue = Array.from(_this2.nondeterministicChildren(root)).map(node => [node, depth]);
3692
- yield root;
3693
- while (queue.length) {
3694
- const [node, _depth] = queue.shift();
3695
- yield node;
3696
- if (_depth >= _this2.environment.maxRecursionDepth) {
3697
- throw new JSONPathRecursionLimitError("recursion limit reached", _this2.token);
3698
- }
3699
3707
 
3700
- // Visit child nodes now or queue them for later?
3701
- const visitChildren = Math.random() < 0.5;
3702
- for (const child of _this2.nondeterministicChildren(node)) {
3703
- if (visitChildren) {
3704
- yield child;
3705
- const grandchildren = Array.from(_this2.nondeterministicChildren(child)).map(n => [n, _depth + 2]);
3706
- queue = interleave(queue, grandchildren);
3707
- } else {
3708
- queue.push([child, _depth + 1]);
3709
- }
3708
+ // Visit child nodes now or queue them for later?
3709
+ const visitChildren = Math.random() < 0.5;
3710
+ for (const child of this.nondeterministicChildren(node)) {
3711
+ if (visitChildren) {
3712
+ yield child;
3713
+ const grandchildren = Array.from(this.nondeterministicChildren(child)).map(n => [n, _depth + 2]);
3714
+ queue = interleave(queue, grandchildren);
3715
+ } else {
3716
+ queue.push([child, _depth + 1]);
3710
3717
  }
3711
3718
  }
3712
- }();
3719
+ }
3713
3720
  }
3714
3721
  *nondeterministicChildren(node) {
3715
3722
  if (isString(node.value)) return;
@@ -3975,8 +3982,7 @@ class Parser {
3975
3982
  }
3976
3983
  return segments;
3977
3984
  }
3978
- parseQuery(stream) {
3979
- let inFilter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
3985
+ parseQuery(stream, inFilter = false) {
3980
3986
  const segments = [];
3981
3987
  loop: for (;;) {
3982
3988
  switch (stream.current.kind) {
@@ -4128,8 +4134,7 @@ class Parser {
4128
4134
  }
4129
4135
  return selectors;
4130
4136
  }
4131
- parseFilter(stream) {
4132
- let keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
4137
+ parseFilter(stream, keys = false) {
4133
4138
  const tok = stream.next();
4134
4139
  const expr = this.parseFilterExpression(stream);
4135
4140
  if (expr instanceof FunctionExtension) {
@@ -4243,8 +4248,7 @@ class Parser {
4243
4248
  stream.expect(TokenKind.RPAREN);
4244
4249
  return new FunctionExtension(tok, tok.value, this.environment.checkWellTypedness(tok, args));
4245
4250
  }
4246
- parseFilterExpression(stream) {
4247
- let precedence = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : PRECEDENCE_LOWEST;
4251
+ parseFilterExpression(stream, precedence = PRECEDENCE_LOWEST) {
4248
4252
  const func = this.tokenMap.get(stream.current.kind);
4249
4253
  if (!func) {
4250
4254
  let msg;
@@ -4314,7 +4318,6 @@ class Parser {
4314
4318
  rv.push(this.stringFromCodePoint(codepoint, token));
4315
4319
  break;
4316
4320
  default:
4317
- // TODO: This is unreachable. The lexer will catch unknown escape sequences.
4318
4321
  throw new JSONPathSyntaxError(`unknown escape sequence at index ${token.index + index - 1}`, token);
4319
4322
  }
4320
4323
  } else {
@@ -4494,12 +4497,11 @@ class JSONPathEnvironment {
4494
4497
  * A map of function names to objects implementing the {@link FilterFunction}
4495
4498
  * interface. You are free to set or delete custom filter functions directly.
4496
4499
  */
4497
- functionRegister = (() => new Map())();
4500
+ functionRegister = new Map();
4498
4501
  /**
4499
4502
  * @param options - Environment configuration options.
4500
4503
  */
4501
- constructor() {
4502
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4504
+ constructor(options = {}) {
4503
4505
  this.strict = options.strict ?? true;
4504
4506
  this.maxIntIndex = options.maxIntIndex ?? Math.pow(2, 53) - 1;
4505
4507
  this.minIntIndex = options.maxIntIndex ?? -Math.pow(2, 53) + 1;
@@ -4644,11 +4646,10 @@ class JSONPathEnvironment {
4644
4646
  * value and it contains a property matching the second argument.
4645
4647
  */
4646
4648
  class Has {
4647
- argTypes = (() => [FunctionExpressionType.ValueType, FunctionExpressionType.ValueType])();
4648
- returnType = (() => FunctionExpressionType.LogicalType)();
4649
+ argTypes = [FunctionExpressionType.ValueType, FunctionExpressionType.ValueType];
4650
+ returnType = FunctionExpressionType.LogicalType;
4649
4651
  #cache;
4650
- constructor() {
4651
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4652
+ constructor(options = {}) {
4652
4653
  this.options = options;
4653
4654
  this.cacheSize = options.cacheSize ?? 10;
4654
4655
  this.throwErrors = options.throwErrors ?? false;
@@ -5297,6 +5298,6 @@ var index = /*#__PURE__*/Object.freeze({
5297
5298
  apply: apply
5298
5299
  });
5299
5300
 
5300
- const version = "2.2.1";
5301
+ const version = "2.3.0";
5301
5302
 
5302
5303
  export { DEFAULT_ENVIRONMENT, FunctionExpressionType, JSONPatch, JSONPatchError, JSONPatchTestFailure, JSONPathEnvironment, JSONPathError, JSONPathIndexError, JSONPathLexerError, JSONPathNode, JSONPathNodeList, JSONPathQuery, JSONPathRecursionLimitError, JSONPathSyntaxError, JSONPathTypeError, JSONPointer, Nothing, RelativeJSONPointer, Token, TokenKind, UNDEFINED, apply, compile, index as jsonpatch, index$1 as jsonpath, index$3 as jsonpointer, lazyQuery, query, resolve, version };