PageRenderTime 28ms CodeModel.GetById 20ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/node_modules/lodash/isSafeInteger.js

https://bitbucket.org/coleman333/smartsite
JavaScript | 37 lines | 6 code | 3 blank | 28 comment | 2 complexity | 846016550092560b7743e3a58d56f72c MD5 | raw file
 1var isInteger = require('./isInteger');
 2
 3/** Used as references for various `Number` constants. */
 4var 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 */
33function isSafeInteger(value) {
34  return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
35}
36
37module.exports = isSafeInteger;