Lazily copy items + itemsById on first mutation so callers get new refs.
(d: TranscriptDraft)
| 98 | |
| 99 | /** Lazily copy items + itemsById on first mutation so callers get new refs. */ |
| 100 | function ensureMutable(d: TranscriptDraft) { |
| 101 | if (!d.changed) { |
| 102 | d.items = [...d.items]; |
| 103 | d.itemsById = new Map(d.itemsById); |
| 104 | d.changed = true; |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | function replaceItem(d: TranscriptDraft, id: string, updated: TranscriptItem) { |
| 109 | ensureMutable(d); |
no outgoing calls
no test coverage detected