Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

_isKey.js 880B

1234567891011121314151617181920212223242526272829
  1. var isArray = require('./isArray'),
  2. isSymbol = require('./isSymbol');
  3. /** Used to match property names within property paths. */
  4. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  5. reIsPlainProp = /^\w*$/;
  6. /**
  7. * Checks if `value` is a property name and not a property path.
  8. *
  9. * @private
  10. * @param {*} value The value to check.
  11. * @param {Object} [object] The object to query keys on.
  12. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  13. */
  14. function isKey(value, object) {
  15. if (isArray(value)) {
  16. return false;
  17. }
  18. var type = typeof value;
  19. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  20. value == null || isSymbol(value)) {
  21. return true;
  22. }
  23. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  24. (object != null && value in Object(object));
  25. }
  26. module.exports = isKey;