Projekt

Obecné

Profil

Stáhnout (880 Bajtů) Statistiky
| Větev: | Revize:
1
var isArray = require('./isArray'),
2
    isSymbol = require('./isSymbol');
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
module.exports = isKey;
(225-225/590)