Comparing version 2.4.0 to 3.0.0
18
index.js
@@ -12,5 +12,19 @@ 'use strict'; | ||
for (var i = 0; i < pathArr.length; i++) { | ||
var descriptor = Object.getOwnPropertyDescriptor(obj, pathArr[i]) || Object.getOwnPropertyDescriptor(Object.prototype, pathArr[i]); | ||
if (descriptor && !descriptor.enumerable) { | ||
return; | ||
} | ||
obj = obj[pathArr[i]]; | ||
if (obj === undefined) { | ||
if (obj === undefined || obj === null) { | ||
// `obj` is either `undefined` or `null` so we want to stop the loop, and | ||
// if this is not the last bit of the path, and | ||
// if it did't return `undefined` | ||
// it would return `null` if `obj` is `null` | ||
// but we want `get({foo: null}, 'foo.bar')` to equal `undefined` not `null` | ||
if (i !== pathArr.length - 1) { | ||
return undefined; | ||
} | ||
break; | ||
@@ -89,3 +103,3 @@ } | ||
while (p[p.length - 1] === '\\') { | ||
while (p[p.length - 1] === '\\' && pathArr[i + 1] !== undefined) { | ||
p = p.slice(0, -1) + '.'; | ||
@@ -92,0 +106,0 @@ p += pathArr[++i]; |
{ | ||
"name": "dot-prop", | ||
"version": "2.4.0", | ||
"version": "3.0.0", | ||
"description": "Get, set, or delete a property from a nested object using a dot path", | ||
@@ -16,3 +16,3 @@ "license": "MIT", | ||
"scripts": { | ||
"test": "ava && xo", | ||
"test": "xo && ava", | ||
"bench": "matcha bench.js" | ||
@@ -43,5 +43,5 @@ }, | ||
"ava": "*", | ||
"matcha": "^0.6.1", | ||
"matcha": "^0.7.0", | ||
"xo": "*" | ||
} | ||
} |
@@ -61,3 +61,3 @@ # dot-prop [![Build Status](https://travis-ci.org/sindresorhus/dot-prop.svg?branch=master)](https://travis-ci.org/sindresorhus/dot-prop) | ||
Type: `object` | ||
Type: `Object` | ||
@@ -70,4 +70,6 @@ Object to get, set, or delete the `path` value. | ||
Path of the property in the object. Use `.` for nested objects or `\\.` to add a `.` in a key. | ||
Path of the property in the object, using `.` to separate each nested key. | ||
Use `\\.` if you have a `.` in the key. | ||
#### value | ||
@@ -82,2 +84,2 @@ | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
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
5429
83
83