applyPatches
functionsignature
applyPatches<T>(target, patches): TApply an array of RFC 6902 JSON Patch operations to a value. Returns a new object -- does not mutate the input.
Type parameters
| Name | Type | Description |
|---|---|---|
T | – |
Parameters
| Name | Type | Description |
|---|---|---|
target | T | The value to patch. |
| Name | Type | Description |
|---|---|---|
patches | JsonPatch[] | RFC 6902 operations. |
Returns
T, A new patched value.
Example
example
import { applyPatches } from "@yoltra/devtools-ui";
const next = applyPatches(
{ counter: { value: 0 } },
[{ op: "replace", path: "/counter/value", value: 1 }],
);
// next => { counter: { value: 1 } }