( oldValue: Context<Input>, newValue: Context<Output> )
| 129 | |
| 130 | /** @internal */ |
| 131 | export const diff = <Input, Output>( |
| 132 | oldValue: Context<Input>, |
| 133 | newValue: Context<Output> |
| 134 | ): Differ.Context.Patch<Input, Output> => { |
| 135 | const missingServices = new Map(oldValue.unsafeMap) |
| 136 | let patch = empty<any, any>() |
| 137 | for (const [tag, newService] of newValue.unsafeMap.entries()) { |
| 138 | if (missingServices.has(tag)) { |
| 139 | const old = missingServices.get(tag)! |
| 140 | missingServices.delete(tag) |
| 141 | if (!Equal.equals(old, newService)) { |
| 142 | patch = combine(makeUpdateService(tag, () => newService))(patch) |
| 143 | } |
| 144 | } else { |
| 145 | missingServices.delete(tag) |
| 146 | patch = combine(makeAddService(tag, newService))(patch) |
| 147 | } |
| 148 | } |
| 149 | for (const [tag] of missingServices.entries()) { |
| 150 | patch = combine(makeRemoveService(tag))(patch) |
| 151 | } |
| 152 | return patch |
| 153 | } |
| 154 | |
| 155 | /** @internal */ |
| 156 | export const combine = Dual.dual< |
nothing calls this directly
no test coverage detected
searching dependent graphs…