(
options: {
readonly oldValue: Either<Value2, Value>
readonly newValue: Either<Value2, Value>
readonly left: Differ<Value, Patch>
readonly right: Differ<Value2, Patch2>
}
)
| 187 | |
| 188 | /** @internal */ |
| 189 | export const diff = <Value, Value2, Patch, Patch2>( |
| 190 | options: { |
| 191 | readonly oldValue: Either<Value2, Value> |
| 192 | readonly newValue: Either<Value2, Value> |
| 193 | readonly left: Differ<Value, Patch> |
| 194 | readonly right: Differ<Value2, Patch2> |
| 195 | } |
| 196 | ): Differ.Or.Patch<Value, Value2, Patch, Patch2> => { |
| 197 | switch (options.oldValue._tag) { |
| 198 | case "Left": { |
| 199 | switch (options.newValue._tag) { |
| 200 | case "Left": { |
| 201 | const valuePatch = options.left.diff(options.oldValue.left, options.newValue.left) |
| 202 | if (Equal.equals(valuePatch, options.left.empty)) { |
| 203 | return empty() |
| 204 | } |
| 205 | return makeUpdateLeft(valuePatch) |
| 206 | } |
| 207 | case "Right": { |
| 208 | return makeSetRight(options.newValue.right) |
| 209 | } |
| 210 | } |
| 211 | } |
| 212 | case "Right": { |
| 213 | switch (options.newValue._tag) { |
| 214 | case "Left": { |
| 215 | return makeSetLeft(options.newValue.left) |
| 216 | } |
| 217 | case "Right": { |
| 218 | const valuePatch = options.right.diff(options.oldValue.right, options.newValue.right) |
| 219 | if (Equal.equals(valuePatch, options.right.empty)) { |
| 220 | return empty() |
| 221 | } |
| 222 | return makeUpdateRight(valuePatch) |
| 223 | } |
| 224 | } |
| 225 | } |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | /** @internal */ |
| 230 | export const combine = Dual.dual< |
no test coverage detected