MCPcopy Index your code
hub / github.com/Effect-TS/effect / diff

Function diff

packages/effect/src/internal/differ/orPatch.ts:189–227  ·  view source on GitHub ↗
(
  options: {
    readonly oldValue: Either<Value2, Value>
    readonly newValue: Either<Value2, Value>
    readonly left: Differ<Value, Patch>
    readonly right: Differ<Value2, Patch2>
  }
)

Source from the content-addressed store, hash-verified

187
188/** @internal */
189export 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 */
230export const combine = Dual.dual<

Callers 1

runtimeFlags.tsFile · 0.50

Calls 6

makeUpdateLeftFunction · 0.85
makeSetRightFunction · 0.85
makeSetLeftFunction · 0.85
makeUpdateRightFunction · 0.85
emptyFunction · 0.70
diffMethod · 0.65

Tested by

no test coverage detected