@tanstack/db
Version:
A reactive client store for building super fast apps on sync
60 lines (59 loc) • 2.22 kB
text/typescript
import { CompareOptions } from './query/builder/types.cjs';
/**
* 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 implementation with cycle detection to prevent infinite recursion.
* Internal callers can seed already-paired roots when comparing their children.
*/
export declare function deepEqualsInternal(a: any, b: any, 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`;
}>;
/**
* Log a warning message only once per unique key.
* Subsequent calls with the same key will be silently ignored.
*
* @internal Used by first-party collection adapters.
*
* @param key - Unique identifier for this warning
* @param message - The warning message to display
*
* @example
* ```typescript
* // First call logs the warning
* warnOnce('deprecated-api', 'This API is deprecated')
*
* // Subsequent calls with same key are ignored
* warnOnce('deprecated-api', 'This API is deprecated') // silent
* ```
*/
export declare function warnOnce(key: string, message: string): void;
/**
* Reset all warning states. Primarily useful for testing.
*
* @internal Used by first-party collection adapter tests.
*/
export declare function resetWarnings(): void;