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

_isIndex.js 759B

12345678910111213141516171819202122232425
  1. /** Used as references for various `Number` constants. */
  2. var MAX_SAFE_INTEGER = 9007199254740991;
  3. /** Used to detect unsigned integer values. */
  4. var reIsUint = /^(?:0|[1-9]\d*)$/;
  5. /**
  6. * Checks if `value` is a valid array-like index.
  7. *
  8. * @private
  9. * @param {*} value The value to check.
  10. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  11. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  12. */
  13. function isIndex(value, length) {
  14. var type = typeof value;
  15. length = length == null ? MAX_SAFE_INTEGER : length;
  16. return !!length &&
  17. (type == 'number' ||
  18. (type != 'symbol' && reIsUint.test(value))) &&
  19. (value > -1 && value % 1 == 0 && value < length);
  20. }
  21. module.exports = isIndex;