json-p3 2.2.2 → 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 +70 -97
  6. package/dist/json-p3.esm.js +70 -97
  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 -5366
  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 -74
  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,33 +0,0 @@
1
- import { FilterFunction, FunctionExpressionType } from "./function";
2
- export type MatchFilterFunctionOptions = {
3
- /**
4
- * The maximum number of regular expressions to cache.
5
- */
6
- cacheSize?: number;
7
- /**
8
- * If _true_, throw errors from regex checking, construction and matching.
9
- * The standard and default behavior is to ignore these errors and return
10
- * _false_.
11
- */
12
- throwErrors?: boolean;
13
- /**
14
- * If _true_, check that regexp patterns are valid according to I-Regexp.
15
- * The standard and default behavior is to silently return _false_ if a
16
- * pattern is invalid.
17
- *
18
- * If `iRegexpCheck` is _true_ and `throwErrors` is _true_, an `IRegexpError`
19
- * will be thrown.
20
- */
21
- iRegexpCheck?: boolean;
22
- };
23
- export declare class Match implements FilterFunction {
24
- #private;
25
- readonly options: MatchFilterFunctionOptions;
26
- readonly argTypes: FunctionExpressionType[];
27
- readonly returnType = FunctionExpressionType.LogicalType;
28
- readonly cacheSize: number;
29
- readonly throwErrors: boolean;
30
- readonly iRegexpCheck: boolean;
31
- constructor(options?: MatchFilterFunctionOptions);
32
- call(s: string, pattern: string): boolean;
33
- }
@@ -1,2 +0,0 @@
1
- export declare function mapRegexp(pattern: string): string;
2
- export declare function fullMatch(pattern: string): string;
@@ -1,34 +0,0 @@
1
- import { FilterFunction, FunctionExpressionType } from "./function";
2
- export type SearchFilterFunctionOptions = {
3
- /**
4
- * The maximum number of regular expressions to cache. Defaults
5
- * to 10.
6
- */
7
- cacheSize?: number;
8
- /**
9
- * If _true_, throw errors from regex construction and matching.
10
- * The standard and default behavior is to ignore these errors
11
- * and return _false_.
12
- */
13
- throwErrors?: boolean;
14
- /**
15
- * If _true_, check that regexp patterns are valid according to I-Regexp.
16
- * The standard and default behavior is to silently return _false_ if a
17
- * pattern is invalid.
18
- *
19
- * If `iRegexpCheck` is _true_ and `throwErrors` is _true_, an `IRegexpError`
20
- * will be thrown.
21
- */
22
- iRegexpCheck?: boolean;
23
- };
24
- export declare class Search implements FilterFunction {
25
- #private;
26
- readonly options: SearchFilterFunctionOptions;
27
- readonly argTypes: FunctionExpressionType[];
28
- readonly returnType = FunctionExpressionType.LogicalType;
29
- readonly cacheSize: number;
30
- readonly throwErrors: boolean;
31
- readonly iRegexpCheck: boolean;
32
- constructor(options?: SearchFilterFunctionOptions);
33
- call(s: string, pattern: string): boolean;
34
- }
@@ -1,7 +0,0 @@
1
- import { JSONPathNodeList } from "../node";
2
- import { FilterFunction, FunctionExpressionType } from "./function";
3
- export declare class Value implements FilterFunction {
4
- readonly argTypes: FunctionExpressionType[];
5
- readonly returnType = FunctionExpressionType.ValueType;
6
- call(nodes: JSONPathNodeList): unknown;
7
- }
@@ -1,76 +0,0 @@
1
- import { JSONValue } from "../types";
2
- import { JSONPathEnvironment } from "./environment";
3
- import { JSONPathNode, JSONPathNodeList } from "./node";
4
- import { JSONPathQuery } from "./path";
5
- export { JSONPathEnvironment } from "./environment";
6
- export type { JSONPathEnvironmentOptions } from "./environment";
7
- export { JSONPathSegment } from "./segments";
8
- export { JSONPathSelector } from "./selectors";
9
- export { JSONPathQuery } from "./path";
10
- export { JSONPathNodeList, JSONPathNode } from "./node";
11
- export { Token, TokenKind } from "./token";
12
- export * as selectors from "./selectors";
13
- export * as expressions from "./expression";
14
- export * as functions from "./functions";
15
- export { FunctionExpressionType } from "./functions";
16
- export type { FilterFunction } from "./functions";
17
- export { JSONPathError, JSONPathIndexError, JSONPathLexerError, JSONPathSyntaxError, JSONPathTypeError, JSONPathRecursionLimitError, } from "./errors";
18
- export { Nothing, KEY_MARK } from "./types";
19
- export type { JSONPathValue, FilterContext, SerializationOptions, } from "./types";
20
- export declare const DEFAULT_ENVIRONMENT: JSONPathEnvironment;
21
- /**
22
- * Query JSON value _value_ with JSONPath expression _path_.
23
- * @param path - A JSONPath expression/query.
24
- * @param value - The JSON-like value the JSONPath query is applied to.
25
- * @returns A list of JSONPathNode objects, one for each value matched
26
- * by _path_ in _value_.
27
- *
28
- * @throws {@link JSONPathSyntaxError}
29
- * If the path does not conform to standard syntax.
30
- *
31
- * @throws {@link JSONPathTypeError}
32
- * If filter function arguments are invalid, or filter expression are
33
- * used in an invalid way.
34
- */
35
- export declare function query(path: string, value: JSONValue): JSONPathNodeList;
36
- /**
37
- * Lazily query JSON value _value_ with JSONPath expression _path_.
38
- * Lazy queries can be faster and more memory efficient when querying
39
- * large datasets, especially when using recursive decent selectors.
40
- *
41
- * @param path - A JSONPath expression/query.
42
- * @param value - The JSON-like value the JSONPath query is applied to.
43
- * @returns A sequence of {@link JSONPathNode} objects resulting from
44
- * applying _path_ to _value_.
45
- *
46
- * @throws {@link JSONPathSyntaxError}
47
- * If the path does not conform to standard syntax.
48
- *
49
- * @throws {@link JSONPathTypeError}
50
- * If filter function arguments are invalid, or filter expression are
51
- * used in an invalid way.
52
- */
53
- export declare function lazyQuery(path: string, value: JSONValue): IterableIterator<JSONPathNode>;
54
- /**
55
- * Compile JSONPath _path_ for later use.
56
- * @param path - A JSONPath expression/query.
57
- * @returns A path object with a `query()` method.
58
- *
59
- * @throws {@link JSONPathSyntaxError}
60
- * If the path does not conform to standard syntax.
61
- *
62
- * @throws {@link JSONPathTypeError}
63
- * If filter function arguments are invalid, or filter expression are
64
- * used in an invalid way.
65
- */
66
- export declare function compile(path: string): JSONPathQuery;
67
- /**
68
- * Return a {@link JSONPathNode} instance for the first object found in
69
- * _value_ matching _path_.
70
- *
71
- * @param path - A JSONPath query.
72
- * @param value - JSON-like data to which the query _path_ will be applied.
73
- * @returns The first node in _value_ matching _path_, or `undefined` if
74
- * there are no matches.
75
- */
76
- export declare function match(path: string, value: JSONValue): JSONPathNode | undefined;
@@ -1,74 +0,0 @@
1
- /** A lexer that accepts additional, non-standard tokens. */
2
- import { JSONPathEnvironment } from "./environment";
3
- import { Token, TokenKind } from "./token";
4
- /**
5
- * JSONPath lexical scanner.
6
- *
7
- * Lexer state is shared between this class and the current state function. A
8
- * new _Lexer_ instance is automatically created every time a path is tokenized.
9
- *
10
- * Use {@link tokenize} to get an array of {@link Token}'s for a JSONPath query.
11
- */
12
- declare class Lexer {
13
- #private;
14
- readonly environment: JSONPathEnvironment;
15
- readonly path: string;
16
- /**
17
- * Filter nesting level.
18
- */
19
- filterLevel: number;
20
- /**
21
- * A running count of parentheses for each, possibly nested, function call.
22
- *
23
- * If the stack is empty, we are not in a function call. Remember that
24
- * function arguments can use arbitrarily nested in parentheses.
25
- */
26
- funcCallStack: number[];
27
- /**
28
- * A stack of parentheses and square brackets used to check for balanced
29
- * brackets.
30
- */
31
- bracketStack: Array<[string, number]>;
32
- /** Tokens resulting from tokenizing a JSONPath query. */
33
- tokens: Token[];
34
- /**
35
- * @param path - A JSONPath query.
36
- */
37
- constructor(environment: JSONPathEnvironment, path: string);
38
- get pos(): number;
39
- get start(): number;
40
- run(): void;
41
- emit(t: TokenKind): void;
42
- next(): string;
43
- ignore(): void;
44
- backup(): void;
45
- peek(): string;
46
- peekMatch(pattern: RegExp): boolean;
47
- accept(valid: Set<string>): boolean;
48
- acceptMatch(pattern: RegExp): boolean;
49
- acceptRun(valid: Set<string>): boolean;
50
- acceptMatchRun(pattern: RegExp): boolean;
51
- ignoreWhitespace(): boolean;
52
- error(msg: string): void;
53
- }
54
- /**
55
- * Return a lexer for _path_ and an array to be populated with Tokens.
56
- *
57
- * `lexer.run()` must be called to populate the returned tokens array.
58
- *
59
- * You probably want to use {@link tokenize} instead of _lex_. This function
60
- * is mostly for internal use, where we want to test the state of the returned
61
- * _lexer_ after tokens have been populated.
62
- *
63
- * @param path - A JSONPath query.
64
- * @returns A two-tuple containing a lexer for _path_ and an array to populate
65
- * with tokens.
66
- */
67
- export declare function lex(environment: JSONPathEnvironment, path: string): [Lexer, Token[]];
68
- /**
69
- * Scan _path_ and return an array of tokens to be parsed by the parser.
70
- * @param path - A JSONPath query.
71
- * @returns Tokens to be parsed by the parser.
72
- */
73
- export declare function tokenize(environment: JSONPathEnvironment, path: string): Token[];
74
- export {};
@@ -1,10 +0,0 @@
1
- /**
2
- * A Least Recently Used cache, implemented as an extended Map.
3
- */
4
- export declare class LRUCache<K, V> extends Map<K, V> {
5
- readonly maxSize: number;
6
- constructor(maxSize?: number, entries?: Iterable<[K, V]>);
7
- get(key: K): V | undefined;
8
- set(key: K, value: V): this;
9
- first(): K | undefined;
10
- }
@@ -1,84 +0,0 @@
1
- import { JSONPointer } from "../pointer";
2
- import { JSONValue } from "../types";
3
- import { type SerializationOptions } from "./types";
4
- /**
5
- * The pair of a JSON value and its location found in the target JSON value.
6
- */
7
- export declare class JSONPathNode {
8
- readonly value: JSONValue;
9
- readonly location: Array<string | number>;
10
- readonly root: JSONValue;
11
- /**
12
- * @param value - The JSON value found at _location_.
13
- * @param location - The parts of a normalized path to _value_.
14
- * @param root - The target value at the top of the JSON node tree.
15
- */
16
- constructor(value: JSONValue, location: Array<string | number>, root: JSONValue);
17
- /**
18
- * @deprecated Use {@link getPath} with `options.form` set to `canonical` instead.
19
- */
20
- get path(): string;
21
- /**
22
- * Get the path to this node in the target JSON value.
23
- *
24
- * Given that the path refers to the singular current node, the returned path
25
- * will always be a normalized path if `options.form` is set to `canonical`,
26
- * following section 2.7 of RFC 9535.
27
- */
28
- getPath(options?: SerializationOptions): string;
29
- /**
30
- * Return this node's location as a {@link JSONPointer}.
31
- */
32
- toPointer(): JSONPointer;
33
- private decodeNameLocation;
34
- }
35
- /**
36
- *
37
- */
38
- export declare class JSONPathNodeList {
39
- readonly nodes: JSONPathNode[];
40
- constructor(nodes: JSONPathNode[]);
41
- /**
42
- * @returns an iterator over nodes in the list.
43
- */
44
- [Symbol.iterator](): Iterator<JSONPathNode>;
45
- /**
46
- * @returns `true` if the node list is empty.
47
- */
48
- empty(): boolean;
49
- /**
50
- * @returns An array containing the values at each node in the list.
51
- *
52
- * @see {@link valuesOrSingular} to unpack the array if there is only
53
- * one node in the list.
54
- */
55
- values(): JSONValue[];
56
- /**
57
- * Like {@link values}, but returns the node's value is there is only one
58
- * node in the list.
59
- */
60
- valuesOrSingular(): JSONValue;
61
- /**
62
- * @returns An array of locations for each node in the node list.
63
- *
64
- * A location is an array of property names and array indices that were
65
- * required to reach the node's value in the target JSON value.
66
- */
67
- locations(): Array<Array<string | number>>;
68
- /**
69
- * @returns An array of normalized path strings for each node in the list.
70
- *
71
- * A normalized path contains only property name and index selectors, and
72
- * always uses bracketed segments, never shorthand selectors.
73
- */
74
- paths(options?: SerializationOptions): string[];
75
- /**
76
- * @returns An array of {@link JSONPointer} instances, one for each node
77
- * in the list.
78
- */
79
- pointers(): JSONPointer[];
80
- /**
81
- * @returns The number of nodes in the node list.
82
- */
83
- get length(): number;
84
- }
@@ -1,61 +0,0 @@
1
- import { JSONPathEnvironment } from "./environment";
2
- import { BooleanLiteral, FilterExpression, FunctionExtension, InfixExpression, NullLiteral, NumberLiteral, PrefixExpression, RelativeQuery, RootQuery, StringLiteral } from "./expression";
3
- import { FilterSelector, IndexSelector, JSONPathSelector, SliceSelector } from "./selectors";
4
- import { JSONPathSegment } from "./segments";
5
- import { Token, TokenStream } from "./token";
6
- import { CurrentKey } from "./extra/expression";
7
- /**
8
- * JSONPath token stream parser.
9
- */
10
- export declare class Parser {
11
- readonly environment: JSONPathEnvironment;
12
- protected tokenMap: Map<string, (stream: TokenStream) => FilterExpression>;
13
- constructor(environment: JSONPathEnvironment);
14
- parse(stream: TokenStream): JSONPathSegment[];
15
- protected parseQuery(stream: TokenStream, inFilter?: boolean): JSONPathSegment[];
16
- protected parseSelectors(stream: TokenStream): JSONPathSelector[];
17
- protected parseIndex(stream: TokenStream): IndexSelector;
18
- protected parseSlice(stream: TokenStream): SliceSelector;
19
- protected parseBracketedSelection(stream: TokenStream): JSONPathSelector[];
20
- protected parseFilter(stream: TokenStream, keys?: boolean): FilterSelector;
21
- protected parseBoolean(stream: TokenStream): BooleanLiteral;
22
- protected parseNull(stream: TokenStream): NullLiteral;
23
- protected parseString(stream: TokenStream): StringLiteral;
24
- protected parseNumber(stream: TokenStream): NumberLiteral;
25
- protected parsePrefixExpression(stream: TokenStream): PrefixExpression;
26
- protected parseInfixExpression(stream: TokenStream, left: FilterExpression): InfixExpression;
27
- protected parseGroupedExpression(stream: TokenStream): FilterExpression;
28
- protected parseRootQuery(stream: TokenStream): RootQuery;
29
- protected parseRelativeQuery(stream: TokenStream): RelativeQuery;
30
- protected parseCurrentKey(stream: TokenStream): CurrentKey;
31
- protected parseFunction(stream: TokenStream): FunctionExtension;
32
- protected parseFilterExpression(stream: TokenStream, precedence?: number): FilterExpression;
33
- protected decodeString(token: Token): string;
34
- protected unescapeString(value: string, token: Token): string;
35
- /**
36
- * Decode a `\uXXXX` or `\uXXXX\uXXXX` escape sequence from _value_ at _index_.
37
- *
38
- * @param value - A string value containing the sequence to decode.
39
- * @param index - The start index of an escape sequence in _value_.
40
- * @param token - The token for the string value.
41
- * @returns - A codepoint, new index tuple.
42
- */
43
- protected decodeHexChar(value: string, index: number, token: Token): [number, number];
44
- /**
45
- * Parse a hexadecimal string as an integer.
46
- *
47
- * @param digits - Hexadecimal digit string.
48
- * @param token - The token for the string value.
49
- * @returns - The number representation of _digits_.
50
- *
51
- * Note that we're not using `parseInt(digits, 16)` because it accepts `+`
52
- * and `-` and things we don't allow.
53
- */
54
- protected parseHexDigits(digits: string, token: Token): number;
55
- /** Check the codepoint is valid and return its string representation. */
56
- protected stringFromCodePoint(codepoint: number | undefined, token: Token): string;
57
- protected throwForNonComparable(expr: FilterExpression): void;
58
- protected throwForLiteral(expr: FilterExpression): void;
59
- }
60
- export declare function isHighSurrogate(codepoint: number): boolean;
61
- export declare function isLowSurrogate(codepoint: number): boolean;
@@ -1,42 +0,0 @@
1
- import { JSONPathEnvironment } from "./environment";
2
- import { JSONPathNode, JSONPathNodeList } from "./node";
3
- import { JSONValue } from "../types";
4
- import { JSONPathSegment } from "./segments";
5
- import { SerializationOptions } from "./types";
6
- /**
7
- * A compiled JSONPath query ready to be applied to different data repeatedly.
8
- */
9
- export declare class JSONPathQuery {
10
- readonly environment: JSONPathEnvironment;
11
- readonly segments: JSONPathSegment[];
12
- constructor(environment: JSONPathEnvironment, segments: JSONPathSegment[]);
13
- /**
14
- * Apply this JSONPath query to _value_.
15
- * @param value - A JSON-like object to apply this query to.
16
- * @returns Nodes matched by applying this query to _value_.
17
- */
18
- query(value: JSONValue): JSONPathNodeList;
19
- /**
20
- * Apply this JSONPath query to _value_.
21
- * @param value - A JSON-like object to apply this query to.
22
- * @returns An iterator over nodes matched by applying this query to _value_.
23
- */
24
- lazyQuery(value: JSONValue): IterableIterator<JSONPathNode>;
25
- /**
26
- * Return a {@link JSONPathNode} instance for the first object found in
27
- * _value_ matching this query.
28
- *
29
- * @param value - JSON-like data to which this query will be applied.
30
- * @returns The first node in _value_ matching this query, or `undefined` if
31
- * there are no matches.
32
- */
33
- match(value: JSONValue): JSONPathNode | undefined;
34
- /**
35
- * Return a string representation of this query.
36
- */
37
- toString(options?: SerializationOptions): string;
38
- /**
39
- * Return `true` if this query is a _singular query_, or `false` otherwise.
40
- */
41
- singularQuery(): boolean;
42
- }
@@ -1,39 +0,0 @@
1
- import { JSONPathEnvironment } from "./environment";
2
- import { JSONPathNode } from "./node";
3
- import { JSONPathSelector } from "./selectors";
4
- import { Token } from "./token";
5
- import { type SerializationOptions } from "./types";
6
- /** Base class for all JSONPath segments. Both shorthand and bracketed. */
7
- export declare abstract class JSONPathSegment {
8
- readonly environment: JSONPathEnvironment;
9
- readonly token: Token;
10
- readonly selectors: JSONPathSelector[];
11
- constructor(environment: JSONPathEnvironment, token: Token, selectors: JSONPathSelector[]);
12
- /**
13
- * @param nodes - Nodes matched by preceding segments.
14
- */
15
- abstract resolve(nodes: JSONPathNode[]): JSONPathNode[];
16
- /**
17
- * @param nodes - Nodes matched by preceding segments.
18
- */
19
- abstract lazyResolve(nodes: Iterable<JSONPathNode>): Generator<JSONPathNode>;
20
- /**
21
- * Return a string representation of this segment.
22
- */
23
- abstract toString(options?: SerializationOptions): string;
24
- }
25
- /** The child selection segment. */
26
- export declare class ChildSegment extends JSONPathSegment {
27
- resolve(nodes: JSONPathNode[]): JSONPathNode[];
28
- lazyResolve(nodes: Iterable<JSONPathNode>): Generator<JSONPathNode>;
29
- toString(options?: SerializationOptions): string;
30
- }
31
- /** The recursive descent segment. */
32
- export declare class DescendantSegment extends JSONPathSegment {
33
- resolve(nodes: JSONPathNode[]): JSONPathNode[];
34
- lazyResolve(nodes: Iterable<JSONPathNode>): Generator<JSONPathNode>;
35
- toString(options?: SerializationOptions): string;
36
- private visit;
37
- private nondeterministicVisit;
38
- private nondeterministicChildren;
39
- }
@@ -1,85 +0,0 @@
1
- import { JSONPathEnvironment } from "./environment";
2
- import { LogicalExpression } from "./expression";
3
- import { JSONPathNode } from "./node";
4
- import { Token } from "./token";
5
- import { type SerializationOptions } from "./types";
6
- /**
7
- * Base class for all JSONPath segments and selectors.
8
- */
9
- export declare abstract class JSONPathSelector {
10
- readonly environment: JSONPathEnvironment;
11
- readonly token: Token;
12
- /**
13
- * @param token - The token at the start of this selector.
14
- */
15
- constructor(environment: JSONPathEnvironment, token: Token);
16
- /**
17
- * @param node - Nodes matched by preceding selectors.
18
- */
19
- abstract resolve(node: JSONPathNode): JSONPathNode[];
20
- /**
21
- * @param node - Nodes matched by preceding selectors.
22
- */
23
- abstract lazyResolve(node: JSONPathNode): Generator<JSONPathNode>;
24
- /**
25
- * Return a canonical string representation of this selector.
26
- */
27
- abstract toString(options?: SerializationOptions): string;
28
- }
29
- /**
30
- * Shorthand and quoted name selector.
31
- */
32
- export declare class NameSelector extends JSONPathSelector {
33
- readonly environment: JSONPathEnvironment;
34
- readonly token: Token;
35
- readonly name: string;
36
- constructor(environment: JSONPathEnvironment, token: Token, name: string);
37
- resolve(node: JSONPathNode): JSONPathNode[];
38
- lazyResolve(node: JSONPathNode): Generator<JSONPathNode>;
39
- toString(options?: SerializationOptions): string;
40
- shorthand(): string | null;
41
- }
42
- /**
43
- * Array index selector.
44
- */
45
- export declare class IndexSelector extends JSONPathSelector {
46
- readonly environment: JSONPathEnvironment;
47
- readonly token: Token;
48
- readonly index: number;
49
- constructor(environment: JSONPathEnvironment, token: Token, index: number);
50
- resolve(node: JSONPathNode): JSONPathNode[];
51
- lazyResolve(node: JSONPathNode): Generator<JSONPathNode>;
52
- toString(): string;
53
- private normalizedIndex;
54
- }
55
- export declare class SliceSelector extends JSONPathSelector {
56
- readonly environment: JSONPathEnvironment;
57
- readonly token: Token;
58
- readonly start?: number | undefined;
59
- readonly stop?: number | undefined;
60
- readonly step?: number | undefined;
61
- constructor(environment: JSONPathEnvironment, token: Token, start?: number | undefined, stop?: number | undefined, step?: number | undefined);
62
- resolve(node: JSONPathNode): JSONPathNode[];
63
- lazyResolve(node: JSONPathNode): Generator<JSONPathNode>;
64
- toString(): string;
65
- private checkRange;
66
- private slice;
67
- private lazySlice;
68
- }
69
- export declare class WildcardSelector extends JSONPathSelector {
70
- readonly environment: JSONPathEnvironment;
71
- readonly token: Token;
72
- constructor(environment: JSONPathEnvironment, token: Token);
73
- resolve(node: JSONPathNode): JSONPathNode[];
74
- lazyResolve(node: JSONPathNode): Generator<JSONPathNode>;
75
- toString(): string;
76
- }
77
- export declare class FilterSelector extends JSONPathSelector {
78
- readonly environment: JSONPathEnvironment;
79
- readonly token: Token;
80
- readonly expression: LogicalExpression;
81
- constructor(environment: JSONPathEnvironment, token: Token, expression: LogicalExpression);
82
- resolve(node: JSONPathNode): JSONPathNode[];
83
- lazyResolve(node: JSONPathNode): Generator<JSONPathNode>;
84
- toString(options?: SerializationOptions): string;
85
- }
@@ -1,6 +0,0 @@
1
- /** Usable in a quoted path. */
2
- export declare function toQuoted(name: string): string;
3
- /** Usable in a normalized path. */
4
- export declare function toCanonical(name: string): string;
5
- /** Usable in a shorthand path. */
6
- export declare function toShorthand(name: string): string | null;
@@ -1,70 +0,0 @@
1
- /**
2
- *
3
- */
4
- export declare enum TokenKind {
5
- AND = "TOKEN_AND",
6
- COLON = "TOKEN_COLON",
7
- COMMA = "TOKEN_COMMA",
8
- CURRENT = "TOKEN_CURRENT_VALUE",
9
- CURRENT_KEY = "TOKEN_CURRENT_KEY",// non-standard, default `#`
10
- DDOT = "TOKEN_DDOT",
11
- DOT = "TOKEN_DOT",
12
- DOUBLE_QUOTE_STRING = "TOKEN_DOUBLE_QUOTE_STRING",
13
- EOF = "TOKEN_EOF",
14
- EQ = "TOKEN_EQ",
15
- ERROR = "TOKEN_ERROR",
16
- FALSE = "TOKEN_FALSE",
17
- FILTER = "TOKEN_FILTER_START",
18
- FUNCTION = "TOKEN_FUNCTION",
19
- GE = "TOKEN_GE",
20
- GT = "TOKEN_GT",
21
- INDEX = "TOKEN_INDEX",
22
- KEY = "TOKEN_KEY",// non-standard, default `~<name>`
23
- KEY_DOUBLE_QUOTE_STRING = "TOKEN_KEY_DOUBLE_QUOTE_STRING",// non-standard, `~"<name>"`
24
- KEY_SINGLE_QUOTE_STRING = "TOKEN_KEY_SINGLE_QUOTE_STRING",// non-standard, `~'<name>'`
25
- KEYS = "TOKEN_KEYS",// non-standard, default `~`
26
- KEYS_FILTER = "TOKEN_KEYS_FILTER",// non-standard, `~?<expression>`
27
- LBRACKET = "TOKEN_LBRACKET",
28
- LE = "TOKEN_LE",
29
- LG = "TOKEN_LG",
30
- LPAREN = "TOKEN_LPAREN",
31
- LT = "TOKEN_LT",
32
- NAME = "TOKEN_NAME",
33
- NE = "TOKEN_NE",
34
- NOT = "TOKEN_NOT",
35
- NULL = "TOKEN_NULL",
36
- NUMBER = "NUMBER",
37
- OR = "TOKEN_OR",
38
- RBRACKET = "TOKEN_RBRACKET",
39
- ROOT = "TOKEN_ROOT",
40
- RPAREN = "TOKEN_RPAREN",
41
- SINGLE_QUOTE_STRING = "TOKEN_SINGLE_QUOTE_STRING",
42
- TRUE = "TOKEN_TRUE",
43
- WILD = "TOKEN_WILD"
44
- }
45
- /**
46
- *
47
- */
48
- export declare class Token {
49
- readonly kind: TokenKind;
50
- readonly value: string;
51
- readonly index: number;
52
- readonly input: string;
53
- constructor(kind: TokenKind, value: string, index: number, input: string);
54
- }
55
- export declare const EOF: Token;
56
- /**
57
- *
58
- */
59
- export declare class TokenStream {
60
- #private;
61
- private tokens;
62
- constructor(tokens: Token[]);
63
- get current(): Token;
64
- get peek(): Token;
65
- next(): Token;
66
- backup(): void;
67
- expect(kind: TokenKind): void;
68
- expectPeek(kind: TokenKind): void;
69
- expectPeekNot(kind: TokenKind, message: string): void;
70
- }