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.

toInteger.js 760B

123456789101112131415161718192021222324252627282930313233343536
  1. var toFinite = require('./toFinite');
  2. /**
  3. * Converts `value` to an integer.
  4. *
  5. * **Note:** This method is loosely based on
  6. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  7. *
  8. * @static
  9. * @memberOf _
  10. * @since 4.0.0
  11. * @category Lang
  12. * @param {*} value The value to convert.
  13. * @returns {number} Returns the converted integer.
  14. * @example
  15. *
  16. * _.toInteger(3.2);
  17. * // => 3
  18. *
  19. * _.toInteger(Number.MIN_VALUE);
  20. * // => 0
  21. *
  22. * _.toInteger(Infinity);
  23. * // => 1.7976931348623157e+308
  24. *
  25. * _.toInteger('3.2');
  26. * // => 3
  27. */
  28. function toInteger(value) {
  29. var result = toFinite(value),
  30. remainder = result % 1;
  31. return result === result ? (remainder ? result - remainder : result) : 0;
  32. }
  33. module.exports = toInteger;