@finnair/diff
Version:
Object Diff Based on Paths And Valudes of an Object
28 lines (27 loc) • 915 B
TypeScript
import { Node, Path } from '@finnair/path';
export declare const defaultDiffFilter: (_path: Path, value: any) => boolean;
export interface DiffConfig {
readonly filter?: DiffFilter;
readonly isPrimitive?: (value: any, path: Path) => boolean;
readonly isEqual?: (a: any, b: any, path: Path) => boolean;
readonly includeObjects?: boolean;
}
export interface DiffFilter {
(path: Path, value: any): boolean;
}
export interface Change {
readonly path: Path;
readonly oldValue?: any;
readonly newValue?: any;
}
export declare class Diff {
private readonly config?;
constructor(config?: DiffConfig | undefined);
allPaths(value: any): Set<string>;
changedPaths<T>(a: T, b: T): Set<string>;
changeset<T>(a: T, b: T): Map<string, Change>;
pathsAndValues(value: any): Map<string, Node>;
private collectPathsAndValues;
private isEqual;
private getNewValue;
}