Comparing version 3.0.1 to 3.0.2
@@ -41,2 +41,8 @@ var dlv = require('dlv'); | ||
}; | ||
var isInt = function isInt(str) { | ||
return /^\d+$/.test(str); | ||
}; | ||
var stripBrackets = function stripBrackets(str) { | ||
return str.replace(/[[\]]/g, ''); | ||
}; | ||
@@ -241,13 +247,16 @@ // Modified version of clean-set (https://github.com/fwilkerson/clean-set) | ||
changes[key] = null; | ||
} // added in new | ||
} | ||
} else if (inModified && !inOriginal) { | ||
changes[key] = modified[key]; // changed in new | ||
} else if (modified[key] !== original[key]) { | ||
var modifiedType = typeof modified[key]; | ||
continue; | ||
} // what type of value are we dealing with? | ||
if (modifiedType === 'object' && modified[key] !== null) { | ||
var modifiedValue = modified[key]; | ||
var modifiedValueIsObject = typeof modifiedValue === 'object'; // checks if modified value is different in any way | ||
if (!inOriginal || modifiedValue !== original[key]) { | ||
if (modifiedValueIsObject && modifiedValue !== null) { | ||
// we pass through "ignored" for nested stuff, but not the ignored keys | ||
// those only apply at the top level | ||
var otherChanges = getChanges(original[key], modified[key], { | ||
var otherChanges = getChanges(inOriginal ? original[key] : {}, modifiedValue, { | ||
includeDeletions: includeDeletions | ||
@@ -257,6 +266,6 @@ }); | ||
for (var otherKey in otherChanges) { | ||
changes[key + '.' + otherKey] = otherChanges[otherKey]; | ||
changes[(isInt(key) ? "[" + key + "]" : key) + '.' + otherKey] = otherChanges[otherKey]; | ||
} | ||
} else { | ||
changes[key] = modified[key]; | ||
changes[key] = modifiedValue; | ||
} | ||
@@ -311,3 +320,4 @@ } | ||
if (addedByObj1.hasOwnProperty(key)) { | ||
conflicts[key] = [dlv__default['default'](obj1, key), dlv__default['default'](obj2, key)]; | ||
var cleanedKey = stripBrackets(key); | ||
conflicts[key] = [dlv__default['default'](obj1, cleanedKey), dlv__default['default'](obj2, cleanedKey)]; | ||
} else { | ||
@@ -314,0 +324,0 @@ notConflicted[key] = addedByObj2[key]; |
@@ -37,2 +37,4 @@ import dlv from 'dlv'; | ||
}; | ||
const isInt = str => /^\d+$/.test(str); | ||
const stripBrackets = str => str.replace(/[[\]]/g, ''); | ||
@@ -205,13 +207,16 @@ // Modified version of clean-set (https://github.com/fwilkerson/clean-set) | ||
changes[key] = null; | ||
} // added in new | ||
} | ||
} else if (inModified && !inOriginal) { | ||
changes[key] = modified[key]; // changed in new | ||
} else if (modified[key] !== original[key]) { | ||
const modifiedType = typeof modified[key]; | ||
continue; | ||
} // what type of value are we dealing with? | ||
if (modifiedType === 'object' && modified[key] !== null) { | ||
const modifiedValue = modified[key]; | ||
const modifiedValueIsObject = typeof modifiedValue === 'object'; // checks if modified value is different in any way | ||
if (!inOriginal || modifiedValue !== original[key]) { | ||
if (modifiedValueIsObject && modifiedValue !== null) { | ||
// we pass through "ignored" for nested stuff, but not the ignored keys | ||
// those only apply at the top level | ||
const otherChanges = getChanges(original[key], modified[key], { | ||
const otherChanges = getChanges(inOriginal ? original[key] : {}, modifiedValue, { | ||
includeDeletions: _includeDeletions | ||
@@ -221,6 +226,6 @@ }); | ||
for (const otherKey in otherChanges) { | ||
changes[key + '.' + otherKey] = otherChanges[otherKey]; | ||
changes[(isInt(key) ? `[${key}]` : key) + '.' + otherKey] = otherChanges[otherKey]; | ||
} | ||
} else { | ||
changes[key] = modified[key]; | ||
changes[key] = modifiedValue; | ||
} | ||
@@ -275,3 +280,4 @@ } | ||
if (addedByObj1.hasOwnProperty(key)) { | ||
conflicts[key] = [dlv(obj1, key), dlv(obj2, key)]; | ||
const cleanedKey = stripBrackets(key); | ||
conflicts[key] = [dlv(obj1, cleanedKey), dlv(obj2, cleanedKey)]; | ||
} else { | ||
@@ -278,0 +284,0 @@ notConflicted[key] = addedByObj2[key]; |
@@ -37,2 +37,8 @@ import dlv from 'dlv'; | ||
}; | ||
var isInt = function isInt(str) { | ||
return /^\d+$/.test(str); | ||
}; | ||
var stripBrackets = function stripBrackets(str) { | ||
return str.replace(/[[\]]/g, ''); | ||
}; | ||
@@ -237,13 +243,16 @@ // Modified version of clean-set (https://github.com/fwilkerson/clean-set) | ||
changes[key] = null; | ||
} // added in new | ||
} | ||
} else if (inModified && !inOriginal) { | ||
changes[key] = modified[key]; // changed in new | ||
} else if (modified[key] !== original[key]) { | ||
var modifiedType = typeof modified[key]; | ||
continue; | ||
} // what type of value are we dealing with? | ||
if (modifiedType === 'object' && modified[key] !== null) { | ||
var modifiedValue = modified[key]; | ||
var modifiedValueIsObject = typeof modifiedValue === 'object'; // checks if modified value is different in any way | ||
if (!inOriginal || modifiedValue !== original[key]) { | ||
if (modifiedValueIsObject && modifiedValue !== null) { | ||
// we pass through "ignored" for nested stuff, but not the ignored keys | ||
// those only apply at the top level | ||
var otherChanges = getChanges(original[key], modified[key], { | ||
var otherChanges = getChanges(inOriginal ? original[key] : {}, modifiedValue, { | ||
includeDeletions: includeDeletions | ||
@@ -253,6 +262,6 @@ }); | ||
for (var otherKey in otherChanges) { | ||
changes[key + '.' + otherKey] = otherChanges[otherKey]; | ||
changes[(isInt(key) ? "[" + key + "]" : key) + '.' + otherKey] = otherChanges[otherKey]; | ||
} | ||
} else { | ||
changes[key] = modified[key]; | ||
changes[key] = modifiedValue; | ||
} | ||
@@ -307,3 +316,4 @@ } | ||
if (addedByObj1.hasOwnProperty(key)) { | ||
conflicts[key] = [dlv(obj1, key), dlv(obj2, key)]; | ||
var cleanedKey = stripBrackets(key); | ||
conflicts[key] = [dlv(obj1, cleanedKey), dlv(obj2, cleanedKey)]; | ||
} else { | ||
@@ -310,0 +320,0 @@ notConflicted[key] = addedByObj2[key]; |
@@ -44,2 +44,8 @@ (function (global, factory) { | ||
}; | ||
var isInt = function isInt(str) { | ||
return /^\d+$/.test(str); | ||
}; | ||
var stripBrackets = function stripBrackets(str) { | ||
return str.replace(/[[\]]/g, ''); | ||
}; | ||
@@ -244,13 +250,16 @@ // Modified version of clean-set (https://github.com/fwilkerson/clean-set) | ||
changes[key] = null; | ||
} // added in new | ||
} | ||
} else if (inModified && !inOriginal) { | ||
changes[key] = modified[key]; // changed in new | ||
} else if (modified[key] !== original[key]) { | ||
var modifiedType = typeof modified[key]; | ||
continue; | ||
} // what type of value are we dealing with? | ||
if (modifiedType === 'object' && modified[key] !== null) { | ||
var modifiedValue = modified[key]; | ||
var modifiedValueIsObject = typeof modifiedValue === 'object'; // checks if modified value is different in any way | ||
if (!inOriginal || modifiedValue !== original[key]) { | ||
if (modifiedValueIsObject && modifiedValue !== null) { | ||
// we pass through "ignored" for nested stuff, but not the ignored keys | ||
// those only apply at the top level | ||
var otherChanges = getChanges(original[key], modified[key], { | ||
var otherChanges = getChanges(inOriginal ? original[key] : {}, modifiedValue, { | ||
includeDeletions: includeDeletions | ||
@@ -260,6 +269,6 @@ }); | ||
for (var otherKey in otherChanges) { | ||
changes[key + '.' + otherKey] = otherChanges[otherKey]; | ||
changes[(isInt(key) ? "[" + key + "]" : key) + '.' + otherKey] = otherChanges[otherKey]; | ||
} | ||
} else { | ||
changes[key] = modified[key]; | ||
changes[key] = modifiedValue; | ||
} | ||
@@ -314,3 +323,4 @@ } | ||
if (addedByObj1.hasOwnProperty(key)) { | ||
conflicts[key] = [dlv__default['default'](obj1, key), dlv__default['default'](obj2, key)]; | ||
var cleanedKey = stripBrackets(key); | ||
conflicts[key] = [dlv__default['default'](obj1, cleanedKey), dlv__default['default'](obj2, cleanedKey)]; | ||
} else { | ||
@@ -317,0 +327,0 @@ notConflicted[key] = addedByObj2[key]; |
{ | ||
"name": "sinks", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "Tools for object sync (get it?!), validation, diffing, and immutable deep setting", | ||
@@ -10,3 +10,3 @@ "source": "src/index.js", | ||
"scripts": { | ||
"prepublish": "npm run format && npm run lint && npm test && npm run build", | ||
"prepublishOnly": "npm run format && npm run lint && npm test && npm run build", | ||
"build": "rm -rf ./dist && microbundle --no-compress", | ||
@@ -13,0 +13,0 @@ "test-inspect": "node --inspect-brk definition.spec.js", |
@@ -320,2 +320,3 @@ # sinks | ||
- `3.0.2`: Fix bad prepublish script. | ||
- `3.0.1`: Removing unnecessary conditional check. | ||
@@ -322,0 +323,0 @@ - `3.0.0`: `getChanges` now returns individual key path updates, this is important for simultaneous changes of nested objects. Technically, this should not be a breaking change unless you manually modify or somehow deal with the changes object. But since it changes the shape of something returned by public API I decided to bump the major version. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
138662
1406
336