refactor(javascript): group domain semantics and contracts (#907)

This commit is contained in:
ysopwnable authored and GitHub committed 2026-10-07 17:16:58 +08:00
1 parent d5f28fb29c
commit f6a58f1062
253 files changed
+432 -410

No files matched your search

@@ -0,0 +1,17 @@
import { createHash } from "node:crypto";
import canonicalize from "canonicalize";
/** Canonically encode one export-shape comparison value. */
export const canonicalExportShapeValue = (value: unknown): string => {
const encoded = canonicalize(value);
if (encoded === undefined)
throw new TypeError(
"JavaScript export shape comparison could not canonicalize data",
);
return encoded;
};
/** Derive one deterministic SHA-256 comparison identifier component. */
export const digestExportShapeValue = (value: unknown): string =>
createHash("sha256").update(canonicalExportShapeValue(value)).digest("hex");