Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
13 additions
and
57 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,24 @@ | ||
import baseHasIn from './.internal/baseHasIn.js' | ||
import hasPath from './.internal/hasPath.js' | ||
|
||
/** | ||
* Checks if `path` is a direct or inherited property of `object`. | ||
* | ||
* @since 4.0.0 | ||
* @category Object | ||
* @param {Object} object The object to query. | ||
* @param {Array|string} path The path to check. | ||
* @returns {boolean} Returns `true` if `path` exists, else `false`. | ||
* @see has, get, set, unset | ||
* @param {string} key The key to check. | ||
* @returns {boolean} Returns `true` if `key` exists, else `false`. | ||
* @see has, hasPath, hasPathIn | ||
* @example | ||
* | ||
* const object = create({ 'a': create({ 'b': 2 }) }) | ||
* | ||
* hasIn(object, 'a') | ||
* // => true | ||
* | ||
* hasIn(object, 'a.b') | ||
* // => true | ||
* | ||
* hasIn(object, ['a', 'b']) | ||
* // => true | ||
* | ||
* hasIn(object, 'b') | ||
* // => false | ||
*/ | ||
function hasIn(object, path) { | ||
return object != null && hasPath(object, path, baseHasIn) | ||
function hasIn(object, key) { | ||
return object != null && key in Object(object) | ||
} | ||
|
||
export default hasIn |
b6a426a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's pretty big change in functionality 😲
b6a426a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's splitting the functionality out into two modules (
has
andhasPath
).b6a426a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, somehow I missed next commit 😆
b6a426a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so folks don't have to pay the byte cost when they don't need the extra functionality.