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