json-p3 0.2.1 → 0.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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- * json-p3 version 0.2.0
2
+ * json-p3 version 0.3.0
3
3
  * https://github.com/jg-rp/json-p3
4
4
  *
5
5
  * MIT License
@@ -646,10 +646,6 @@ var json_p3 = (function (exports) {
646
646
  * The pair of a JSON value and its location found in the target JSON value.
647
647
  */
648
648
  class JSONPathNode {
649
- /**
650
- * The normalized path to this node in the target JSON value.
651
- */
652
-
653
649
  /**
654
650
  * @param value - The JSON value found at _location_.
655
651
  * @param location - The parts of a normalized path to _value_.
@@ -659,9 +655,12 @@ var json_p3 = (function (exports) {
659
655
  this.value = value;
660
656
  this.location = location;
661
657
  this.root = root;
662
- this.path =
663
- // eslint-disable-next-line prefer-template
664
- "$" + location.map(s => isString(s) ? `['${s}']` : `[${s}]`).join("");
658
+ }
659
+ get path() {
660
+ return (
661
+ // eslint-disable-next-line prefer-template
662
+ "$" + this.location.map(s => isString(s) ? `['${s}']` : `[${s}]`).join("")
663
+ );
665
664
  }
666
665
 
667
666
  /**
@@ -913,7 +912,7 @@ var json_p3 = (function (exports) {
913
912
  }
914
913
  class RelativeQuery extends JSONPathQuery {
915
914
  evaluate(context) {
916
- return this.path.query(context.currentValue);
915
+ return context.lazy ? new JSONPathNodeList(Array.from(this.path.lazyQuery(context.currentValue))) : this.path.query(context.currentValue);
917
916
  }
918
917
  toString() {
919
918
  return `@${this.path.toString().slice(1)}`;
@@ -921,7 +920,7 @@ var json_p3 = (function (exports) {
921
920
  }
922
921
  class RootQuery extends JSONPathQuery {
923
922
  evaluate(context) {
924
- return this.path.query(context.rootValue);
923
+ return context.lazy ? new JSONPathNodeList(Array.from(this.path.lazyQuery(context.rootValue))) : this.path.query(context.rootValue);
925
924
  }
926
925
  toString() {
927
926
  return this.path.toString();
@@ -1723,6 +1722,10 @@ var json_p3 = (function (exports) {
1723
1722
  this.token = token;
1724
1723
  }
1725
1724
 
1725
+ /**
1726
+ * @param nodes - Nodes matched by preceding selectors.
1727
+ */
1728
+
1726
1729
  /**
1727
1730
  * @param nodes - Nodes matched by preceding selectors.
1728
1731
  */
@@ -1750,7 +1753,14 @@ var json_p3 = (function (exports) {
1750
1753
  rv.push(new JSONPathNode(node.value[this.name], node.location.concat(this.name), node.root));
1751
1754
  }
1752
1755
  }
1753
- return new JSONPathNodeList(rv);
1756
+ return rv;
1757
+ }
1758
+ *lazyResolve(nodes) {
1759
+ for (const node of nodes) {
1760
+ if (hasStringKey(node.value, this.name)) {
1761
+ yield new JSONPathNode(node.value[this.name], node.location.concat(this.name), node.root);
1762
+ }
1763
+ }
1754
1764
  }
1755
1765
  toString() {
1756
1766
  return this.shorthand ? `['${this.name}']` : `'${this.name}'`;
@@ -1780,7 +1790,17 @@ var json_p3 = (function (exports) {
1780
1790
  }
1781
1791
  }
1782
1792
  }
1783
- return new JSONPathNodeList(rv);
1793
+ return rv;
1794
+ }
1795
+ *lazyResolve(nodes) {
1796
+ for (const node of nodes) {
1797
+ if (isArray(node.value)) {
1798
+ const normIndex = this.normalizedIndex(node.value.length);
1799
+ if (normIndex in node.value) {
1800
+ yield new JSONPathNode(node.value[normIndex], node.location.concat(normIndex), node.root);
1801
+ }
1802
+ }
1803
+ }
1784
1804
  }
1785
1805
  toString() {
1786
1806
  return String(this.index);
@@ -1808,7 +1828,15 @@ var json_p3 = (function (exports) {
1808
1828
  rv.push(new JSONPathNode(value, node.location.concat(i), node.root));
1809
1829
  }
1810
1830
  }
1811
- return new JSONPathNodeList(rv);
1831
+ return rv;
1832
+ }
1833
+ *lazyResolve(nodes) {
1834
+ for (const node of nodes) {
1835
+ if (!isArray(node.value)) continue;
1836
+ for (const [i, value] of this.slice(node.value, this.start, this.stop, this.step)) {
1837
+ yield new JSONPathNode(value, node.location.concat(i), node.root);
1838
+ }
1839
+ }
1812
1840
  }
1813
1841
  toString() {
1814
1842
  const start = this.start ? this.start : "";
@@ -1891,22 +1919,92 @@ var json_p3 = (function (exports) {
1891
1919
  }
1892
1920
  }
1893
1921
  }
1894
- return new JSONPathNodeList(rv);
1922
+ return rv;
1923
+ }
1924
+ *lazyResolve(nodes) {
1925
+ for (const node of nodes) {
1926
+ if (node.value instanceof String) continue;
1927
+ if (isArray(node.value)) {
1928
+ for (let i = 0; i < node.value.length; i++) {
1929
+ yield new JSONPathNode(node.value[i], node.location.concat(i), node.root);
1930
+ }
1931
+ } else if (isObject(node.value)) {
1932
+ for (const [key, value] of Object.entries(node.value)) {
1933
+ yield new JSONPathNode(value, node.location.concat(key), node.root);
1934
+ }
1935
+ }
1936
+ }
1895
1937
  }
