refactor(domain): consolidate canonical ordering and digest helpers (#624)
* refactor(domain): consolidate canonical ordering and digest helpers Single owner for code-point ordering (domain/canonicalOrdering.ts) and canonical JSON digests (domain/comparisonSemantics.ts). Delete all local compareCodePoints/compareText/digestCanonical duplicates and migrate every importer. No re-export shims. * fix(ci): allow slower real browser startup
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { uniqueSorted } from "../domain/canonicalOrdering.js";
|
||||
import type { AnalysisOperationPort } from "../application/AnalysisProvider.js";
|
||||
import type { BinarySessionPort } from "../application/BinarySession.js";
|
||||
import type { PromptCompletionKind } from "../contracts/promptContracts.js";
|
||||
@@ -41,7 +42,8 @@ export const createPromptCompletionSource = (
|
||||
context,
|
||||
);
|
||||
const prefix = normalize(value);
|
||||
return uniqueSorted(candidates).filter((candidate) =>
|
||||
const nonEmpty = candidates.filter((candidate) => candidate.length > 0);
|
||||
return uniqueSorted(nonEmpty).filter((candidate) =>
|
||||
normalize(candidate).startsWith(prefix),
|
||||
);
|
||||
},
|
||||
@@ -182,11 +184,5 @@ const unknownCandidates = (
|
||||
.filter(({ status }) => status !== "resolved")
|
||||
.map(({ unknown_id: id }) => id);
|
||||
|
||||
const uniqueSorted = (values: readonly string[]): string[] =>
|
||||
[...new Set(values.filter((value) => value.length > 0))].sort(compareText);
|
||||
|
||||
const compareText = (left: string, right: string): number =>
|
||||
left < right ? -1 : left > right ? 1 : 0;
|
||||
|
||||
const normalize = (value: string): string =>
|
||||
value.normalize("NFKC").toLowerCase();
|
||||
|
||||
Reference in New Issue
Block a user