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:
947 bytes
|
Line | |
---|
1 | import isInteger from './isInteger.js';
|
---|
2 |
|
---|
3 | /** Used as references for various `Number` constants. */
|
---|
4 | var MAX_SAFE_INTEGER = 9007199254740991;
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
|
---|
8 | * double precision number which isn't the result of a rounded unsafe integer.
|
---|
9 | *
|
---|
10 | * **Note:** This method is based on
|
---|
11 | * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
|
---|
12 | *
|
---|
13 | * @static
|
---|
14 | * @memberOf _
|
---|
15 | * @since 4.0.0
|
---|
16 | * @category Lang
|
---|
17 | * @param {*} value The value to check.
|
---|
18 | * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
|
---|
19 | * @example
|
---|
20 | *
|
---|
21 | * _.isSafeInteger(3);
|
---|
22 | * // => true
|
---|
23 | *
|
---|
24 | * _.isSafeInteger(Number.MIN_VALUE);
|
---|
25 | * // => false
|
---|
26 | *
|
---|
27 | * _.isSafeInteger(Infinity);
|
---|
28 | * // => false
|
---|
29 | *
|
---|
30 | * _.isSafeInteger('3');
|
---|
31 | * // => false
|
---|
32 | */
|
---|
33 | function isSafeInteger(value) {
|
---|
34 | return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
|
---|
35 | }
|
---|
36 |
|
---|
37 | export default isSafeInteger;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.