applyPatches

function
devtools-ui/src/utils/apply-patch.ts:43
signature
applyPatches<T>(target, patches): T

Apply an array of RFC 6902 JSON Patch operations to a value. Returns a new object -- does not mutate the input.

Type parameters

NameTypeDescription
T–

Parameters

NameTypeDescription
targetTThe value to patch.
NameTypeDescription
patchesJsonPatch[]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 } }