UNPKG

@tanstack/db

Version:

A reactive client store for building super fast apps on sync

38 lines (37 loc) • 1.17 kB
function hasVirtualProps(value) { return typeof value === "object" && value !== null && [ "$hasPendingWrites", "$origin", "$key", "$collectionId" ].every((name) => name in value); } function enrichRowWithVirtualProps(row, key, collectionId, computePendingWrites, computeOrigin) { const existingRow = row; const hasPendingWrites = existingRow.$hasPendingWrites ?? computePendingWrites(); return { ...row, $hasPendingWrites: hasPendingWrites, $origin: existingRow.$origin ?? computeOrigin(), $key: existingRow.$key ?? key, $collectionId: existingRow.$collectionId ?? collectionId }; } var VIRTUAL_PROP_NAMES = [ "$hasPendingWrites", "$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