isFinite.js 793 B

12345678910111213141516171819202122232425262728293031323334353637
  1. var root = require('./_root');
  2. /* Built-in method references for those with the same name as other `lodash` methods. */
  3. var nativeIsFinite = root.isFinite;
  4. /**
  5. * Checks if `value` is a finite primitive number.
  6. *
  7. * **Note:** This method is based on
  8. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  9. *
  10. * @static
  11. * @memberOf _
  12. * @since 0.1.0
  13. * @category Lang
  14. * @param {*} value The value to check.
  15. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  16. * @example
  17. *
  18. * _.isFinite(3);
  19. * // => true
  20. *
  21. * _.isFinite(Number.MIN_VALUE);
  22. * // => true
  23. *
  24. * _.isFinite(Infinity);
  25. * // => false
  26. *
  27. * _.isFinite('3');
  28. * // => false
  29. */
  30. function isFinite(value) {
  31. return typeof value == 'number' && nativeIsFinite(value);
  32. }
  33. module.exports = isFinite;