json-p3
Version:
JSONPath, JSON Pointer and JSON Patch
86 lines (85 loc) • 3.31 kB
TypeScript
import { JSONPathEnvironment } from "./environment";
import { LogicalExpression } from "./expression";
import { JSONPathNode } from "./node";
import { Token } from "./token";
import { type SerializationOptions } from "./types";
/**
* Base class for all JSONPath segments and selectors.
*/
export declare abstract class JSONPathSelector {
readonly environment: JSONPathEnvironment;
readonly token: Token;
/**
* @param token - The token at the start of this selector.
*/
constructor(environment: JSONPathEnvironment, token: Token);
/**
* @param node - Nodes matched by preceding selectors.
*/
abstract resolve(node: JSONPathNode): JSONPathNode[];
/**
* @param node - Nodes matched by preceding selectors.
*/
abstract lazyResolve(node: JSONPathNode): Generator<JSONPathNode>;
/**
* Return a canonical string representation of this selector.
*/
abstract toString(options?: SerializationOptions): string;
}
/**
* Shorthand and quoted name selector.
*/
export declare class NameSelector extends JSONPathSelector {
readonly environment: JSONPathEnvironment;
readonly token: Token;
readonly name: string;
constructor(environment: JSONPathEnvironment, token: Token, name: string);
resolve(node: JSONPathNode): JSONPathNode[];
lazyResolve(node: JSONPathNode): Generator<JSONPathNode>;
toString(options?: SerializationOptions): string;
shorthand(): string | null;
}
/**
* Array index selector.
*/
export declare class IndexSelector extends JSONPathSelector {
readonly environment: JSONPathEnvironment;
readonly token: Token;
readonly index: number;
constructor(environment: JSONPathEnvironment, token: Token, index: number);
resolve(node: JSONPathNode): JSONPathNode[];
lazyResolve(node: JSONPathNode): Generator<JSONPathNode>;
toString(): string;
private normalizedIndex;
}
export declare class SliceSelector extends JSONPathSelector {
readonly environment: JSONPathEnvironment;
readonly token: Token;
readonly start?: number | undefined;
readonly stop?: number | undefined;
readonly step?: number | undefined;
constructor(environment: JSONPathEnvironment, token: Token, start?: number | undefined, stop?: number | undefined, step?: number | undefined);
resolve(node: JSONPathNode): JSONPathNode[];
lazyResolve(node: JSONPathNode): Generator<JSONPathNode>;
toString(): string;
private checkRange;
private slice;
private lazySlice;
}
export declare class WildcardSelector extends JSONPathSelector {
readonly environment: JSONPathEnvironment;
readonly token: Token;
constructor(environment: JSONPathEnvironment, token: Token);
resolve(node: JSONPathNode): JSONPathNode[];
lazyResolve(node: JSONPathNode): Generator<JSONPathNode>;
toString(): string;
}
export declare class FilterSelector extends JSONPathSelector {
readonly environment: JSONPathEnvironment;
readonly token: Token;
readonly expression: LogicalExpression;
constructor(environment: JSONPathEnvironment, token: Token, expression: LogicalExpression);
resolve(node: JSONPathNode): JSONPathNode[];
lazyResolve(node: JSONPathNode): Generator<JSONPathNode>;
toString(options?: SerializationOptions): string;
}