(
options: {
readonly oldValue: ReadonlyArray<Value>
readonly newValue: ReadonlyArray<Value>
readonly differ: Differ.Differ<Value, Patch>
}
)
| 114 | |
| 115 | /** @internal */ |
| 116 | export const diff = <Value, Patch>( |
| 117 | options: { |
| 118 | readonly oldValue: ReadonlyArray<Value> |
| 119 | readonly newValue: ReadonlyArray<Value> |
| 120 | readonly differ: Differ.Differ<Value, Patch> |
| 121 | } |
| 122 | ): Differ.Differ.ReadonlyArray.Patch<Value, Patch> => { |
| 123 | let i = 0 |
| 124 | let patch = empty<Value, Patch>() |
| 125 | while (i < options.oldValue.length && i < options.newValue.length) { |
| 126 | const oldElement = options.oldValue[i]! |
| 127 | const newElement = options.newValue[i]! |
| 128 | const valuePatch = options.differ.diff(oldElement, newElement) |
| 129 | if (!Equal.equals(valuePatch, options.differ.empty)) { |
| 130 | patch = combine(patch, makeUpdate(i, valuePatch)) |
| 131 | } |
| 132 | i = i + 1 |
| 133 | } |
| 134 | if (i < options.oldValue.length) { |
| 135 | patch = combine(patch, makeSlice(0, i)) |
| 136 | } |
| 137 | if (i < options.newValue.length) { |
| 138 | patch = combine(patch, makeAppend(Arr.drop(i)(options.newValue))) |
| 139 | } |
| 140 | return patch |
| 141 | } |
| 142 | |
| 143 | /** @internal */ |
| 144 | export const combine = Dual.dual< |
nothing calls this directly
no test coverage detected
searching dependent graphs…