Query
Query helpers over an existing DiffResult (does not re-run diff).
Previous: Merge · Next: Statistics
Import path
ts
import { find, filter, exclude, paths, summary, ofType, query } from "@jayoncode/object-diff/query";Not on the root entry — Engines. Root added / removed / updated / unchanged still take (a, b) and re-diff.
Free functions
ts
const result = diff(before, after);
find(result, (r) => r.path.startsWith("user."));
filter(result, (r) => r.type === "changed"); // → DiffResult
exclude(result, ["password", "meta.*"]); // globs + prefix for non-globs
exclude(result, (r) => r.type === "added");
paths(result); // string[]
summary(result); // { total, added, removed, changed, unchanged, moved }
ofType(result, "moved");Fluent query
ts
query(result).exclude(["password"]).updated().paths();
query(result).added().summary();Pure — never mutates the input DiffResult.
Pitfalls
- Query operates on an existing DiffResult; it does not call
diffagain. - For richer metrics use
/stats→statistics(result), notsummaryalone.
Related
- Richer metrics:
@jayoncode/object-diff/stats→statistics(result) - Fluent + explain/serialize/patch/stats: DX / createDiffView
- Engines
