@tanstack/db
Version:
A reactive client store for building super fast apps on sync
1 lines • 19.3 kB
Source Map (JSON)
{"version":3,"file":"utils.cjs","names":["UndefinedKeyError","InvalidKeyError","result"],"sources":["../../src/utils.ts"],"sourcesContent":["/**\n * Generic utility functions\n */\n\nimport { InvalidKeyError, UndefinedKeyError } from './errors'\nimport type { CompareOptions } from './query/builder/types'\n\ninterface TypedArray {\n length: number\n [index: number]: number\n every: (predicate: (value: number, index: number) => boolean) => boolean\n}\n\nexport const durationFields = [\n `years`,\n `months`,\n `weeks`,\n `days`,\n `hours`,\n `minutes`,\n `seconds`,\n `milliseconds`,\n `microseconds`,\n `nanoseconds`,\n] as const\nexport type DurationFields = Record<(typeof durationFields)[number], number>\n\n/**\n * Deep equality function that compares two values recursively\n * Handles primitives, objects, arrays, Date, RegExp, Map, Set, TypedArrays, and Temporal objects\n * Plain records can compare by keys with keyed class instances and records from other realms.\n *\n * @param a - First value to compare\n * @param b - Second value to compare\n * @returns True if the values are deeply equal, false otherwise\n *\n * @example\n * ```typescript\n * deepEquals({ a: 1, b: 2 }, { b: 2, a: 1 }) // true (property order doesn't matter)\n * deepEquals([1, { x: 2 }], [1, { x: 2 }]) // true\n * deepEquals({ a: 1 }, { a: 2 }) // false\n * deepEquals(new Date('2023-01-01'), new Date('2023-01-01')) // true\n * deepEquals(new Map([['a', 1]]), new Map([['a', 1]])) // true\n * ```\n */\nexport function deepEquals(a: any, b: any): boolean {\n return deepEqualsInternal(a, b)\n}\n\n/**\n * @internal Whether a synced row changed observably: deep equality that\n * tells -0 from 0 and preserves record prototypes, as public row values do.\n * Maintainer decisions: FID-1, 2026-10-29; record shape, 2026-11-03.\n */\nexport function sameRowValue(a: unknown, b: unknown): boolean {\n return deepEqualsInternal(a, b, ROW)\n}\n\n/**\n * @internal Whether an ordered Effect's update repeats its previous\n * publication: row-value equality, except that a class instance equals only\n * itself, since it can hold readable state outside its enumerable fields\n * (maintainer decision 2026-11-02).\n */\nexport function samePublishedValue(a: unknown, b: unknown): boolean {\n return deepEqualsInternal(a, b, ROW | PUBLICATION)\n}\n\n/** @internal Compare persisted public and durable value shapes before skipping a reload. */\nexport function equalPersistedSnapshotValues(a: unknown, b: unknown): boolean {\n return deepEqualsInternal(a, b, DRAFT | PERSISTED)\n}\n\nfunction isPlainPrototype(prototype: object | null): boolean {\n return prototype === null || Object.getPrototypeOf(prototype) === null\n}\n\nfunction enumerableOwnKeys(value: object): Array<string | symbol> {\n const keys: Array<string | symbol> = Object.keys(value)\n for (const key of Object.getOwnPropertySymbols(value)) {\n if (Object.prototype.propertyIsEnumerable.call(value, key)) keys.push(key)\n }\n return keys\n}\n\n// The comparison modes of `deepEqualsInternal`, combined as bits.\n/**\n * The stricter equality used by change-tracking drafts: Map and Set contents\n * must match in order, RegExp match position must match, and arrays compare\n * as keyed objects (holes and extra enumerable keys count).\n */\nexport const DRAFT = 1\n/** Persisted snapshots also distinguish prototypes after serialization. */\nconst PERSISTED = 2\n/** Row change detection tells -0 from 0; general equality does not. */\nexport const ROW = 4\n/** An ordered Effect's publication also compares a class instance by identity. */\nconst PUBLICATION = 8\n\n/**\n * Internal implementation with cycle detection to prevent infinite recursion.\n * Internal callers can seed already-paired roots when comparing their children.\n *\n * `mode` combines the bits above; one recursive call forwards all of them.\n */\nexport function deepEqualsInternal(\n a: any,\n b: any,\n mode = 0,\n // Created on the first container that descends into a child.\n visited?: Map<object, object>,\n): boolean {\n const draft = mode & DRAFT\n // Handle strict equality (primitives, same reference); a row value tells\n // -0 from 0.\n if ((!(mode & ROW) && a === b) || Object.is(a, b)) return true\n\n // Handle null/undefined\n if (a == null || b == null) return false\n\n // Handle different types\n if (typeof a !== typeof b) return false\n\n // SQLite can turn an authored nested instance into an equal-keyed plain\n // record. A skipped persisted reload must not retain the old public shape.\n if (\n mode & PERSISTED &&\n typeof a === `object` &&\n Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)\n ) {\n return false\n }\n\n // A container already paired in this comparison closes a cycle: it equals\n // only its partner.\n if (visited?.has(a)) return visited.get(a) === b\n\n // Handle Date objects\n if (a instanceof Date) {\n if (!(b instanceof Date)) return false\n return Object.is(a.getTime(), b.getTime())\n }\n // Symmetric check: if b is Date but a is not, they're not equal\n if (b instanceof Date) return false\n\n // Handle RegExp objects\n if (a instanceof RegExp) {\n if (!(b instanceof RegExp)) return false\n return (\n a.source === b.source &&\n a.flags === b.flags &&\n (!draft || a.lastIndex === b.lastIndex)\n )\n }\n // Symmetric check: if b is RegExp but a is not, they're not equal\n if (b instanceof RegExp) return false\n\n // Handle Map objects - only if both are Maps\n if (a instanceof Map) {\n if (!(b instanceof Map)) return false\n if (a.size !== b.size) return false\n ;(visited ??= new Map()).set(a, b)\n\n // A draft compares entries in order; general equality looks keys up.\n const bEntries = draft && Array.from(b.entries())\n const result = Array.from(a.entries()).every(([key, val], index) =>\n bEntries\n ? Object.is(key, bEntries[index]![0]) &&\n deepEqualsInternal(val, bEntries[index]![1], mode, visited)\n : b.has(key) && deepEqualsInternal(val, b.get(key), mode, visited),\n )\n\n visited.delete(a)\n return result\n }\n // Symmetric check: if b is Map but a is not, they're not equal\n if (b instanceof Map) return false\n\n // Handle Set objects - only if both are Sets\n if (a instanceof Set) {\n if (!(b instanceof Set)) return false\n if (a.size !== b.size) return false\n ;(visited ??= new Map()).set(a, b)\n\n // Convert to arrays for comparison\n const aValues = Array.from(a)\n const bValues = Array.from(b)\n\n if (draft) {\n // A draft compares contents in order, as it compares arrays.\n const result = deepEqualsInternal(aValues, bValues, mode, visited)\n visited.delete(a)\n return result\n }\n\n // Simple comparison for primitive values\n if (aValues.every((val) => typeof val !== `object`)) {\n visited.delete(a)\n return aValues.every((val) => b.has(val))\n }\n\n // A paired equality is already a bijection. Keep common equal inputs linear.\n if (\n aValues.every((value, index) =>\n deepEqualsInternal(value, bValues[index], mode, visited),\n )\n ) {\n visited.delete(a)\n return true\n }\n\n // Recursive comparisons remove their own pairs before returning. Reuse the\n // ancestor map; only failed assignments need augmenting-path search.\n const candidates = aValues.map((value) =>\n bValues.flatMap((candidate, index) =>\n deepEqualsInternal(value, candidate, mode, visited) ? [index] : [],\n ),\n )\n const assigned = new Map<number, number>()\n const match = (index: number, seen: Set<number>): boolean => {\n const options = candidates[index]!\n const free = options.find((candidate) => !assigned.has(candidate))\n if (free !== undefined) {\n assigned.set(free, index)\n return true\n }\n return options.some((candidate) => {\n if (seen.has(candidate)) return false\n seen.add(candidate)\n const previous = assigned.get(candidate)\n if (previous !== undefined && !match(previous, seen)) return false\n assigned.set(candidate, index)\n return true\n })\n }\n const result = aValues.every((_, index) => match(index, new Set()))\n visited.delete(a)\n return result\n }\n // Symmetric check: if b is Set but a is not, they're not equal\n if (b instanceof Set) return false\n\n // Handle TypedArrays. A typed array is its own value class: it equals only\n // another typed array, in both directions.\n const typed = ArrayBuffer.isView(a) && !(a instanceof DataView)\n if (typed !== (ArrayBuffer.isView(b) && !(b instanceof DataView))) {\n return false\n }\n if (typed) {\n const typedA = a as unknown as TypedArray\n const typedB = b as unknown as TypedArray\n // Elements compare as the numbers they are: NaN equals NaN, and -0\n // equals 0 except as a row value. Only a draft treats a change of\n // typed-array class as a change.\n return (\n (!draft || Object.getPrototypeOf(a) === Object.getPrototypeOf(b)) &&\n typedA.length === typedB.length &&\n typedA.every((x, i) => deepEqualsInternal(x, typedB[i], mode))\n )\n }\n\n // Handle Temporal objects\n // Check if both are Temporal objects of the same type\n if (isTemporal(a) && isTemporal(b)) {\n const aTag = a[Symbol.toStringTag]\n const bTag = b[Symbol.toStringTag]\n\n // If they're different Temporal types, they're not equal\n if (aTag !== bTag) return false\n\n // Duration identity preserves its fields, even when toString normalizes\n // different units to the same elapsed time.\n if (aTag === `Temporal.Duration`) {\n const durationA = a as unknown as DurationFields\n const durationB = b as unknown as DurationFields\n return durationFields.every(\n (field) => durationA[field] === durationB[field],\n )\n }\n\n // Use Temporal's built-in equals method if available\n if (typeof a.equals === `function`) {\n return a.equals(b)\n }\n\n // Fallback to toString comparison for other types\n return a.toString() === b.toString()\n }\n // Symmetric check: if b is Temporal but a is not, they're not equal\n if (isTemporal(b)) return false\n\n // Handle arrays\n if (Array.isArray(a) !== Array.isArray(b)) return false\n if (Array.isArray(a) && a.length !== b.length) return false\n if (Array.isArray(a) && !draft) {\n ;(visited ??= new Map()).set(a, b)\n\n let result = true\n for (let index = 0; index < a.length; index++) {\n if (!deepEqualsInternal(a[index], b[index], mode, visited)) {\n result = false\n break\n }\n }\n visited.delete(a)\n return result\n }\n // Handle objects\n if (typeof a === `object`) {\n // Row publication preserves record prototypes. Generic equality and draft\n // reconstruction keep their established plain-record/class bridge.\n const prototype = Object.getPrototypeOf(a)\n const prototypeB = Object.getPrototypeOf(b)\n const plain = isPlainPrototype(prototype)\n const plainB = isPlainPrototype(prototypeB)\n if (\n prototype !== prototypeB &&\n ((mode & ROW && !draft) || (!plain && !plainB))\n )\n return false\n if (mode & PUBLICATION && !(plain && plainB)) return false\n\n // Compare enumerable symbol keys as well as string keys. Query results may\n // use user-owned symbols, and a symbol-only update is still a value change.\n const keysA = enumerableOwnKeys(a)\n const keysB = enumerableOwnKeys(b)\n\n // Check if they have the same number of keys\n if (keysA.length !== keysB.length) return false\n\n // A class instance without enumerable keys (a File, an object with\n // private fields) keeps its state elsewhere, so it equals only itself.\n // A draft copies a URL by its href, so URLs compare by href.\n if (keysA.length === 0 && !Array.isArray(a) && !(plain && plainB)) {\n return a instanceof URL && a.href === b.href\n }\n\n // Check if all keys exist in both objects and their values are equal.\n // Register for cycles only before descending, so a flat object\n // allocates no cycle map.\n let registered = false\n let result = true\n for (const key of keysA) {\n const value = a[key]\n if (!registered && value !== null && typeof value === `object`) {\n ;(visited ??= new Map()).set(a, b)\n registered = true\n }\n if (\n !Object.prototype.propertyIsEnumerable.call(b, key) ||\n !deepEqualsInternal(value, b[key], mode, visited)\n ) {\n result = false\n break\n }\n }\n if (registered) visited!.delete(a)\n return result\n }\n\n // For primitives that aren't strictly equal\n return false\n}\n\nconst temporalTypes = new Set([\n `Temporal.Duration`,\n `Temporal.Instant`,\n `Temporal.PlainDate`,\n `Temporal.PlainDateTime`,\n `Temporal.PlainMonthDay`,\n `Temporal.PlainTime`,\n `Temporal.PlainYearMonth`,\n `Temporal.ZonedDateTime`,\n])\n\nexport interface TemporalLike {\n [Symbol.toStringTag]: string\n toString: () => string\n equals?: (other: unknown) => boolean\n}\n\n/** Checks if the value is a Temporal object by checking for the Temporal brand */\nexport function isTemporal(a: unknown): a is TemporalLike {\n if (a == null || typeof a !== `object`) return false\n const tag = (a as Record<symbol, unknown>)[Symbol.toStringTag]\n return typeof tag === `string` && temporalTypes.has(tag)\n}\n\nexport const DEFAULT_COMPARE_OPTIONS: Exclude<\n CompareOptions,\n { stringSort: `custom` }\n> = {\n direction: `asc`,\n nulls: `first`,\n stringSort: `locale`,\n}\n\n/** Throws unless a key has the Collection key type: a string or a number. */\nexport function assertCollectionKey(key: unknown, item: unknown): void {\n if (typeof key !== `string` && typeof key !== `number`) {\n throw key === undefined\n ? new UndefinedKeyError(item)\n : new InvalidKeyError(key, item)\n }\n}\n"],"mappings":";AAaA,IAAa,iBAAiB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAqBA,SAAgB,WAAW,GAAQ,GAAiB;CAClD,OAAO,mBAAmB,GAAG,CAAC;AAChC;AAOA,SAAgB,aAAa,GAAY,GAAqB;CAC5D,OAAO,mBAAmB,GAAG,GAAA,CAAM;AACrC;AAQA,SAAgB,mBAAmB,GAAY,GAAqB;CAClE,OAAO,mBAAmB,GAAG,GAAA,IAAS,WAAW;AACnD;AAGA,SAAgB,6BAA6B,GAAY,GAAqB;CAC5E,OAAO,mBAAmB,GAAG,GAAA,IAAW,SAAS;AACnD;AAEA,SAAS,iBAAiB,WAAmC;CAC3D,OAAO,cAAc,QAAQ,OAAO,eAAe,SAAS,MAAM;AACpE;AAEA,SAAS,kBAAkB,OAAuC;CAChE,MAAM,OAA+B,OAAO,KAAK,KAAK;CACtD,KAAA,MAAW,OAAO,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