UNPKG

@tanstack/db

Version:

A reactive client store for building super fast apps on sync

39 lines (38 loc) • 1.26 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); function hasVirtualProps(value) { return typeof value === "object" && value !== null && ["$synced", "$origin", "$key", "$collectionId"].every( (name) => name in value ); } function enrichRowWithVirtualProps(row, key, collectionId, computeSynced, computeOrigin) { const existingRow = row; const synced = existingRow.$synced ?? computeSynced(); return { ...row, $hasPendingWrites: !synced, $synced: synced, $origin: existingRow.$origin ?? computeOrigin(), $key: existingRow.$key ?? key, $collectionId: existingRow.$collectionId ?? collectionId }; } const VIRTUAL_PROP_NAMES = [ "$hasPendingWrites", "$synced", "$origin", "$key", "$collectionId" ]; function isVirtualPropName(name) { return VIRTUAL_PROP_NAMES.includes(name); } function hasVirtualPropPath(path) { return path.some((segment) => isVirtualPropName(segment)); } exports.VIRTUAL_PROP_NAMES = VIRTUAL_PROP_NAMES; exports.enrichRowWithVirtualProps = enrichRowWithVirtualProps; exports.hasVirtualPropPath = hasVirtualPropPath; exports.hasVirtualProps = hasVirtualProps; exports.isVirtualPropName = isVirtualPropName; //# sourceMappingURL=virtual-props.cjs.map