1896
1938
  toString() {
1897
1939
  return this.shorthand ? "[*]" : "*";
1898
1940
  }
1899
1941
  }
1900
1942
  class RecursiveDescentSegment extends JSONPathSelector {
1943
+ constructor(environment, token, selector) {
1944
+ super(environment, token);
1945
+ this.environment = environment;
1946
+ this.token = token;
1947
+ this.selector = selector;
1948
+ }
1901
1949
  resolve(nodes) {
1902
1950
  const rv = [];
1903
1951
  for (const node of nodes) {
1904
- rv.push(node, ...this.visit(node));
1952
+ rv.push(node);
1953
+ for (const _node of this.visit(node)) {
1954
+ rv.push(_node);
1955
+ }
1956
+ }
1957
+ return this.selector.resolve(rv);
1958
+ }
1959
+ *lazyResolve(nodes) {
1960
+ yield* this.selector.lazyResolve(this._lazyResolve(nodes));
1961
+ }
1962
+
1963
+ // eslint-disable-next-line sonarjs/cognitive-complexity
1964
+ *_lazyResolve(nodes) {
1965
+ for (const _node of nodes) {
1966
+ const stack = [{
1967
+ node: _node,
1968
+ depth: 0
1969
+ }];
1970
+ yield _node;
1971
+ while (stack.length) {
1972
+ const {
1973
+ node: currentNode,
1974
+ depth
1975
+ } = stack.pop();
1976
+ if (depth >= this.environment.maxRecursionDepth) {
1977
+ throw new JSONPathRecursionLimitError("recursion limit reached", this.token);
1978
+ }
1979
+ if (currentNode.value instanceof String) continue;
1980
+ if (isArray(currentNode.value)) {
1981
+ for (let i = 0; i < currentNode.value.length; i++) {
1982
+ const __node = new JSONPathNode(currentNode.value[i], currentNode.location.concat(i), currentNode.root);
1983
+ yield __node;
1984
+ if (isObject(__node.value)) {
1985
+ stack.push({
1986
+ node: __node,
1987
+ depth: depth + 1
1988
+ });
1989
+ }
1990
+ }
1991
+ } else if (isObject(currentNode.value)) {
1992
+ for (const [key, value] of Object.entries(currentNode.value)) {
1993
+ const __node = new JSONPathNode(value, currentNode.location.concat(key), currentNode.root);
1994
+ yield __node;
1995
+ if (isObject(__node.value)) {
1996
+ stack.push({
1997
+ node: __node,
1998
+ depth: depth + 1
1999
+ });
2000
+ }
2001
+ }
2002
+ }
2003
+ }
1905
2004
  }
1906
- return new JSONPathNodeList(rv);
1907
2005
  }
1908
2006
  toString() {
1909
- return "..";
2007
+ return `..${this.selector.toString()}`;
1910
2008
  }
1911
2009
  visit(node) {
1912
2010
  let depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
@@ -1914,19 +2012,25 @@ var json_p3 = (function (exports) {
1914
2012
  throw new JSONPathRecursionLimitError("recursion limit reached", this.token);
1915
2013
  }
1916
2014
  const rv = [];
1917
- if (node.value instanceof String) return new JSONPathNodeList(rv);
2015
+ if (node.value instanceof String) return rv;
1918
2016
  if (isArray(node.value)) {
1919
2017
  for (let i = 0; i < node.value.length; i++) {
1920
2018
  const _node = new JSONPathNode(node.value[i], node.location.concat(i), node.root);
1921
- rv.push(_node, ...this.visit(_node, depth + 1));
2019
+ rv.push(_node);
2020
+ for (const __node of this.visit(_node, depth + 1)) {
2021
+ rv.push(__node);
2022
+ }
1922
2023
  }
1923
2024
  } else if (isObject(node.value)) {
1924
2025
  for (const [key, value] of Object.entries(node.value)) {
1925
2026
  const _node = new JSONPathNode(value, node.location.concat(key), node.root);
1926
- rv.push(_node, ...this.visit(_node, depth + 1));
2027
+ rv.push(_node);
2028
+ for (const __node of this.visit(_node, depth + 1)) {
2029
+ rv.push(__node);
2030
+ }
1927
2031
  }
1928
2032
  }
1929
- return new JSONPathNodeList(rv);
2033
+ return rv;
1930
2034
  }
1931
2035
  }
1932
2036
  class FilterSelector extends JSONPathSelector {
@@ -1967,7 +2071,40 @@ var json_p3 = (function (exports) {
1967
2071
  }
1968
2072
  }
1969
2073
  }
1970
- return new JSONPathNodeList(rv);
2074
+ return rv;
2075
+ }
2076
+
2077
+ // eslint-disable-next-line sonarjs/cognitive-complexity
2078
+ *lazyResolve(nodes) {
2079
+ for (const node of nodes) {
2080
+ if (node.value instanceof String) continue;
2081
+ if (isArray(node.value)) {
2082
+ for (let i = 0; i < node.value.length; i++) {
2083
+ const value = node.value[i];
2084
+ const filterContext = {
2085
+ environment: this.environment,
2086
+ currentValue: value,
2087
+ rootValue: node.root,
2088
+ lazy: true
2089
+ };
2090
+ if (this.expression.evaluate(filterContext)) {
2091
+ yield new JSONPathNode(value, node.location.concat(i), node.root);
2092
+ }
2093
+ }
2094
+ } else if (isObject(node.value)) {
2095
+ for (const [key, value] of Object.entries(node.value)) {
2096
+ const filterContext = {
2097
+ environment: this.environment,
2098
+ currentValue: value,
2099
+ rootValue: node.root,
2100
+ lazy: true
2101
+ };
2102
+ if (this.expression.evaluate(filterContext)) {
2103
+ yield new JSONPathNode(value, node.location.concat(key), node.root);
2104
+ }
2105
+ }
2106
+ }
2107
+ }
1971
2108
  }
