Skip to content
v0.4.1

Object Diff

@jayoncode/object-diff

Stop guessing what changed. Get paths, patches, and review-ready output.

Typed deep comparison with path-aware records, fast dirty checks, DiffView explain, RFC 6902 patches, and optional snapshot merge — not a CRDT runtime.

Spot the edit — explain it — apply the patch

import { diff, hasChanges, patch, applyPatch } from "@jayoncode/object-diff";
import { createDiffView } from "@jayoncode/object-diff/view";

const saved = {
  profile: { name: "Ada", role: "admin" },
  prefs: { theme: "dark" },
};
const draft = {
  profile: { name: "Ada Lovelace", role: "admin" },
  prefs: { theme: "dark" },
};

if (hasChanges(saved, draft)) {
  const view = createDiffView(diff(saved, draft));
  await audit.log(view.explain({ format: "human" }));
  const synced = applyPatch(saved, view.patch());
}
Read the overview

Why it stands out

Typed deep diff

Path-aware records for objects, arrays, Dates, Maps, and Sets — plus ignore / include.

Intuitive moves & dirty checks

detectMoves for reorders; hasChanges for cheap dirty flags without a full DiffResult.

DiffView toolbox

createDiffView(result).explain() turns moves and edits into review-ready structured or human text.

RFC 6902 patches

Generate, validate, apply, and inverse patches for optimistic UI and audit trails.

Snapshot merge

Optional /merge with identity-aware lists and structured conflicts — not live collab.

An ecosystem of independent, headless TypeScript libraries engineered for modern web development. Every package includes interactive playgrounds and documentation that evolves alongside the code.