( row: T, key: TKey, collectionId: string, computeSynced: () => boolean, computeOrigin: () => VirtualOrigin, )
| 199 | * @internal |
| 200 | */ |
| 201 | export function enrichRowWithVirtualProps< |
| 202 | T extends object, |
| 203 | TKey extends string | number, |
| 204 | >( |
| 205 | row: T, |
| 206 | key: TKey, |
| 207 | collectionId: string, |
| 208 | computeSynced: () => boolean, |
| 209 | computeOrigin: () => VirtualOrigin, |
| 210 | ): WithVirtualProps<T, TKey> { |
| 211 | // Use nullish coalescing to preserve existing virtual properties (pass-through) |
| 212 | // This is the "add-if-missing" pattern described in the RFC |
| 213 | const existingRow = row as Partial<VirtualRowProps<TKey>> |
| 214 | |
| 215 | return { |
| 216 | ...row, |
| 217 | $synced: existingRow.$synced ?? computeSynced(), |
| 218 | $origin: existingRow.$origin ?? computeOrigin(), |
| 219 | $key: existingRow.$key ?? key, |
| 220 | $collectionId: existingRow.$collectionId ?? collectionId, |
| 221 | } as WithVirtualProps<T, TKey> |
| 222 | } |
| 223 | |
| 224 | /** |
| 225 | * Computes aggregate virtual properties for a group of rows. |
no outgoing calls
no test coverage detected