From 745b77725ba7d32ba917440bb7e0835ef09b6d93 Mon Sep 17 00:00:00 2001 From: jos Date: Wed, 22 Nov 2017 13:38:18 +0100 Subject: [PATCH] Fixed removing multiple items from an array --- src/actions.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/actions.js b/src/actions.js index 928c5c6..c893dc5 100644 --- a/src/actions.js +++ b/src/actions.js @@ -283,10 +283,12 @@ export function remove (path) { * @return {ESONPatch} */ export function removeAll (paths) { - return paths.map(path => ({ - op: 'remove', - path: compileJSONPointer(path) - })) + return paths + .map(path => ({ + op: 'remove', + path: compileJSONPointer(path) + })) + .reverse() // reverse is needed for arrays: delete the last index first } // TODO: test removeAll