@tanstack/db
Version:
A reactive client store for building super fast apps on sync
39 lines (38 loc) • 1.04 kB
JavaScript
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));
}
export {
VIRTUAL_PROP_NAMES,
enrichRowWithVirtualProps,
hasVirtualPropPath,
hasVirtualProps,
isVirtualPropName
};
//# sourceMappingURL=virtual-props.js.map