1972
2109
  toString() {
1973
2110
  return `?${this.expression.toString()}`;
@@ -1984,10 +2121,19 @@ var json_p3 = (function (exports) {
1984
2121
  const rv = [];
1985
2122
  for (const node of nodes) {
1986
2123
  for (const item of this.items) {
1987
- rv.push(...item.resolve(new JSONPathNodeList([node])));
2124
+ for (const _node of item.resolve([node])) {
2125
+ rv.push(_node);
2126
+ }
2127
+ }
2128
+ }
2129
+ return rv;
2130
+ }
2131
+ *lazyResolve(nodes) {
2132
+ for (const node of nodes) {
2133
+ for (const item of this.items) {
2134
+ yield* item.lazyResolve([node]);
1988
2135
  }
1989
2136
  }
1990
- return new JSONPathNodeList(rv);
1991
2137
  }
1992
2138
  toString() {
1993
2139
  return `[${this.items.map(itm => itm.toString()).join(", ")}]`;
@@ -2026,10 +2172,23 @@ var json_p3 = (function (exports) {
2026
2172
  * @returns
2027
2173
  */
2028
2174
  query(value) {
2029
- let nodes = new JSONPathNodeList([new JSONPathNode(value, [], value)]);
2175
+ let nodes = [new JSONPathNode(value, [], value)];
2030
2176
  for (const selector of this.selectors) {
2031
2177
  nodes = selector.resolve(nodes);
2032
2178
  }
2179
+ return new JSONPathNodeList(nodes);
2180
+ }
2181
+
2182
+ /**
2183
+ *
2184
+ * @param value -
2185
+ * @returns
2186
+ */
2187
+ lazyQuery(value) {
2188
+ let nodes = [new JSONPathNode(value, [], value)][Symbol.iterator]();
2189
+ for (const selector of this.selectors) {
2190
+ nodes = selector.lazyResolve(nodes);
2191
+ }
2033
2192
  return nodes;
2034
2193
  }
2035
2194
 
@@ -2042,7 +2201,10 @@ var json_p3 = (function (exports) {
2042
2201
  * there are no matches.
2043
2202
  */
2044
2203
  match(value) {
2045
- return this.query(value).nodes.at(0);
2204
+ const it = this.lazyQuery(value);
2205
+ const rv = it.next();
2206
+ if (rv.done) return undefined;
2207
+ return rv.value;
2046
2208
  }
2047
2209
 
2048
2210
  /**
@@ -2062,13 +2224,17 @@ var json_p3 = (function (exports) {
2062
2224
  }
2063
2225
 
2064
2226
  const PRECEDENCE_LOWEST = 1;
2065
- const PRECEDENCE_LOGICALRIGHT = 3;
2066
2227
  const PRECEDENCE_LOGICAL_AND = 4;
2067
2228
  const PRECEDENCE_LOGICAL_OR = 5;
2068
2229
  const PRECEDENCE_COMPARISON = 6;
2069
- const PRECEDENCES = new Map([[TokenKind.AND, PRECEDENCE_LOGICAL_AND], [TokenKind.EQ, PRECEDENCE_COMPARISON], [TokenKind.GE, PRECEDENCE_COMPARISON], [TokenKind.GT, PRECEDENCE_COMPARISON], [TokenKind.LE, PRECEDENCE_COMPARISON], [TokenKind.LT, PRECEDENCE_COMPARISON], [TokenKind.NE, PRECEDENCE_COMPARISON], [TokenKind.NOT, PRECEDENCE_LOGICALRIGHT], [TokenKind.OR, PRECEDENCE_LOGICAL_OR], [TokenKind.RPAREN, PRECEDENCE_LOWEST]]);
2230
+ const PRECEDENCE_PREFIX = 7;
2231
+ const PRECEDENCES = new Map([[TokenKind.AND, PRECEDENCE_LOGICAL_AND], [TokenKind.EQ, PRECEDENCE_COMPARISON], [TokenKind.GE, PRECEDENCE_COMPARISON], [TokenKind.GT, PRECEDENCE_COMPARISON], [TokenKind.LE, PRECEDENCE_COMPARISON], [TokenKind.LT, PRECEDENCE_COMPARISON], [TokenKind.NE, PRECEDENCE_COMPARISON], [TokenKind.NOT, PRECEDENCE_PREFIX], [TokenKind.OR, PRECEDENCE_LOGICAL_OR], [TokenKind.RPAREN, PRECEDENCE_LOWEST]]);
2070
2232
  const BINARY_OPERATORS = new Map([[TokenKind.AND, "&&"], [TokenKind.EQ, "=="], [TokenKind.GE, ">="], [TokenKind.GT, ">"], [TokenKind.LE, "<="], [TokenKind.LT, "<"], [TokenKind.NE, "!="], [TokenKind.OR, "||"]]);
2071
2233
  const COMPARISON_OPERATORS = new Set(["==", ">=", ">", "<=", "<", "!="]);
2234
+
2235
+ /**
2236
+ * JSONPath token stream parser.
2237
+ */
2072
2238
  class Parser {
2073
2239
  constructor(environment) {
2074
2240
  this.environment = environment;
@@ -2085,30 +2251,41 @@ var json_p3 = (function (exports) {
2085
2251
  parsePath(stream) {
2086
2252
  let inFilter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
2087
2253
  const selectors = [];
2088
- loop: for (;;) {
2089
- switch (stream.current.kind) {
2090
- case TokenKind.NAME:
2091
- selectors.push(new NameSelector(this.environment, stream.current, stream.current.value, true));
2092
- break;
2093
- case TokenKind.WILD:
2094
- selectors.push(new WildcardSelector(this.environment, stream.current, true));
2095
- break;
2096
- case TokenKind.DDOT:
2097
- selectors.push(new RecursiveDescentSegment(this.environment, stream.current));
2098
- break;
2099
- case TokenKind.LBRACKET:
2100
- selectors.push(this.parseBracketedSelection(stream));
2101
- break;
2102
- default:
2103
- if (inFilter) {
2104
- stream.backup();
2105
- }
2106
- break loop;
2254
+ for (;;) {
2255
+ const selector = this.parseSegment(stream);
2256
+ if (!selector) {
2257
+ if (inFilter) {
2258
+ stream.backup();
2259
+ }
2260
+ break;
2107
2261
  }
2262
+ selectors.push(selector);
2108
2263
  stream.next();
2109
2264
  }
2110
2265
  return selectors;
2111
2266
  }
2267
+ parseSegment(stream) {
2268
+ switch (stream.current.kind) {
2269
+ case TokenKind.NAME:
2270
+ return new NameSelector(this.environment, stream.current, stream.current.value, true);
2271
+ case TokenKind.WILD:
2272
+ return new WildcardSelector(this.environment, stream.current, true);
2273
+ case TokenKind.DDOT:
2274
+ {
2275
+ const segmentToken = stream.current;
2276
+ stream.next();
2277
+ const selector = this.parseSegment(stream);
2278
+ if (!selector) {
2279
+ throw new JSONPathSyntaxError("bald descendant segment", stream.current);
2280
+ }
2281
+ return new RecursiveDescentSegment(this.environment, segmentToken, selector);
2282
+ }
2283
+ case TokenKind.LBRACKET:
2284
+ return this.parseBracketedSelection(stream);
2285
+ default:
2286
+ return null;
2287
+ }
2288
+ }
2112
2289
  parseIndex(stream) {
2113
2290
  if (stream.current.value.length > 1 && stream.current.value.startsWith("0") || stream.current.value.startsWith("-0")) {
2114
2291
  throw new JSONPathSyntaxError("leading zero in index selector", stream.current);
@@ -2229,7 +2406,7 @@ var json_p3 = (function (exports) {
2229
2406
  parsePrefixExpression(stream) {
2230
2407
  stream.expect(TokenKind.NOT);
2231
2408
  stream.next();
2232
- return new PrefixExpression(stream.current, "!", this.parseFilterExpression(stream, PRECEDENCE_LOGICALRIGHT));
2409
+ return new PrefixExpression(stream.current, "!", this.parseFilterExpression(stream, PRECEDENCE_PREFIX));
2233
2410
  }
2234
2411
  parseInfixExpression(stream, left) {
2235
2412
  const tok = stream.next();
@@ -2351,7 +2528,10 @@ var json_p3 = (function (exports) {
2351
2528
  */
2352
2529
 
2353
2530
  /**
2531
+ * A configuration object from which JSONPath queries can be evaluated.
2354
2532
  *
2533
+ * An environment is where you'd register custom function extensions or set
2534
+ * the maximum recursion depth limit, for example.
2355
2535
  */
2356
2536
  class JSONPathEnvironment {
2357
2537
  /**
@@ -2384,8 +2564,7 @@ var json_p3 = (function (exports) {
2384
2564
  */
2385
2565
  functionRegister = new Map();
2386
2566
  /**
2387
- *
2388
- * @param options -
2567
+ * @param options - Environment configuration options.
2389
2568
  */
2390
2569
  constructor() {
2391
2570
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -2398,9 +2577,8 @@ var json_p3 = (function (exports) {
2398
2577
  }
2399
2578
 
2400
2579
  /**
2401
- *
2402
- * @param path -
2403
- * @returns
2580
+ * @param path - A JSONPath query to parse.
2581
+ * @returns A new {@link JSONPath} object, bound to this environment.
2404
2582
  */
2405
2583
  compile(path) {
2406
2584
  return new JSONPath(this, this.parser.parse(new TokenStream(tokenize(path))));
@@ -2408,14 +2586,28 @@ var json_p3 = (function (exports) {
2408
2586
 
2409
2587
  /**
2410
2588
  *
2411
- * @param path -
2412
- * @param value -
2413
- * @returns
2589
+ * @param path - A JSONPath query to parse and evaluate against _value_.
2590
+ * @param value - Data to which _path_ will be applied.
2591
+ * @returns The {@link JSONPathNodeList} resulting from applying _path_
2592
+ * to _value_.
2414
2593
  */
2415
2594
  query(path, value) {
2416
2595
  return this.compile(path).query(value);
2417
2596
  }
2418
2597
 
2598
+ /**
2599
+ * A lazy version of {@link query} which is faster and more memory
2600
+ * efficient when querying some large datasets.
2601
+ *
2602
+ * @param path - A JSONPath query to parse and evaluate against _value_.
2603
+ * @param value - Data to which _path_ will be applied.
2604
+ * @returns A sequence of {@link JSONPathNode} objects resulting from
2605
+ * applying _path_ to _value_.
2606
+ */
2607
+ lazyQuery(path, value) {
2608
+ return this.compile(path).lazyQuery(value);
2609
+ }
2610
+
2419
2611
  /**
2420
2612
  * Return a {@link JSONPathNode} instance for the first object found in
2421
2613
  * _value_ matching _path_.
@@ -2428,6 +2620,11 @@ var json_p3 = (function (exports) {
2428
2620
  match(path, value) {
2429
2621
  return this.compile(path).match(value);
2430
2622
  }
2623
+
2624
+ /**
2625
+ * A hook for setting up the function register. You are encouraged to
2626
+ * override this method in classes extending `JSONPathEnvironment`.
2627
+ */
2431
2628
  setupFilterFunctions() {
2432
2629
  this.functionRegister.set("count", new Count());
2433
2630
  this.functionRegister.set("length", new Length());
@@ -2437,9 +2634,18 @@ var json_p3 = (function (exports) {
2437
2634
  }
2438
2635
 
2439
2636
  /**
2637
+ * Check the well-typedness of a function's arguments at compile-time.
2638
+ *
2639
+ * This method is called by the {@link Parser} when parsing function calls.
2640
+ * It is expected to throw a {@link JSONPathTypeError} if the function's
2641
+ * parameters are not well-typed.
2642
+ *
2643
+ * Override this if you want to deviate from the JSONPath Spec's function
2644
+ * extension type system.
2440
2645
  *
2441
- * @param token -
2442
- * @param args -
2646
+ * @param token - The {@link Token} starting the function call. `Token.value`
2647
+ * will contain the name of the function.
2648
+ * @param args - One {@link FilterExpression} for each argument.
2443
2649
  */
2444
2650
  // eslint-disable-next-line sonarjs/cognitive-complexity
2445
2651
  checkWellTypedness(token, args) {
@@ -2506,6 +2712,27 @@ var json_p3 = (function (exports) {
2506
2712
  return DEFAULT_ENVIRONMENT.query(path, value);
2507
2713
  }
2508
2714
 
2715
+ /**
2716
+ * Lazily query JSON value _value_ with JSONPath expression _path_.
2717
+ * Lazy queries can be faster and more memory efficient when querying
2718
+ * large datasets, especially when using recursive decent selectors.
2719
+ *
2720
+ * @param path - A JSONPath expression/query.
2721
+ * @param value - The JSON-like value the JSONPath query is applied to.
2722
+ * @returns A sequence of {@link JSONPathNode} objects resulting from
2723
+ * applying _path_ to _value_.
2724
+ *
2725
+ * @throws {@link JSONPathSyntaxError}
2726
+ * If the path does not conform to standard syntax.
2727
+ *
2728
+ * @throws {@link JSONPathTypeError}
2729
+ * If filter function arguments are invalid, or filter expression are
2730
+ * used in an invalid way.
2731
+ */
2732
+ function lazyQuery(path, value) {
2733
+ return DEFAULT_ENVIRONMENT.lazyQuery(path, value);
2734
+ }
2735
+
2509
2736
  /**
2510
2737
  * Compile JSONPath _path_ for later use.
2511
2738
  * @param path - A JSONPath expression/query.
@@ -2555,6 +2782,7 @@ var json_p3 = (function (exports) {
2555
2782
  compile: compile,
2556
2783
  expressions: expression,
2557
2784
  functions: index$2,
2785
+ lazyQuery: lazyQuery,
2558
2786
  match: match,
2559
2787
  query: query,
2560
2788
  selectors: selectors
@@ -3040,7 +3268,7 @@ var json_p3 = (function (exports) {
3040
3268
  apply: apply
3041
3269
  });
3042
3270
 
3043
- const version = "0.2.0";
3271
+ const version = "0.3.0";
3044
3272
 
3045
3273
  exports.DEFAULT_ENVIRONMENT = DEFAULT_ENVIRONMENT;
3046
3274
  exports.FunctionExpressionType = FunctionExpressionType;
@@ -3068,6 +3296,7 @@ var json_p3 = (function (exports) {
3068
3296
  exports.jsonpatch = index;
3069
3297
  exports.jsonpath = index$1;
3070
3298
  exports.jsonpointer = index$3;
3299
+ exports.lazyQuery = lazyQuery;
3071
3300
  exports.query = query;
3072
3301
  exports.resolve = resolve;
3073
3302
  exports.version = version;