UNPKG

@tanstack/db

Version:

A reactive client store for building super fast apps on sync

57 lines (56 loc) • 2.43 kB
import { CompareOptions } from './query/builder/types.cjs'; 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 Compare persisted public and durable value shapes before skipping a reload. */ export declare function equalPersistedSnapshotValues(a: unknown, b: unknown): boolean; /** * Internal implementation with cycle detection to prevent infinite recursion. * Internal callers can seed already-paired roots when comparing their children. * * `draft` selects 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). * `persistedSnapshot` also distinguishes prototypes after serialization. */ export declare function deepEqualsInternal(a: any, b: any, visited: Map<object, object> | undefined, draft?: boolean, persistedSnapshot?: boolean): 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;