main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
755 bytes
|
Rev | Line | |
---|
[d565449] | 1 | import baseHas from './_baseHas.js';
|
---|
| 2 | import hasPath from './_hasPath.js';
|
---|
| 3 |
|
---|
| 4 | /**
|
---|
| 5 | * Checks if `path` is a direct property of `object`.
|
---|
| 6 | *
|
---|
| 7 | * @static
|
---|
| 8 | * @since 0.1.0
|
---|
| 9 | * @memberOf _
|
---|
| 10 | * @category Object
|
---|
| 11 | * @param {Object} object The object to query.
|
---|
| 12 | * @param {Array|string} path The path to check.
|
---|
| 13 | * @returns {boolean} Returns `true` if `path` exists, else `false`.
|
---|
| 14 | * @example
|
---|
| 15 | *
|
---|
| 16 | * var object = { 'a': { 'b': 2 } };
|
---|
| 17 | * var other = _.create({ 'a': _.create({ 'b': 2 }) });
|
---|
| 18 | *
|
---|
| 19 | * _.has(object, 'a');
|
---|
| 20 | * // => true
|
---|
| 21 | *
|
---|
| 22 | * _.has(object, 'a.b');
|
---|
| 23 | * // => true
|
---|
| 24 | *
|
---|
| 25 | * _.has(object, ['a', 'b']);
|
---|
| 26 | * // => true
|
---|
| 27 | *
|
---|
| 28 | * _.has(other, 'a');
|
---|
| 29 | * // => false
|
---|
| 30 | */
|
---|
| 31 | function has(object, path) {
|
---|
| 32 | return object != null && hasPath(object, path, baseHas);
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | export default has;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.