dot-object
Advanced tools
Comparing version 0.6.0 to 0.7.0
@@ -104,3 +104,3 @@ 'use strict'; | ||
for (i = 0; i < keys.length; i++) { | ||
if (obj.hasOwnProperty(keys[i])) { | ||
if (obj && typeof obj === 'object' && keys[i] in obj) { | ||
if (i === (keys.length - 1)) { | ||
@@ -107,0 +107,0 @@ if (remove) { |
{ | ||
"name": "dot-object", | ||
"description": "dot-object makes it possible to transform and read (JSON) objects using dot notation.", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Rob Halff", |
@@ -39,2 +39,63 @@ 'use strict'; | ||
it('Should be able to pick null properties', function() { | ||
var dj = new DJ(); | ||
var obj = { | ||
'some': null | ||
}; | ||
var val = dj.pick('some', obj); | ||
(val === null).should.be.true; | ||
}); | ||
it('Should return undefined when picking an non-existing value', function() { | ||
var dj = new DJ(); | ||
var obj = { | ||
'some': null | ||
}; | ||
var val = dj.pick('other', obj); | ||
(val === undefined).should.be.true; | ||
}); | ||
it('Should return undefined when picking an non-existing dotted value', function() { | ||
var dj = new DJ(); | ||
var obj = { | ||
'some': null | ||
}; | ||
var val = dj.pick('some.other', obj); | ||
(val === undefined).should.be.true; | ||
}); | ||
it('Should check down the object\'s prototype chain', function() { | ||
var dj = new DJ(); | ||
var obj = { | ||
'some': { | ||
'other': 'value' | ||
} | ||
}; | ||
var objIns = Object.create(obj); | ||
objIns.should.have.property('some'); | ||
var val = dj.pick('some.other', objIns); | ||
val.should.be.an.Object; | ||
}); | ||
}); |
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
22787
12
606