refactor(domain): reuse canonical ordering and digest owners

This commit is contained in:
morluto committed 2026-10-22 14:04:28 +08:00
1 parent c537c52c96
commit 51be954c4b
6 files changed
+37 -55

No files matched your search

@@ -1,3 +1,4 @@
import { uniqueSortedBy } from "../canonicalOrdering.js";
import * as t from "@babel/types";
import { RETURNED_REFERENCE_WIDENING_LIMITATION } from "./javascriptSemanticCoverage.js";
import { collectElectronWrappedCallPaths } from "./electronWrappedCallPaths.js";
@@ -20,7 +21,6 @@ import {
detectVendors,
failedJavaScriptStaticAnalysis,
registrationKey,
sortedUnique,
stringValue,
} from "./javascriptStaticAnalysisHelpers.js";
import {
@@ -218,7 +218,7 @@ const finalizeStaticAnalysis = (
accumulator.storage,
accumulator.moduleRangeIndex,
),
bundler_registrations: sortedUnique(
bundler_registrations: uniqueSortedBy(
accumulator.registrations,
registrationKey,
),
@@ -829,15 +829,6 @@ export const registrationKey = (
]),
]);
/** Sort values by a deterministic unique semantic key. */
export const sortedUnique = <Value>(
values: readonly Value[],
key: (value: Value) => string,
): Value[] =>
[...new Map(values.map((value) => [key(value), value])).values()].sort(
(left, right) => compareUnicodeCodePoints(key(left), key(right)),
);
/** Hash exact UTF-8 source text. */
export const sha256Text = (value: string): string =>
createHash("sha256").update(value).digest("hex");