mirror of
https://github.com/morluto/rea
synced 2026-10-26 06:16:17 -04:00
392f1f3107
Share parser modes and collision-free composite keys, enforce architecture guards, and consolidate redundant unit assertions into filesystem, CLI, MCP, and producer-backed workflows. Preserve concurrent upstream boundary fixes and exclude legacy Objective-C class-name bookkeeping labels. Validation: source/composition suites (3358 passing), focused canonical digest and MCP checks, typecheck/lint, Knip, formatting, architecture guards, and real Foundation archive and Apple legacy simulator CLI/MCP verification. No real Hopper, Ghidra, or IDA verification claim.
27 lines
1.0 KiB
TypeScript
27 lines
1.0 KiB
TypeScript
/** Compare strings lexicographically by Unicode code point, independent of locale. */
|
|
export const compareUnicodeCodePoints = (
|
|
left: string,
|
|
right: string,
|
|
): number => {
|
|
let leftIndex = 0;
|
|
let rightIndex = 0;
|
|
while (leftIndex < left.length && rightIndex < right.length) {
|
|
const leftPoint = left.codePointAt(leftIndex) ?? 0;
|
|
const rightPoint = right.codePointAt(rightIndex) ?? 0;
|
|
const difference = leftPoint - rightPoint;
|
|
if (difference !== 0) return difference;
|
|
leftIndex += leftPoint > 0xffff ? 2 : 1;
|
|
rightIndex += rightPoint > 0xffff ? 2 : 1;
|
|
}
|
|
if (leftIndex === left.length && rightIndex === right.length) return 0;
|
|
return leftIndex === left.length ? -1 : 1;
|
|
};
|
|
|
|
/**
|
|
* Collision-free composite key for deduplication/sorting. `\0`-joins
|
|
* collide when any component contains NUL (valid in JS property names);
|
|
* a JSON tuple escapes every component. Single owner for composite keys.
|
|
*/
|
|
export const compositeKey = (parts: readonly unknown[]): string =>
|
|
JSON.stringify(parts);
|