Skip to content
Myr

patches.ts

This file

Path

src/plugins/patches.ts

431 lines · 10.4 KiB · TypeScript

Last changed by

feat: Override array methods to avoid proxy creation while iterating and updating (#1184)Mark Eriksonbefore adoptiond38a9d0

History of this file

Take it

The walk stopped after 200 commits: lines older than 6555173 point at it.

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 1–13why, one step back
1import {immerable} from "../immer"
2import {3 ImmerState,4 Patch,5 SetState,6 ProxyArrayState,7 MapState,8 ProxyObjectState,9 PatchPath,10 get,11 each,12 has,13 getArchtype,

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 14why, one step back
14 getPrototypeOf,

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 15–17why, one step back
15 isSet,
16 isMap,17 loadPlugin,

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 18why, one step back
18 ArchType,

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 19–20why, one step back
19 die,
20 isDraft,

fix: #791 return 'nothing' should produce undefined patchMichel Weststratebefore adoption5412c9f

line 21why, one step back
21 isDraftable,

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 22why, one step back
22 NOTHING,

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

lines 23–32why, one step back
23 errors,
24 DRAFT_STATE,25 getProxyDraft,26 ImmerScope,27 isObjectish,28 isFunction,29 CONSTRUCTOR,30 PluginPatches,31 isArray,32 PROTOTYPE

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 33–35why, one step back
33} from "../internal"
3435export function enablePatches() {

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

lines 36–49why, one step back
36 const errorOffset = 16
37 if (process.env.NODE_ENV !== "production") {38 errors.push(39 'Sets cannot have "replace" patches.',40 function(op: string) {41 return "Unsupported patch operation: " + op42 },43 function(path: string) {44 return "Cannot apply patch, path doesn't resolve: " + path45 },46 "Patching reserved attributes like __proto__, prototype and constructor is not allowed"47 )48 }49

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

lines 50–127why, one step back
50 function getPath(state: ImmerState, path: PatchPath = []): PatchPath | null {
51 // Step 1: Check if state has a stored key52 if ("key_" in state && state.key_ !== undefined) {53 // Step 2: Validate the key is still valid in parent5455 const parentCopy = state.parent_!.copy_ ?? state.parent_!.base_56 const proxyDraft = getProxyDraft(get(parentCopy, state.key_!))57 const valueAtKey = get(parentCopy, state.key_!)5859 if (valueAtKey === undefined) {60 return null61 }6263 // Check if the value at the key is still related to this draft64 // It should be either the draft itself, the base, or the copy65 if (66 valueAtKey !== state.draft_ &&67 valueAtKey !== state.base_ &&68 valueAtKey !== state.copy_69 ) {70 return null // Value was replaced with something else71 }72 if (proxyDraft != null && proxyDraft.base_ !== state.base_) {73 return null // Different draft74 }7576 // Step 3: Handle Set case specially77 const isSet = state.parent_!.type_ === ArchType.Set78 let key: string | number7980 if (isSet) {81 // For Sets, find the index in the drafts_ map82 const setParent = state.parent_ as SetState83 key = Array.from(setParent.drafts_.keys()).indexOf(state.key_)84 } else {85 key = state.key_ as string | number86 }8788 // Step 4: Validate key still exists in parent89 if (!((isSet && parentCopy.size > key) || has(parentCopy, key))) {90 return null // Key deleted91 }9293 // Step 5: Add key to path94 path.push(key)95 }9697 // Step 6: Recurse to parent if exists98 if (state.parent_) {99 return getPath(state.parent_, path)100 }101102 // Step 7: At root - reverse path and validate103 path.reverse()104105 try {106 // Validate path can be resolved from ROOT107 resolvePath(state.copy_, path)108 } catch (e) {109 return null // Path invalid110 }111112 return path113 }114115 // NEW: Add resolvePath helper function116 function resolvePath(base: any, path: PatchPath): any {117 let current = base118 for (let i = 0; i < path.length - 1; i++) {119 const key = path[i]120 current = get(current, key)121 if (!isObjectish(current) || current === null) {122 throw new Error(`Cannot resolve path at '${path.join("/")}'`)123 }124 }125 return current126 }127

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 128–134why, one step back
128 const REPLACE = "replace"
129 const ADD = "add"130 const REMOVE = "remove"131132 function generatePatches_(133 state: ImmerState,134 basePath: PatchPath,

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 135why, one step back
135 scope: ImmerScope

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

line 136why, one step back
136 ): void {

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

lines 137–144why, one step back
137 if (state.scope_.processedForPatches_.has(state)) {
138 return139 }140141 state.scope_.processedForPatches_.add(state)142143 const {patches_, inversePatches_} = scope144

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

line 145why, one step back
145 switch (state.type_) {

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

lines 146–147why, one step back
146 case ArchType.Object:
147 case ArchType.Map:

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 148–150why, one step back
148 return generatePatchesFromAssigned(
149 state,150 basePath,

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

lines 151–152why, one step back
151 patches_!,
152 inversePatches_!

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

line 153why, one step back
153 )

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 154why, one step back
154 case ArchType.Array:

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

lines 155–160why, one step back
155 return generateArrayPatches(
156 state,157 basePath,158 patches_!,159 inversePatches_!160 )

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 161why, one step back
161 case ArchType.Set:

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 162–164why, one step back
162 return generateSetPatches(
163 (state as any) as SetState,164 basePath,

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

lines 165–166why, one step back
165 patches_!,
166 inversePatches_!

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 167–171why, one step back
167 )
168 }169 }170171 function generateArrayPatches(

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 172why, one step back
172 state: ProxyArrayState,

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 173–186why, one step back
173 basePath: PatchPath,
174 patches: Patch[],175 inversePatches: Patch[]176 ) {177 let {base_, assigned_} = state178 let copy_ = state.copy_!179180 // Reduce complexity by ensuring `base` is never longer.181 if (copy_.length < base_.length) {182 // @ts-ignore183 ;[base_, copy_] = [copy_, base_]184 ;[patches, inversePatches] = [inversePatches, patches]185 }186

feat: Override array methods to avoid proxy creation while iterating and updating (#1184)Mark Eriksonbefore adoptiond38a9d0

lines 187–188why, one step back
187 const allReassigned = state.allIndicesReassigned_ === true
188

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 189–190why, one step back
189 // Process replaced indices.
190 for (let i = 0; i < base_.length; i++) {

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

lines 191–192why, one step back
191 const copiedItem = copy_[i]
192 const baseItem = base_[i]

feat: Override array methods to avoid proxy creation while iterating and updating (#1184)Mark Eriksonbefore adoptiond38a9d0

lines 193–195why, one step back
193
194 const isAssigned = allReassigned || assigned_?.get(i.toString())195 if (isAssigned && copiedItem !== baseItem) {

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

lines 196–200why, one step back
196 const childState = copiedItem?.[DRAFT_STATE]
197 if (childState && childState.modified_) {198 // Skip - let the child generate its own patches199 continue200 }

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 201–206why, one step back
201 const path = basePath.concat([i])
202 patches.push({203 op: REPLACE,204 path,205 // Need to maybe clone it, as it can in fact be the original value206 // due to the base/copy inversion at the start of this function

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 207why, one step back
207 value: clonePatchValueIfNeeded(copiedItem)

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 208–211why, one step back
208 })
209 inversePatches.push({210 op: REPLACE,211 path,

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 212why, one step back
212 value: clonePatchValueIfNeeded(baseItem)

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 213–227why, one step back
213 })
214 }215 }216217 // Process added indices.218 for (let i = base_.length; i < copy_.length; i++) {219 const path = basePath.concat([i])220 patches.push({221 op: ADD,222 path,223 // Need to maybe clone it, as it can in fact be the original value224 // due to the base/copy inversion at the start of this function225 value: clonePatchValueIfNeeded(copy_[i])226 })227 }

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

lines 228–229why, one step back
228 for (let i = copy_.length - 1; base_.length <= i; --i) {
229 const path = basePath.concat([i])

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

line 230why, one step back
230 inversePatches.push({

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

lines 231–232why, one step back
231 op: REMOVE,
232 path

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 233–238why, one step back
233 })
234 }235 }236237 // This is used for both Map objects and normal objects.238 function generatePatchesFromAssigned(

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 239why, one step back
239 state: MapState | ProxyObjectState,

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 240–243why, one step back
240 basePath: PatchPath,
241 patches: Patch[],242 inversePatches: Patch[]243 ) {

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 244why, one step back
244 const {base_, copy_, type_} = state

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

line 245why, one step back
245 each(state.assigned_!, (key, assignedValue) => {

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

lines 246–247why, one step back
246 const origValue = get(base_, key, type_)
247 const value = get(copy_!, key, type_)

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 248–250why, one step back
248 const op = !assignedValue ? REMOVE : has(base_, key) ? REPLACE : ADD
249 if (origValue === value && op === REPLACE) return250 const path = basePath.concat(key as any)

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

lines 251–255why, one step back
251 patches.push(
252 op === REMOVE253 ? {op, path}254 : {op, path, value: clonePatchValueIfNeeded(value)}255 )

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 256–310why, one step back
256 inversePatches.push(
257 op === ADD258 ? {op: REMOVE, path}259 : op === REMOVE260 ? {op: ADD, path, value: clonePatchValueIfNeeded(origValue)}261 : {op: REPLACE, path, value: clonePatchValueIfNeeded(origValue)}262 )263 })264 }265266 function generateSetPatches(267 state: SetState,268 basePath: PatchPath,269 patches: Patch[],270 inversePatches: Patch[]271 ) {272 let {base_, copy_} = state273274 let i = 0275 base_.forEach((value: any) => {276 if (!copy_!.has(value)) {277 const path = basePath.concat([i])278 patches.push({279 op: REMOVE,280 path,281 value282 })283 inversePatches.unshift({284 op: ADD,285 path,286 value287 })288 }289 i++290 })291 i = 0292 copy_!.forEach((value: any) => {293 if (!base_.has(value)) {294 const path = basePath.concat([i])295 patches.push({296 op: ADD,297 path,298 value299 })300 inversePatches.unshift({301 op: REMOVE,302 path,303 value304 })305 }306 i++307 })308 }309310 function generateReplacementPatches_(

fix: No patches being generated for root primitive replacements. Fixes #888Michel Weststratebefore adoption0f96270

line 311why, one step back
311 baseValue: any,

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

line 312why, one step back
312 replacement: any,

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 313why, one step back
313 scope: ImmerScope

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

line 314why, one step back
314 ): void {

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

lines 315–316why, one step back
315 const {patches_, inversePatches_} = scope
316 patches_!.push({

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 317–318why, one step back
317 op: REPLACE,
318 path: [],

fix: #791 return 'nothing' should produce undefined patchMichel Weststratebefore adoption5412c9f

line 319why, one step back
319 value: replacement === NOTHING ? undefined : replacement

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

line 320why, one step back
320 })

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 321why, one step back
321 inversePatches_!.push({

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 322–323why, one step back
322 op: REPLACE,
323 path: [],

fix: No patches being generated for root primitive replacements. Fixes #888Michel Weststratebefore adoption0f96270

line 324why, one step back
324 value: baseValue

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 325–327why, one step back
325 })
326 }327

fix: Make `applyPatches` to accept `readonly Patch[]` (#1094)Mateusz Burzyńskibefore adoption4da2e0d

line 328why, one step back
328 function applyPatches_<T>(draft: T, patches: readonly Patch[]): T {

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 329–334why, one step back
329 patches.forEach(patch => {
330 const {path, op} = patch331332 let base: any = draft333 for (let i = 0; i < path.length - 1; i++) {334 const parentType = getArchtype(base)

fix: patching maps failed when using number keys (#1025)Marco Schumacherbefore adoptiondd83e2e

lines 335–339why, one step back
335 let p = path[i]
336 if (typeof p !== "string" && typeof p !== "number") {337 p = "" + p338 }339

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 340–341why, one step back
340 // See #738, avoid prototype pollution
341 if (

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 342why, one step back
342 (parentType === ArchType.Object || parentType === ArchType.Array) &&

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 343why, one step back
343 (p === "__proto__" || p === CONSTRUCTOR)

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

line 344why, one step back
344 )

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 345why, one step back
345 die(errorOffset + 3)

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 346why, one step back
346 if (isFunction(base) && p === PROTOTYPE) die(errorOffset + 3)

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

line 347why, one step back
347 base = get(base, p)

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 348why, one step back
348 if (!isObjectish(base)) die(errorOffset + 2, path.join("/"))

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 349–356why, one step back
349 }
350351 const type = getArchtype(base)352 const value = deepClonePatchValue(patch.value) // used to clone patch to ensure original patch is not modified, see #411353 const key = path[path.length - 1]354 switch (op) {355 case REPLACE:356 switch (type) {

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 357why, one step back
357 case ArchType.Map:

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 358–359why, one step back
358 return base.set(key, value)
359 /* istanbul ignore next */

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

lines 360–361why, one step back
360 case ArchType.Set:
361 die(errorOffset)

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 362–370why, one step back
362 default:
363 // if value is an object, then it's assigned by reference364 // in the following add or remove ops, the value field inside the patch will also be modifyed365 // so we use value from the cloned patch366 // @ts-ignore367 return (base[key] = value)368 }369 case ADD:370 switch (type) {

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 371why, one step back
371 case ArchType.Array:

fix: Append to array when key is "-" (#872)Louis DeSciolibefore adoption2afdb1b

lines 372–374why, one step back
372 return key === "-"
373 ? base.push(value)374 : base.splice(key as any, 0, value)

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 375why, one step back
375 case ArchType.Map:

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

line 376why, one step back
376 return base.set(key, value)

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 377why, one step back
377 case ArchType.Set:

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 378–383why, one step back
378 return base.add(value)
379 default:380 return (base[key] = value)381 }382 case REMOVE:383 switch (type) {

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 384why, one step back
384 case ArchType.Array:

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

line 385why, one step back
385 return base.splice(key as any, 1)

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 386why, one step back
386 case ArchType.Map:

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

line 387why, one step back
387 return base.delete(key)

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 388why, one step back
388 case ArchType.Set:

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 389–393why, one step back
389 return base.delete(patch.value)
390 default:391 return delete base[key]392 }393 default:

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 394why, one step back
394 die(errorOffset + 1, op)

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 395–406why, one step back
395 }
396 })397398 return draft399 }400401 // optimize: this is quite a performance hit, can we detect intelligently when it is needed?402 // E.g. auto-draft when new objects from outside are assigned and modified?403 // (See failing test when deepClone just returns obj)404 function deepClonePatchValue<T>(obj: T): T405 function deepClonePatchValue(obj: any) {406 if (!isDraftable(obj)) return obj

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 407why, one step back
407 if (isArray(obj)) return obj.map(deepClonePatchValue)

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 408–412why, one step back
408 if (isMap(obj))
409 return new Map(410 Array.from(obj.entries()).map(([k, v]) => [k, deepClonePatchValue(v)])411 )412 if (isSet(obj)) return new Set(Array.from(obj).map(deepClonePatchValue))

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 413why, one step back
413 const cloned = Object.create(getPrototypeOf(obj))

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 414–424why, one step back
414 for (const key in obj) cloned[key] = deepClonePatchValue(obj[key])
415 if (has(obj, immerable)) cloned[immerable] = obj[immerable]416 return cloned417 }418419 function clonePatchValueIfNeeded<T>(obj: T): T {420 if (isDraft(obj)) {421 return deepClonePatchValue(obj)422 } else return obj423 }424

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 425why, one step back
425 loadPlugin(PluginPatches, {

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 426–427why, one step back
426 applyPatches_,
427 generatePatches_,

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

lines 428–429why, one step back
428 generateReplacementPatches_,
429 getPath

fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173

lines 430–431why, one step back
430 })
431}