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

Function diff

packages/effect/src/internal/differ/contextPatch.ts:131–153  ·  view source on GitHub ↗
(
  oldValue: Context<Input>,
  newValue: Context<Output>
)

Source from the content-addressed store, hash-verified

129
130/** @internal */
131export 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 */
156export const combine = Dual.dual<

Callers

nothing calls this directly

Calls 7

makeUpdateServiceFunction · 0.85
makeAddServiceFunction · 0.85
makeRemoveServiceFunction · 0.85
entriesMethod · 0.80
emptyFunction · 0.70
getMethod · 0.65
combineFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…