mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
Cleanup _.toInteger and max MAX_INTEGER equal to Number.MAX_VALUE.
This commit is contained in:
11
lodash.js
11
lodash.js
@@ -54,7 +54,7 @@
|
||||
/** Used as references for various `Number` constants. */
|
||||
var INFINITY = 1 / 0,
|
||||
MAX_SAFE_INTEGER = 9007199254740991,
|
||||
MAX_INTEGER = 1e308;
|
||||
MAX_INTEGER = 1.7976931348623157e+308;
|
||||
|
||||
/** Used as references for the maximum length and index of an array. */
|
||||
var MAX_ARRAY_LENGTH = 4294967295,
|
||||
@@ -9837,13 +9837,14 @@
|
||||
* // => 0
|
||||
*
|
||||
* _.toInteger(-Infinity)
|
||||
* // => -1e308
|
||||
* // => 1.7976931348623157e+308
|
||||
*/
|
||||
function toInteger(value) {
|
||||
if (value === INFINITY || value === -INFINITY) {
|
||||
return (value < 0 ? -1 : 1) * MAX_INTEGER;
|
||||
}
|
||||
value = +value;
|
||||
if (value === INFINITY || value === -INFINITY) {
|
||||
var sign = (value < 0 ? -1 : 1);
|
||||
return sign * MAX_INTEGER;
|
||||
}
|
||||
var remainder = value % 1;
|
||||
return value === value ? (remainder ? value - remainder : value) : 0;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
/** Used as references for various `Number` constants. */
|
||||
var MAX_SAFE_INTEGER = 9007199254740991,
|
||||
MAX_INTEGER = 1e308;
|
||||
MAX_INTEGER = 1.7976931348623157e+308;
|
||||
|
||||
/** Used as references for the maximum length and index of an array. */
|
||||
var MAX_ARRAY_LENGTH = 4294967295,
|
||||
|
||||
Reference in New Issue
Block a user