UNPKG

@tanstack/db

Version:

A reactive client store for building super fast apps on sync

63 lines (62 loc) • 3.05 kB
import { CompareOptions } from './query/builder/types.js'; export declare const durationFields: readonly ["years", "months", "weeks", "days", "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds"]; export type DurationFields = Record<(typeof durationFields)[number], number>; /** * Deep equality function that compares two values recursively * Handles primitives, objects, arrays, Date, RegExp, Map, Set, TypedArrays, and Temporal objects * * @param a - First value to compare * @param b - Second value to compare * @returns True if the values are deeply equal, false otherwise * * @example * ```typescript * deepEquals({ a: 1, b: 2 }, { b: 2, a: 1 }) // true (property order doesn't matter) * deepEquals([1, { x: 2 }], [1, { x: 2 }]) // true * deepEquals({ a: 1 }, { a: 2 }) // false * deepEquals(new Date('2023-01-01'), new Date('2023-01-01')) // true * deepEquals(new Map([['a', 1]]), new Map([['a', 1]])) // true * ``` */ export declare function deepEquals(a: any, b: any): boolean; /** * @internal Whether a synced row changed observably: deep equality that * tells -0 from 0, as row values do (FID-1; maintainer decision 2026-10-29). */ export declare function sameRowValue(a: unknown, b: unknown): boolean; /** * @internal Whether an ordered Effect's update repeats its previous * publication: row-value equality, except that a class instance equals only * itself, since it can hold readable state outside its enumerable fields * (maintainer decision 2026-11-02). */ export declare function samePublishedValue(a: unknown, b: unknown): boolean; /** @internal Compare persisted public and durable value shapes before skipping a reload. */ export declare function equalPersistedSnapshotValues(a: unknown, b: unknown): boolean; /** * The stricter equality used by change-tracking drafts: Map and Set contents * must match in order, RegExp match position must match, and arrays compare * as keyed objects (holes and extra enumerable keys count). */ export declare const DRAFT = 1; /** Row change detection tells -0 from 0; general equality does not. */ export declare const ROW = 4; /** * Internal implementation with cycle detection to prevent infinite recursion. * Internal callers can seed already-paired roots when comparing their children. * * `mode` combines the bits above; one recursive call forwards all of them. */ export declare function deepEqualsInternal(a: any, b: any, mode?: number, visited?: Map<object, object>): boolean; export interface TemporalLike { [Symbol.toStringTag]: string; toString: () => string; equals?: (other: unknown) => boolean; } /** Checks if the value is a Temporal object by checking for the Temporal brand */ export declare function isTemporal(a: unknown): a is TemporalLike; export declare const DEFAULT_COMPARE_OPTIONS: Exclude<CompareOptions, { stringSort: `custom`; }>; /** Throws unless a key has the Collection key type: a string or a number. */ export declare function assertCollectionKey(key: unknown, item: unknown): void;