MCPcopy Index your code
hub / github.com/TanStack/db / compareKeys

Function compareKeys

packages/db-ivm/src/utils.ts:185–194  ·  view source on GitHub ↗
(a: string | number, b: string | number)

Source from the content-addressed store, hash-verified

183 * Handles mixed types by ordering strings before numbers.
184 */
185export function compareKeys(a: string | number, b: string | number): number {
186 // Same type: compare directly
187 if (typeof a === typeof b) {
188 if (a < b) return -1
189 if (a > b) return 1
190 return 0
191 }
192 // Different types: strings come before numbers
193 return typeof a === `string` ? -1 : 1
194}
195
196/**
197 * Serializes a value for use as a key, handling BigInt and Date values that JSON.stringify cannot handle.

Callers 2

indexOfMethod · 0.90
createKeyedComparatorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…