Comparing version 0.0.5 to 0.0.6
{ | ||
"name": "getprop", | ||
"main": "getprop.js", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"homepage": "https://github.com/miguelmota/getprop", | ||
@@ -6,0 +6,0 @@ "authors": [ |
@@ -7,3 +7,5 @@ (function(root) { | ||
if (!(typeof s === 'string' || s instanceof String)) return d; | ||
var props = s.match(/(\[(.*?)\]|[0-9a-zA-Z_$]+)/gi).map(function(m) { return m.replace(/[\[\]]/gi,''); }); | ||
var props = s.match(/(\[(.*?)\]|[0-9a-zA-Z_$]+)/gi).map(function(m) { | ||
return m.replace(/[\[\]]/gi,''); | ||
}); | ||
@@ -16,3 +18,6 @@ var len = props.length, | ||
for (i = 0; i < len; i += 1) { | ||
if (typeof head[props[i]] === 'undefined') return d; | ||
if (typeof head[props[i]] === 'undefined' || | ||
head[props[i]] === null) { | ||
return d; | ||
} | ||
head = head[props[i]]; | ||
@@ -19,0 +24,0 @@ if (typeof head !== 'undefined') { |
{ | ||
"name": "get-prop", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Get a property from object", | ||
@@ -5,0 +5,0 @@ "main": "getprop.js", |
@@ -58,3 +58,4 @@ # getprop | ||
}, | ||
'foo.bar': 'noob' | ||
'foo.bar': 'noob', | ||
qax: null | ||
}; | ||
@@ -75,2 +76,3 @@ | ||
getProp(obj, '[foo.bar]') // 'noob' | ||
getProp(obj, 'qux.qux') // undefined | ||
``` | ||
@@ -77,0 +79,0 @@ |
@@ -5,3 +5,3 @@ var test = require('tape'); | ||
test('getProp', function (t) { | ||
t.plan(21); | ||
t.plan(22); | ||
@@ -29,3 +29,4 @@ var obj = { | ||
}, | ||
'foo.bar': 'noob' | ||
'foo.bar': 'noob', | ||
qax: null | ||
}; | ||
@@ -53,2 +54,3 @@ | ||
t.equal(getProp(obj, '[foo.bar]'), 'noob'); | ||
t.equal(getProp(obj, 'qax.quz'), undefined); | ||
@@ -55,0 +57,0 @@ // oldschool |
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
8217
122
81