UNPKG

@hn3000/json-ref

Version:

simple resolver for json reference and json pointer

50 lines (49 loc) 2.04 kB
export declare class JsonPointer { /** * Returns a JsonPointer object from a string or JsonPointer. * Used to allow clients to pass in either a string or a JsonPointer without having * to deal with the difference. * * @param path string or JsonPointer */ static get(path: string | string[] | JsonPointer): JsonPointer; /** * Collects all paths to objects deemed interesting by the predicated passed in. * * @param obj object to walk * @param pred predicate to decide whether an object's path should be returned */ static paths(obj: any, pred?: (x: any, p: JsonPointer) => boolean): string[]; /** * Collects all pointers to objects deemed interesting by the predicated passed in. * * @param obj object to walk * @param pred predicate to decide whether an object's path should be returned */ static pointers(obj: any, pred?: (x: any, p: JsonPointer) => boolean): JsonPointer[]; /** * Walk obj and pass all values and their paths to the walker function. * * Stops descending into sub-objects if the walker returns true. */ static walkObject(obj: any, walker: (val: any, p: JsonPointer) => boolean): void; static deref(p: string, obj: any): any; constructor(ref: string | string[] | JsonPointer, extraUnquoted?: string); add(extraUnquoted: string): JsonPointer; hasParent(): boolean; get parent(): JsonPointer; get(segment: number): string; static unquote(s: string): string; static quote(s: string): string; static _deref(o: any, k: string): any; static _set(o: any, k: string, v: any): void; getValue(obj: any): any; setValue(obj: any, val: any, createPath?: boolean): any; withValue(obj: any, val: any, createPath?: boolean): any; _changeValue(obj: any, val: any, createPath: boolean, makeMutable: (x: any) => any): any; deleteValue(obj: any): void; asString(): string; toString(): string; get keys(): string[]; private _keypath; }