1 | var isArray = require('./isArray'),
|
2 | isSymbol = require('./isSymbol');
|
3 |
|
4 |
|
5 | var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
|
6 | reIsPlainProp = /^\w*$/;
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
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 | module.exports = isKey;
|