UNPKG

json-p3

Version:

JSONPath, JSON Pointer and JSON Patch

40 lines (39 loc) 1.65 kB
import { JSONPathEnvironment } from "./environment"; import { JSONPathNode } from "./node"; import { JSONPathSelector } from "./selectors"; import { Token } from "./token"; import { type SerializationOptions } from "./types"; /** Base class for all JSONPath segments. Both shorthand and bracketed. */ export declare abstract class JSONPathSegment { readonly environment: JSONPathEnvironment; readonly token: Token; readonly selectors: JSONPathSelector[]; constructor(environment: JSONPathEnvironment, token: Token, selectors: JSONPathSelector[]); /** * @param nodes - Nodes matched by preceding segments. */ abstract resolve(nodes: JSONPathNode[]): JSONPathNode[]; /** * @param nodes - Nodes matched by preceding segments. */ abstract lazyResolve(nodes: Iterable<JSONPathNode>): Generator<JSONPathNode>; /** * Return a string representation of this segment. */ abstract toString(options?: SerializationOptions): string; } /** The child selection segment. */ export declare class ChildSegment extends JSONPathSegment { resolve(nodes: JSONPathNode[]): JSONPathNode[]; lazyResolve(nodes: Iterable<JSONPathNode>): Generator<JSONPathNode>; toString(options?: SerializationOptions): string; } /** The recursive descent segment. */ export declare class DescendantSegment extends JSONPathSegment { resolve(nodes: JSONPathNode[]): JSONPathNode[]; lazyResolve(nodes: Iterable<JSONPathNode>): Generator<JSONPathNode>; toString(options?: SerializationOptions): string; private visit; private nondeterministicVisit; private nondeterministicChildren; }