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.

33 lines
669 B

преди 4 години
  1. var toInteger = require('./toInteger');
  2. /**
  3. * Checks if `value` is an integer.
  4. *
  5. * **Note:** This method is based on
  6. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  7. *
  8. * @static
  9. * @memberOf _
  10. * @since 4.0.0
  11. * @category Lang
  12. * @param {*} value The value to check.
  13. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  14. * @example
  15. *
  16. * _.isInteger(3);
  17. * // => true
  18. *
  19. * _.isInteger(Number.MIN_VALUE);
  20. * // => false
  21. *
  22. * _.isInteger(Infinity);
  23. * // => false
  24. *
  25. * _.isInteger('3');
  26. * // => false
  27. */
  28. function isInteger(value) {
  29. return typeof value == 'number' && value == toInteger(value);
  30. }
  31. module.exports = isInteger;