Cleanup hasPath modules.

This commit is contained in:
John-David Dalton
2017-02-27 23:01:51 -08:00
parent d8b5183b1d
commit 46ffbc1d90
2 changed files with 3 additions and 5 deletions

View File

@@ -30,13 +30,12 @@ const hasOwnProperty = Object.prototype.hasOwnProperty
function hasPath(object, path) { function hasPath(object, path) {
path = castPath(path, object) path = castPath(path, object)
let key
let index = -1 let index = -1
let length = path.length let length = path.length
let result = false let result = false
while (++index < length) { while (++index < length) {
key = toKey(path[index]) const key = toKey(path[index])
if (!(result = object != null && hasOwnProperty.call(object, key))) { if (!(result = object != null && hasOwnProperty.call(object, key))) {
break break
} }

View File

@@ -27,13 +27,12 @@ import toKey from './.internal/toKey.js'
function hasPathIn(object, path) { function hasPathIn(object, path) {
path = castPath(path, object) path = castPath(path, object)
let key
let index = -1 let index = -1
let length = path.length let length = path.length
let result = false let result = false
while (++index < length) { while (++index < length) {
key = toKey(path[index]) const key = toKey(path[index])
if (!(result = object != null && key in Object(object))) { if (!(result = object != null && key in Object(object))) {
break break
} }
@@ -47,4 +46,4 @@ function hasPathIn(object, path) {
(Array.isArray(object) || isArguments(object)) (Array.isArray(object) || isArguments(object))
} }
export default hasPath export default hasPathIn