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:
878 bytes
|
Line | |
---|
1 | import isArray from './isArray.js';
|
---|
2 | import isSymbol from './isSymbol.js';
|
---|
3 |
|
---|
4 | /** Used to match property names within property paths. */
|
---|
5 | var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
|
---|
6 | reIsPlainProp = /^\w*$/;
|
---|
7 |
|
---|
8 | /**
|
---|
9 | * Checks if `value` is a property name and not a property path.
|
---|
10 | *
|
---|
11 | * @private
|
---|
12 | * @param {*} value The value to check.
|
---|
13 | * @param {Object} [object] The object to query keys on.
|
---|
14 | * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
|
---|
15 | */
|
---|
16 | function isKey(value, object) {
|
---|
17 | if (isArray(value)) {
|
---|
18 | return false;
|
---|
19 | }
|
---|
20 | var type = typeof value;
|
---|
21 | if (type == 'number' || type == 'symbol' || type == 'boolean' ||
|
---|
22 | value == null || isSymbol(value)) {
|
---|
23 | return true;
|
---|
24 | }
|
---|
25 | return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
|
---|
26 | (object != null && value in Object(object));
|
---|
27 | }
|
---|
28 |
|
---|
29 | export default isKey;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.