UNPKG

@tanstack/db

Version:

A reactive client store for building super fast apps on sync

68 lines (67 loc) • 3.29 kB
import { CompareOptions } from '../query/builder/types.cjs'; /** * Whether a value has no IEEE-754 natural order: `NaN`, or an invalid Date * (whose timestamp is `NaN`). The query engine follows PostgreSQL float * semantics for these values — they are all equal to one another and greater * than every other (non-null) value — so the comparator and the WHERE * evaluator treat them explicitly instead of letting `NaN` compare unequal to * everything (which has no consistent order and cannot be indexed or sorted). */ export declare function isUnorderable(value: any): boolean; /** * Universal comparison function for all data types * Handles null/undefined, strings, arrays, dates, objects, and primitives * Always sorts null/undefined values first */ export declare const ascComparator: (a: any, b: any, opts: CompareOptions) => number; /** * Descending comparator function for ordering values * Handles null/undefined as largest values (opposite of ascending) */ export declare const descComparator: (a: unknown, b: unknown, opts: CompareOptions) => number; export declare function indexObjectKind(value: any): string; export declare function makeComparator(opts: CompareOptions, scope?: `values` | `index`): (a: any, b: any) => number; /** * Wraps a user comparator so an index crashes on a result that cannot order * its storage, instead of silently misplacing rows. */ export declare function makeCheckedComparator(compareFn: (a: any, b: any) => number): (a: any, b: any) => number; /** Default comparator orders values in ascending order with nulls first and locale string comparison. */ export declare const defaultComparator: (a: any, b: any) => number; /** Include host Buffers when the current realm has a different Uint8Array. */ export declare function isUint8Array(value: unknown): value is Uint8Array; /** * Normalize a value for comparison and Map key usage * Converts values that can't be directly compared or used as Map keys * into comparable primitive representations */ export declare function normalizeValue(value: any): any; /** * Compare values using the equality semantics used by Map keys. */ export declare function areSameValueZeroEqual(a: unknown, b: unknown): boolean; /** * Compare two Temporal values of the same type, returning -1, 0, or 1. * * The tags check type agreement. Types without a static `.compare` (e.g. * `PlainMonthDay`) throw instead of using text order. * * Callers must ensure both arguments are Temporal objects; mixed types throw. */ export declare function compareTemporalValues(a: unknown, b: unknown): number; /** * Order two non-null values, returning -1, 0, or 1. * * Temporal types intentionally throw from `valueOf` to prevent silent * miscomparison via the native relational operators — delegate to * `compareTemporalValues` for them. For everything else (numbers, strings, * Dates via `valueOf`, etc.) the native operators do the right thing. * * Callers must handle null/undefined themselves — this helper assumes both * arguments are non-null. */ export declare function compareValues(a: unknown, b: unknown): number; /** * Compare two values for equality, with special handling for Uint8Arrays and Buffers */ export declare function areValuesEqual(a: any, b: any): boolean;