@finnair/path
Version:
Simple object path as array of strings and numbers
31 lines (30 loc) • 1.15 kB
TypeScript
export type PathComponent = number | string;
export declare class Path {
static readonly ROOT: Path;
private readonly path;
private constructor();
index(index: number): Path;
property(property: string): Path;
child(key: number | string): Path;
connectTo(newRootPath: Path): Path;
concat(childPath: Path): Path;
parent(): undefined | Path;
toJSON(): string;
equals(other: any): boolean;
get length(): number;
componentAt(index: number): PathComponent;
[Symbol.iterator](): ArrayIterator<PathComponent>;
get(root: any): any;
unset(root: any): any;
set(root: any, value: any): any;
static property(property: string): Path;
static index(index: number): Path;
static of(...path: PathComponent[]): Path;
static validateComponent(component: any): void;
static validateIndex(index: any): void;
static validateProperty(property: any): void;
static isValidIdentifier(str: string): boolean;
static componentToString(component: PathComponent): string;
static indexToString(index: number): string;
static propertyToString(property: string): string;
}