dot-wild
Version:
Use powerful dot notation (dot path + wildcard) to manipulate properties of JSON
52 lines (51 loc) • 1.71 kB
TypeScript
/**
* Tokenize path string
*/
export declare const tokenize: (str: string) => string[];
/**
* Getter
*/
export interface DotGetOptions {
iterateObject?: boolean;
iterateArray?: boolean;
}
export declare const get: (data: any, path: string | number, value?: any, options?: DotGetOptions | undefined) => any;
/**
* Setter
*/
export declare const set: (data: any, path: string | number, value: any) => any;
export declare const remove: (data: any, path: string | number) => any;
/**
* Check value
*/
export declare const has: (data: any, path: string | number) => boolean;
export declare const flatten: (data: any) => any;
/**
* Expand vaules
*/
export declare const expand: (data: any) => any;
/**
* Executes a provided function once for each element.
*/
export declare const forEach: (data: any, path: string | number, iteratee: (value: any, key: string | number, context: any, path: string, data: any) => boolean | void, options?: DotGetOptions | undefined) => void;
/**
* Create a new element
* with the results of calling a provided function on every element.
*/
export declare const map: (data: any, path: string | number, iteratee: (value: any, key: string | number, context: any, path: string, data: any) => any, options?: DotGetOptions | undefined) => any[];
/**
* Match key
*/
export declare const matchPath: (pathA: string, pathB: string) => boolean;
/**
* Escape path string
*/
export declare const escapePath: (path: string) => string;
/**
* Build path from Tokens like array
*/
export declare const buildPath: (tokens: (string | number)[]) => string;
/**
* Check contains of wildcard syntax
*/
export declare const containWildcardToken: (path: string) => boolean;