source: imaps-frontend/node_modules/lodash-es/toInteger.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 758 bytes
Line 
1import toFinite from './toFinite.js';
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
36export default toInteger;
Note: See TracBrowser for help on using the repository browser.