updateData()function
updateData(data: T, updates: Updates<T>): T
| Param | Type | |
|---|---|---|
data | T | The data object to update. required |
updates | Updates<T> | The set of updates to apply. required |
| Return | |
|---|---|
T | The updated data object (or the original reference if nothing changed). |
| Throws | |
|---|---|
unknown |
Return a copy of a data object with a set of updates applied.
- Returns the original reference unchanged when no update changed a value.
- Supports nested paths, sum/increment, and array add/remove updates via the encoded
Updatessyntax.
Examples
updateData({ count: 1 }, { "+=count": 2 }) // { count: 3 }