@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
30 lines • 1.5 kB
TypeScript
/**
* Order two strings by Unicode code point, the way Python's `sorted` does.
*
* JavaScript's default comparator compares UTF-16 code *units*. Astral
* characters (U+10000 and up) are stored as a surrogate pair in
* 0xD800-0xDFFF, so they sort before every BMP character from U+E000 up —
* while Python puts them after. A directory holding `\u{1F600}.txt` and a
* U+E000 name therefore lists in opposite orders across the two trees, and
* any listing compared against a shared integ truth file diverges. See
* issue #370.
*
* There is no Python counterpart because `sorted()` is already code-point
* ordered; this is the module that makes TypeScript agree with it. Use it
* for anything a user can see the order of. eslint bans the zero-argument
* default comparator outright so it cannot creep back.
*/
export declare function compareCodePoints(a: string, b: string): number;
/**
* Order two `/`-separated paths component by component, each compared by
* code point, so a path sorts right after its parent the way Python's
* `sorted(key=lambda p: p.split("/"))` and a sorted readdir walk put it.
*/
export declare function compareComponents(a: string, b: string): number;
/**
* JSON with each object's keys in code-point order, the key order of
* Python's `json.dumps(value, sort_keys=True)`, so an encoded checkpoint does
* not depend on the order its maps were filled in.
*/
export declare function sortedJson(value: unknown): string;
//# sourceMappingURL=sort.d.ts.map