(list: T[], item: T)
| 261 | } |
| 262 | |
| 263 | function upsert<T extends { id: string }>(list: T[], item: T) { |
| 264 | const idx = list.findIndex((entry) => entry.id === item.id) |
| 265 | if (idx === -1) { |
| 266 | list.push(item) |
| 267 | return |
| 268 | } |
| 269 | |
| 270 | list[idx] = item |
| 271 | } |
| 272 | |
| 273 | function remove(list: Array<{ id: string }>, id: string): boolean { |
| 274 | const idx = list.findIndex((entry) => entry.id === id) |
no test coverage detected