source: trip-planner-front/node_modules/lodash/toInteger.js@ ceaed42

Last change on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

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