Comparing version 3.0.2 to 3.0.3
@@ -41,8 +41,10 @@ var dlv = require('dlv'); | ||
}; | ||
var isInt = function isInt(str) { | ||
return /^\d+$/.test(str); | ||
}; | ||
var stripBrackets = function stripBrackets(str) { | ||
return str.replace(/[[\]]/g, ''); | ||
}; | ||
var injectBrackets = function injectBrackets(str) { | ||
if (!str) return str; | ||
var split = str.split('.'); | ||
return ["[" + split[0] + "]"].concat(split.slice(1)).join('.'); | ||
}; | ||
@@ -265,3 +267,5 @@ // Modified version of clean-set (https://github.com/fwilkerson/clean-set) | ||
for (var otherKey in otherChanges) { | ||
changes[(isInt(key) ? "[" + key + "]" : key) + '.' + otherKey] = otherChanges[otherKey]; | ||
var value = otherChanges[otherKey]; | ||
var isArray = Array.isArray(modified[key]); | ||
changes[key + '.' + (isArray ? injectBrackets(otherKey) : otherKey)] = value; | ||
} | ||
@@ -268,0 +272,0 @@ } else { |
@@ -37,4 +37,8 @@ import dlv from 'dlv'; | ||
}; | ||
const isInt = str => /^\d+$/.test(str); | ||
const stripBrackets = str => str.replace(/[[\]]/g, ''); | ||
const injectBrackets = str => { | ||
if (!str) return str; | ||
const split = str.split('.'); | ||
return [`[${split[0]}]`, ...split.slice(1)].join('.'); | ||
}; | ||
@@ -225,3 +229,5 @@ // Modified version of clean-set (https://github.com/fwilkerson/clean-set) | ||
for (const otherKey in otherChanges) { | ||
changes[(isInt(key) ? `[${key}]` : key) + '.' + otherKey] = otherChanges[otherKey]; | ||
const value = otherChanges[otherKey]; | ||
const isArray = Array.isArray(modified[key]); | ||
changes[key + '.' + (isArray ? injectBrackets(otherKey) : otherKey)] = value; | ||
} | ||
@@ -228,0 +234,0 @@ } else { |
@@ -37,8 +37,10 @@ import dlv from 'dlv'; | ||
}; | ||
var isInt = function isInt(str) { | ||
return /^\d+$/.test(str); | ||
}; | ||
var stripBrackets = function stripBrackets(str) { | ||
return str.replace(/[[\]]/g, ''); | ||
}; | ||
var injectBrackets = function injectBrackets(str) { | ||
if (!str) return str; | ||
var split = str.split('.'); | ||
return ["[" + split[0] + "]"].concat(split.slice(1)).join('.'); | ||
}; | ||
@@ -261,3 +263,5 @@ // Modified version of clean-set (https://github.com/fwilkerson/clean-set) | ||
for (var otherKey in otherChanges) { | ||
changes[(isInt(key) ? "[" + key + "]" : key) + '.' + otherKey] = otherChanges[otherKey]; | ||
var value = otherChanges[otherKey]; | ||
var isArray = Array.isArray(modified[key]); | ||
changes[key + '.' + (isArray ? injectBrackets(otherKey) : otherKey)] = value; | ||
} | ||
@@ -264,0 +268,0 @@ } else { |
@@ -44,8 +44,10 @@ (function (global, factory) { | ||
}; | ||
var isInt = function isInt(str) { | ||
return /^\d+$/.test(str); | ||
}; | ||
var stripBrackets = function stripBrackets(str) { | ||
return str.replace(/[[\]]/g, ''); | ||
}; | ||
var injectBrackets = function injectBrackets(str) { | ||
if (!str) return str; | ||
var split = str.split('.'); | ||
return ["[" + split[0] + "]"].concat(split.slice(1)).join('.'); | ||
}; | ||
@@ -268,3 +270,5 @@ // Modified version of clean-set (https://github.com/fwilkerson/clean-set) | ||
for (var otherKey in otherChanges) { | ||
changes[(isInt(key) ? "[" + key + "]" : key) + '.' + otherKey] = otherChanges[otherKey]; | ||
var value = otherChanges[otherKey]; | ||
var isArray = Array.isArray(modified[key]); | ||
changes[key + '.' + (isArray ? injectBrackets(otherKey) : otherKey)] = value; | ||
} | ||
@@ -271,0 +275,0 @@ } else { |
{ | ||
"name": "sinks", | ||
"version": "3.0.2", | ||
"version": "3.0.3", | ||
"description": "Tools for object sync (get it?!), validation, diffing, and immutable deep setting", | ||
@@ -5,0 +5,0 @@ "source": "src/index.js", |
@@ -320,2 +320,3 @@ # sinks | ||
- `3.0.3`: Fixed bug where `getChanges` not handle objects with integer keys correctly. | ||
- `3.0.2`: Fix bad prepublish script. | ||
@@ -322,0 +323,0 @@ - `3.0.1`: Removing unnecessary conditional check. |
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
141638
1424
337