Comparing version 1.1.0 to 1.2.0
28
index.js
@@ -18,10 +18,12 @@ 'use strict'; | ||
if(parts.length > 1) { | ||
k = parts.pop(); | ||
let partsLength = parts.length | ||
k = parts[partsLength - 1]; | ||
parts.forEach(function(k) { | ||
if(! obj.hasOwnProperty(k)) { | ||
obj[k] = {}; | ||
for(let i = 0; i < partsLength - 1; i++) { | ||
let part = parts[i] | ||
if(! obj.hasOwnProperty(part)) { | ||
obj[part] = {}; | ||
} | ||
obj = obj[k]; | ||
}); | ||
obj = obj[part]; | ||
} | ||
} | ||
@@ -43,11 +45,13 @@ if(typeof val !== 'undefined') { | ||
if(parts.length > -1) { | ||
k = parts.pop(); | ||
let partsLength = parts.length | ||
k = parts[partsLength - 1]; | ||
parts.forEach(function(k) { | ||
if(! obj.hasOwnProperty(k)) { | ||
for(let i = 0; i < partsLength - 1; i++) { | ||
let part = parts[i] | ||
if(! obj.hasOwnProperty(part)) { | ||
obj = false; | ||
return false; | ||
break | ||
} | ||
obj = obj[k]; | ||
}); | ||
obj = obj[part]; | ||
} | ||
} | ||
@@ -54,0 +58,0 @@ return obj ? (typeof obj[k] !== 'undefined' ? obj[k] : def) : def; |
{ | ||
"name": "dot2val", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Set or get a value within a deeply nested object using `dot' notation", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7241
93