From 69e01030a5feed8ce3c767fa5c25fcc81ba3f786 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 29 Jun 2022 17:38:40 -0600 Subject: [PATCH] fix buig --- client/lib/json-patch-lib.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/client/lib/json-patch-lib.ts b/client/lib/json-patch-lib.ts index daff465..aa251d9 100644 --- a/client/lib/json-patch-lib.ts +++ b/client/lib/json-patch-lib.ts @@ -55,6 +55,8 @@ export function applyOperation ( } function recursiveApply | any[]> (data: T, path: readonly string[], op: PatchOp, value?: any): T { + if (!path.length) return value + // object if (isObject(data)) { return recursiveApplyObject(data, path, op, value) @@ -67,8 +69,6 @@ function recursiveApply | any[]> (data: T, path: r } function recursiveApplyObject> (data: T, path: readonly string[], op: PatchOp, value?: any): T { - if (!path.length) return value - const updated = recursiveApply(data[path[0]], path.slice(1), op, value) const result = { ...data, @@ -83,8 +83,6 @@ function recursiveApplyObject> (data: T, path: rea } function recursiveApplyArray (data: T, path: readonly string[], op: PatchOp, value?: any): T { - if (!path.length) return value - const index = parseInt(path[0]) const updated = recursiveApply(data[index], path.slice(1), op, value)