Files
reverse-engineering-anything/src/domain/comparisonSemantics.ts
T
morluto 765e809e36 refactor: use canonical implementations and types directly
Remove forwarding wrappers and shadow aliases, migrate callers and verification scripts to their owners, and share one exhaustive semantic resource-bound projection.
2026-10-09 23:35:19 +08:00

23 lines
743 B
TypeScript

import canonicalize from "canonicalize";
/** Whether an inventory can support a claim that an item is absent. */
export const absenceClaimable = (coverage: {
readonly status: string;
readonly truncated?: boolean;
readonly omitted_count?: number | null;
}): boolean =>
coverage.status === "complete" &&
coverage.truncated !== true &&
(coverage.omitted_count === undefined || coverage.omitted_count === 0);
/** Canonical JSON used for deterministic tie breaking and stable digests. */
export const canonicalJson = (
value: unknown,
context = "Comparison",
): string => {
const encoded = canonicalize(value);
if (encoded === undefined)
throw new TypeError(`${context} could not canonicalize data`);
return encoded;
};