( changes: Iterable<ChangeMessage<T, TKey>>, )
| 305 | |
| 306 | /** Splits updates into a delete of the old value and an insert of the new value */ |
| 307 | export function* splitUpdates< |
| 308 | T extends object = Record<string, unknown>, |
| 309 | TKey extends string | number = string | number, |
| 310 | >( |
| 311 | changes: Iterable<ChangeMessage<T, TKey>>, |
| 312 | ): Generator<ChangeMessage<T, TKey>> { |
| 313 | for (const change of changes) { |
| 314 | if (change.type === `update`) { |
| 315 | yield { type: `delete`, key: change.key, value: change.previousValue! } |
| 316 | yield { type: `insert`, key: change.key, value: change.value } |
| 317 | } else { |
| 318 | yield change |
| 319 | } |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | /** |
| 324 | * Filter changes to prevent duplicate inserts to a D2 pipeline. |
no outgoing calls
no test coverage detected