Type Alias: Patch
ts
type Patch = {
[key: string]: 0 | Patch | [unknown] | ArrayPatch;
};Defined in: patch.ts:18
Deltas between two JSON values, used to send a player only what changed.
A patch mirrors the shape of the object it changes. For each key:
- a nested patch object: go into that key and patch what is there;
[value]: set the key tovalue;[changes, length]: the key holds an array;lengthis how long it now is, andchangeshas, by index, what to do with the elements that changed, each in one of these same forms;0: delete the key.
An array is patched element by element where its elements kept their places: a unit that moved costs its new position, not the whole list. An array whose elements shifted, because one was put in or taken out before the end, is sent whole. So for things that come and go, an object keyed by id is still the better home.
Index Signature
ts
[key: string]: 0 | Patch | [unknown] | ArrayPatch