just-diff-apply
Advanced tools
Comparing version 1.1.0 to 2.0.0
19
index.js
@@ -73,8 +73,7 @@ module.exports = { | ||
if (!Array.isArray(thisPath)) { | ||
throw new Error( | ||
'diff path must be an array, consider supplying a path converter' | ||
); | ||
throw new Error('diff path must be an array, consider supplying a path converter'); | ||
} | ||
} | ||
var lastProp = thisPath.pop(); | ||
var pathCopy = thisPath.slice(); | ||
var lastProp = pathCopy.pop(); | ||
if (!lastProp) { | ||
@@ -84,3 +83,3 @@ return false; | ||
var thisProp; | ||
while ((thisProp = thisPath.shift())) { | ||
while ((thisProp = pathCopy.shift())) { | ||
if (!(thisProp in subObject)) { | ||
@@ -93,13 +92,7 @@ subObject[thisProp] = {}; | ||
if (!subObject.hasOwnProperty(lastProp)) { | ||
throw new Error( | ||
['expected to find property', thisDiff.path, 'in object', obj].join( | ||
' ' | ||
) | ||
); | ||
throw new Error(['expected to find property', thisDiff.path, 'in object', obj].join(' ')); | ||
} | ||
} | ||
if (thisOp === REMOVE) { | ||
Array.isArray(subObject) | ||
? subObject.splice(lastProp, 1) | ||
: delete subObject[lastProp]; | ||
Array.isArray(subObject) ? subObject.splice(lastProp, 1) : delete subObject[lastProp]; | ||
} | ||
@@ -106,0 +99,0 @@ if (thisOp === REPLACE || thisOp === ADD) { |
{ | ||
"name": "just-diff-apply", | ||
"version": "1.1.0", | ||
"version": "2.0.0", | ||
"description": "Apply a diff to an object. Optionally supports jsonPatch protocol", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
6035
96