just-diff-apply
Advanced tools
Comparing version 2.0.0 to 3.0.0
@@ -32,4 +32,4 @@ module.exports = { | ||
{ "op": "replace", "path": ['a'], "value": 3 } | ||
{ "op": "replace", "path": ['b', '2'], "value": 4 } | ||
{ "op": "add", "path": ['b', '3'], "value": 9 } | ||
{ "op": "replace", "path": ['b', 2], "value": 4 } | ||
{ "op": "add", "path": ['b', 3], "value": 9 } | ||
]); | ||
@@ -79,7 +79,7 @@ obj3; // {a: 3, b: [1, 2, 4, 9]} | ||
var lastProp = pathCopy.pop(); | ||
if (!lastProp) { | ||
if (lastProp == null) { | ||
return false; | ||
} | ||
var thisProp; | ||
while ((thisProp = pathCopy.shift())) { | ||
while (((thisProp = pathCopy.shift())) != null) { | ||
if (!(thisProp in subObject)) { | ||
@@ -86,0 +86,0 @@ subObject[thisProp] = {}; |
{ | ||
"name": "just-diff-apply", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"description": "Apply a diff to an object. Optionally supports jsonPatch protocol", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
## just-diff-apply | ||
Part of a [library](../../../../) of zero-dependency npm modules that do just do one thing. | ||
Part of a [library](../../../../) of zero-dependency npm modules that do just do one thing. | ||
Guilt-free utilities for every occasion. | ||
@@ -8,3 +8,3 @@ | ||
Apply a diff object to an object. | ||
Apply a diff object to an object. | ||
Pass converter to apply a http://jsonpatch.com standard patch | ||
@@ -36,8 +36,8 @@ | ||
// arrays | ||
// arrays (array key can be string or numeric) | ||
const obj3 = {a: 4, b: [1, 2, 3]}; | ||
diffApply(obj3, [ | ||
{ "op": "replace", "path": ['a'], "value": 3 } | ||
{ "op": "replace", "path": ['b', '2'], "value": 4 } | ||
{ "op": "add", "path": ['b', '3'], "value": 9 } | ||
{ "op": "replace", "path": ['b', 2], "value": 4 } | ||
{ "op": "add", "path": ['b', 3], "value": 9 } | ||
]); | ||
@@ -54,2 +54,2 @@ obj3; // {a: 3, b: [1, 2, 4, 9]} | ||
obj4; // {a: 5, b: {d: 4}} | ||
``` | ||
``` |
6075