| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Typed deep object diffing with array identity support and change reconstruction.
Compare any two objects or arrays and get a precise, typed list of changes. Supports nested structures, array identity (keyBy), and bi-directional reconstruction—apply changes forward or reverse them for undo. Useful for auditing, state machines, and incremental sync.
export function diff(a: unknown, b: unknown, opts?: {keyBy?: string}): Change[]
export function apply(a: unknown, changes: Change[], opts?: ApplyOptions): unknown
export function reverse(changes: Change[]): Change[]
interface Change {
path: string
type: 'added' | 'removed' | 'changed'
before?: unknown
after?: unknown
}npm install @ferrow/object-diff-tsimport { diff, apply, reverse } from 'object-diff-ts';
const a = { user: 'Alice', age: 30, tags: ['admin'] };
const b = { user: 'Alice', age: 31, tags: ['admin', 'verified'] };
const changes = diff(a, b);
// => [
// { path: 'age', type: 'changed', before: 30, after: 31 },
// { path: 'tags.[1]', type: 'added', before: undefined, after: 'verified' }
// ]
const reconstructed = apply(a, changes);
// reconstructed === b (in value)
const undone = apply(b, reverse(changes));
// undone === a (in value)Part of the ferrow-toolkit collection · Sponsored by Ferrow
| Back | FazBrowse Home | New Git URL |