UNPKG

ag-charts-community

Version:

Advanced Charting / Charts supporting Javascript / Typescript / React / Angular / Vue

91 lines (90 loc) 3.62 kB
import type { DeepPartial } from 'ag-charts-core'; type StringSet = { has(value: string): boolean; }; export type CloneOptions = { shallow?: StringSet; assign?: StringSet; }; /** * Performs a recursive JSON-diff between a source and target JSON structure. * * On a per-property basis, takes the target property value where: * - types are different. * - type is primitive. * - type is array and length or content have changed. * * @param source starting point for diff * @param target target for diff vs. source + * @param shallow object keys to only shallow compare during diff * @returns `null` if no differences, or an object with the subset of properties that have changed. */ export declare function jsonDiff<T>(source: T, target: T, shallow?: Set<keyof T>): Partial<T> | null; /** * Compares all properties of source against target's properties of the same name. * * @param source object to read properties from * @param target object to compare property values with * * @returns true if all properties in source have identical values in target */ export declare function jsonPropertyCompare<T>(source: Partial<T>, target: T): boolean; /** * Recursively clones of primitives and objects. * * @param source object | array * @param shallow * * @return deep clone of source */ export declare function deepClone<T>(source: T, opts?: CloneOptions): T; /** * Clones of primitives and objects. * * @param source any value * * @return shallow clone of source */ export declare function shallowClone<T>(source: T): T; /** * Walk the given JSON object graphs, invoking the visit() callback for every object encountered. * Arrays are descended into without a callback, however their elements will have the visit() * callback invoked if they are objects. * * @param json to traverse * @param visit callback for each non-primitive and non-array object found * @param skip property names to skip when walking * @param parallelJson to traverse in parallel * @param ctx * @param acc initial accumulator value */ export declare function jsonWalk<T, C, R>(json: T, visit: (node: T, parallelNode?: T, ctx?: C, acc?: R) => R, skip?: Set<string>, parallelJson?: T, ctx?: C, acc?: R): R; /** * Recursively apply a JSON object into a class-hierarchy, optionally instantiating certain classes * by property name. * * @param target to apply source JSON properties into * @param source to be applied * @param params * @param params.path path for logging/error purposes, to aid with pinpointing problems * @param params.matcherPath path for pattern matching, to lookup allowedTypes override. * @param params.skip property names to skip from the source * @param params.constructedArrays map stores arrays which items should be initialised using a class constructor */ export declare function jsonApply<Target extends object, Source extends DeepPartial<Target>>(target: Target, source?: Source, params?: { path?: string; matcherPath?: string; skip?: string[]; }): Target; /** * Resolve logical operations within a json object. * * @param source JSON object to walk and onto which to apply the resolved values. * @param params An object of parameters to use with the `$ref` operation. * @param skip (optional) A set of keys to skip processing * @param context (optional) A JSON object that is used as the context for operations, e.g. `$path` * * @returns An object of modified paths. */ export declare function jsonResolveOperations<T extends object, P extends object>(source: T, params: P, skip?: Set<string>, context?: T): Record<string, any>; export {};