Sha256: 0f5dce93adc9aa4b43003c2669e06e2eda1455e4167a12aa703324f578ecbfe1
Contents?: true
Size: 880 Bytes
Versions: 299
Compression:
Stored size: 880 Bytes
Contents
var isArray = require('./isArray'), isSymbol = require('./isSymbol'); /** Used to match property names within property paths. */ var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/; /** * Checks if `value` is a property name and not a property path. * * @private * @param {*} value The value to check. * @param {Object} [object] The object to query keys on. * @returns {boolean} Returns `true` if `value` is a property name, else `false`. */ function isKey(value, object) { if (isArray(value)) { return false; } var type = typeof value; if (type == 'number' || type == 'symbol' || type == 'boolean' || value == null || isSymbol(value)) { return true; } return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || (object != null && value in Object(object)); } module.exports = isKey;
Version data entries
299 entries across 276 versions & 32 rubygems