mirror of
https://github.com/morluto/rea.git
synced 2026-11-10 00:36:35 +00:00
Remove forwarding wrappers and shadow aliases, migrate callers and verification scripts to their owners, and share one exhaustive semantic resource-bound projection.
23 lines
743 B
TypeScript
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;
|
|
};
|