autotel
Version:
Write Once, Observe Anywhere
21 lines (19 loc) • 688 B
JavaScript
import { createHash } from 'crypto';
// src/stable-hash.ts
function stableStringify(value) {
if (value === null || value === void 0 || typeof value !== "object") {
return JSON.stringify(value);
}
if (Array.isArray(value)) {
return "[" + value.map((v) => stableStringify(v)).join(",") + "]";
}
const obj = value;
const body = Object.keys(obj).toSorted().map((k) => JSON.stringify(k) + ":" + stableStringify(obj[k])).join(",");
return "{" + body + "}";
}
function hashJson(value) {
return createHash("sha256").update(stableStringify(value)).digest("hex");
}
export { hashJson };
//# sourceMappingURL=chunk-UNPLAVE7.js.map
//# sourceMappingURL=chunk-UNPLAVE7.js.map