Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

isLength.js 802B

1234567891011121314151617181920212223242526272829303132333435
  1. /** Used as references for various `Number` constants. */
  2. var MAX_SAFE_INTEGER = 9007199254740991;
  3. /**
  4. * Checks if `value` is a valid array-like length.
  5. *
  6. * **Note:** This method is loosely based on
  7. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  8. *
  9. * @static
  10. * @memberOf _
  11. * @since 4.0.0
  12. * @category Lang
  13. * @param {*} value The value to check.
  14. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  15. * @example
  16. *
  17. * _.isLength(3);
  18. * // => true
  19. *
  20. * _.isLength(Number.MIN_VALUE);
  21. * // => false
  22. *
  23. * _.isLength(Infinity);
  24. * // => false
  25. *
  26. * _.isLength('3');
  27. * // => false
  28. */
  29. function isLength(value) {
  30. return typeof value == 'number' &&
  31. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  32. }
  33. module.exports = isLength;