UNPKG

datum-merge

Version:

Simplified diff and merging for deeply nested objects

63 lines 2.97 kB
export { type Diff }; export { type PreFilterFunction }; export { type PreFilterObject }; export { type Accumulator }; export { type Observer }; export { type DiffPath }; export { diff }; export { orderIndependentDiff }; export { accumulateDiff }; export { observableDiff }; export { orderIndependentDeepDiff }; export { applyChange, revertChange }; export { applyDiff }; export { realTypeOf }; export { getOrderIndependentHash }; type DiffNew<RHS> = { readonly kind: "N"; readonly path: any[]; readonly rhs: RHS; }; type DiffDeleted<LHS> = { readonly kind: "D"; readonly path: any[]; readonly lhs: LHS; }; type DiffEdit<LHS, RHS = LHS> = { readonly kind: "E"; readonly path: any[]; readonly lhs: LHS; readonly rhs: RHS; }; type DiffArray<LHS, RHS = LHS> = { readonly kind: "A"; readonly path: any[]; readonly index: number; readonly item: Diff<LHS, RHS>; }; type Diff<LHS, RHS = LHS> = DiffNew<RHS> | DiffDeleted<LHS> | DiffEdit<LHS, RHS> | DiffArray<LHS, RHS>; type PreFilterFunction = (path: any[], key: any) => boolean; type PreFilterObject<LHS, RHS = LHS> = { prefilter?(path: any[], key: any): boolean; normalize?(currentPath: any, key: any, lhs: LHS, rhs: RHS): [LHS, RHS] | false | undefined; }; type PreFilter<LHS, RHS = LHS> = PreFilterFunction | PreFilterObject<LHS, RHS>; type Filter<LHS, RHS = LHS> = (target: LHS, source: RHS, change: Diff<LHS, RHS>) => boolean; type Accumulator<LHS, RHS = LHS> = { push(diff: Diff<LHS, RHS>): void; length: number; }; type Observer<LHS, RHS = LHS> = (diff: Diff<LHS, RHS>) => void; type PathKey = string | number | symbol; type DiffPath = PathKey[]; declare function diff<LHS, RHS = LHS>(lhs: LHS, rhs: RHS, prefilter?: PreFilter<LHS, RHS>): readonly Diff<LHS, RHS>[] | undefined; declare function orderIndependentDiff<LHS, RHS = LHS>(lhs: LHS, rhs: RHS, prefilter?: PreFilter<LHS, RHS>): readonly Diff<LHS, RHS>[] | undefined; declare function observableDiff<LHS, RHS = LHS>(lhs: LHS, rhs: RHS, observer?: Observer<LHS, RHS>, prefilter?: PreFilter<LHS, RHS>, orderIndependent?: boolean): Array<Diff<LHS, RHS>>; declare function accumulateDiff<LHS, RHS = LHS>(lhs: LHS, rhs: RHS, prefilter?: PreFilter<LHS, RHS>, accum?: Accumulator<LHS, RHS>, orderIndependent?: boolean): Accumulator<LHS, RHS> | Diff<LHS, RHS>[] | undefined; declare function orderIndependentDeepDiff<LHS, RHS = LHS>(lhs: LHS, rhs: RHS, changes: Array<Diff<LHS, RHS>>, prefilter?: PreFilter<LHS, RHS>, path?: any[], key?: any, stack?: any[]): void; declare function applyDiff<LHS, RHS = LHS>(target: LHS, source: RHS, filter?: Filter<LHS, RHS>): LHS; declare function applyChange<LHS>(target: LHS, unused: any, change: Diff<LHS, any>): void; declare function revertChange<LHS>(target: LHS, unused: any, change: Diff<LHS, any>): void; declare function realTypeOf(val: any): string; declare function getOrderIndependentHash(val: any): number; //# sourceMappingURL=deep-diff.d.ts.map