API reference · generated from source
Type Alias: TNodeFieldChangeOp#
type TNodeFieldChangeOp = "add" | "delete" | "insert" | "remove" | "length" | "clear";Defined in: types.ts:90
Structural operation marker on a field-level change record.
Remarks#
previous/new values alone cannot always describe a mutation exactly:
assigning undefined to a property and deleting that property produce the
same value pair, and array structural methods shift elements without
emitting a record per shifted index. The marker carries the missing fact so
Retree.applyInverse and Retree.applyChanges can restore
state exactly.
"add"— the key/entry did not exist before this change (object property creation,Map.setof a new key). Inverse: delete the key."delete"— the key/entry was removed (propertydelete,Map.delete, and the per-entry records emitted byMap.clear). Inverse: restorepreviousat the key."insert"— an element was inserted by an array structural method (push,unshift,splice);keyis the element's index in the post-mutation array. Inverse:splice(index, 1)."remove"— an element was removed by an array structural method (pop,shift,splice);keyis the element's index in the pre-mutation array. Inverse:splice(index, 0, previous)."length"— the length adjustment accompanying an array structural method. It is bookkeeping for theinsert/removerecords in the same set; applying those already restores the length, so inversion skips it."clear"— the summary record emitted byMap.clear/Set.clearalongside the per-entry"delete"records. The marker separates it from a plain write to a literal"clear"Map key; inversion skips it because the per-entry records restore the contents.
Records without a marker are plain value rewrites (previous -> new at
key) and invert by writing previous back. A direct array.length = n
assignment emits an unmarked length record; the elements a shrinking
assignment discards emit no records, so only the length itself can be
restored.