Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

compareTemporalValues.md

34 lines819 Bytes

1---
2id: compareTemporalValues
3title: compareTemporalValues
4---
5​
6```ts
7function compareTemporalValues(a, b): number;
8```
9​
10Defined in: [packages/db/src/utils/comparison.ts:313](https://github.com/TanStack/db/blob/main/packages/db/src/utils/comparison.ts#L313)
11​
12Compare two Temporal values of the same type, returning -1, 0, or 1.
13​
14Dispatch is keyed on `Symbol.toStringTag` (the brand already checked by
15`isTemporal`) rather than `a.constructor`, making it robust across realms
16and resistant to a shadowed `constructor` property. Types without a static
17`.compare` (e.g. `PlainMonthDay`) throw rather than fall back to string
18comparison, matching Temporal's design intent.
19​
20Callers must ensure both arguments are Temporal objects; mixed types throw.
21​
22## Parameters
23​
24### a
25​
26`unknown`
27​
28### b
29​
30`unknown`
31​
32## Returns
33​
34`number`