object-path
Advanced tools
Comparing version 0.8.0 to 0.8.1
@@ -77,5 +77,5 @@ (function (root, factory){ | ||
if (isString(path)) { | ||
return set(obj, path.split('.'), value, doNotReplace); | ||
return set(obj, path.split('.').map(getKey), value, doNotReplace); | ||
} | ||
var currentPath = getKey(path[0]); | ||
var currentPath = path[0]; | ||
@@ -92,4 +92,3 @@ if (path.length === 1) { | ||
//check if we assume an array | ||
var nextPath = getKey(path[1]); | ||
if(isNumber(nextPath)) { | ||
if(isNumber(path[1])) { | ||
obj[currentPath] = []; | ||
@@ -96,0 +95,0 @@ } else { |
{ | ||
"name": "object-path", | ||
"description": "Access deep properties using a path", | ||
"version": "0.8.0", | ||
"version": "0.8.1", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Mario Casciaro" |
12
test.js
@@ -151,4 +151,4 @@ var expect = require('chai').expect, | ||
obj = getTestObj(); | ||
objectPath.set(obj, ['c','0',1,'m'], 'l'); | ||
expect(obj.c).to.be.an('array'); | ||
objectPath.set(obj, ['c','0', 1,'m'], 'l'); | ||
expect(obj.c).to.be.an('object'); | ||
expect(obj.c[0]).to.be.an('array'); | ||
@@ -222,2 +222,10 @@ expect(obj).to.have.deep.property('c.0.1.m', 'l'); | ||
}); | ||
it('Issue #26', function() { | ||
var any = {}; | ||
objectPath.ensureExists(any, ['1','1'], {}); | ||
expect(any).to.be.an('object'); | ||
expect(any[1]).to.be.an('object'); | ||
expect(any[1][1]).to.be.an('object'); | ||
}); | ||
}); | ||
@@ -224,0 +232,0 @@ |
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
27225
686