(updates: any[], state: any)
| 105 | |
| 106 | function updateManyMutably(updates: Update<T>[], state: R): DidMutate; |
| 107 | function updateManyMutably(updates: any[], state: any): DidMutate { |
| 108 | const models: T[] = []; |
| 109 | |
| 110 | const didMutateIds = |
| 111 | updates.filter((update) => takeUpdatedModel(models, update, state)) |
| 112 | .length > 0; |
| 113 | |
| 114 | if (models.length === 0) { |
| 115 | return DidMutate.None; |
| 116 | } else { |
| 117 | const originalIds = state.ids; |
| 118 | const updatedIndexes: any[] = []; |
| 119 | state.ids = state.ids.filter((id: any, index: number) => { |
| 120 | if (id in state.entities) { |
| 121 | return true; |
| 122 | } else { |
| 123 | updatedIndexes.push(index); |
| 124 | return false; |
| 125 | } |
| 126 | }); |
| 127 | |
| 128 | merge(models, state); |
| 129 | |
| 130 | if ( |
| 131 | !didMutateIds && |
| 132 | updatedIndexes.every((i: number) => state.ids[i] === originalIds[i]) |
| 133 | ) { |
| 134 | return DidMutate.EntitiesOnly; |
| 135 | } else { |
| 136 | return DidMutate.Both; |
| 137 | } |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | function mapMutably(map: EntityMap<T>, state: R): DidMutate; |
| 142 | function mapMutably(updatesOrMap: any, state: any): DidMutate { |
no test coverage detected