MCPcopy Create free account
hub / github.com/codemix/graph / getTypeOrder

Function getTypeOrder

packages/graph/src/Comparator.ts:29–37  ·  view source on GitHub ↗

* Type ordering for deterministic cross-type comparisons: * undefined < null < boolean < number < string < object * * When comparing values of different types that cannot be coerced, * this ordering is used to provide stable, predictable results.

(value: unknown)

Source from the content-addressed store, hash-verified

27 * this ordering is used to provide stable, predictable results.
28 */
29function getTypeOrder(value: unknown): number {
30 if (value === undefined) return 0;
31 if (value === null) return 1;
32 if (typeof value === "boolean") return 2;
33 if (typeof value === "number") return 3;
34 if (typeof value === "string") return 4;
35 if (typeof value === "object") return 5;
36 return 6; // symbol, function, bigint, etc.
37}
38
39/**
40 * Compares two values and returns a number indicating their relative order.

Callers 1

compareFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected