Comparing version 2.0.1 to 2.0.2
39
index.js
@@ -8,7 +8,21 @@ /*! | ||
module.exports = function(obj, prop) { | ||
if (!isObject(obj)) { return obj; } | ||
var segs = toSegments(prop); | ||
if (segs === null) return obj; | ||
module.exports = function(obj, prop, a, b, c) { | ||
if (!isObject(obj) || !prop) { | ||
return obj; | ||
} | ||
prop = toString(prop); | ||
// allowing for multiple properties to be passed as | ||
// a string or array, but much faster (3-4x) than doing | ||
// `[].slice.call(arguments)` | ||
if (a) prop += '.' + toString(a); | ||
if (b) prop += '.' + toString(b); | ||
if (c) prop += '.' + toString(c); | ||
if (prop in obj) { | ||
return obj[prop]; | ||
} | ||
var segs = prop.split('.'); | ||
var len = segs.length; | ||
@@ -27,12 +41,2 @@ var i = -1; | ||
function toSegments(val) { | ||
if (Array.isArray(val)) { | ||
return val.join('.').split('.'); | ||
} | ||
if (typeof val === 'string') { | ||
return val.split('.'); | ||
} | ||
return null; | ||
} | ||
function isObject(val) { | ||
@@ -42,1 +46,8 @@ return val !== null && (typeof val === 'object' || typeof val === 'function'); | ||
function toString(val) { | ||
if (!val) return ''; | ||
if (Array.isArray(val)) { | ||
return val.join('.'); | ||
} | ||
return val; | ||
} |
{ | ||
"name": "get-value", | ||
"description": "Use property paths (`a.b.c`) to get a nested value from an object.", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"homepage": "https://github.com/jonschlinkert/get-value", | ||
@@ -67,2 +67,2 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
} | ||
} | ||
} |
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
5998
42