2f04aca810f31b0e2a45b8aedbcb7d806c3fe598
[yaffs-website] / node_modules / grunt-legacy-util / node_modules / lodash / isLength.js
1 /** Used as references for various `Number` constants. */
2 var MAX_SAFE_INTEGER = 9007199254740991;
3
4 /**
5  * Checks if `value` is a valid array-like length.
6  *
7  * **Note:** This function is loosely based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
8  *
9  * @static
10  * @memberOf _
11  * @category Lang
12  * @param {*} value The value to check.
13  * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
14  * @example
15  *
16  * _.isLength(3);
17  * // => true
18  *
19  * _.isLength(Number.MIN_VALUE);
20  * // => false
21  *
22  * _.isLength(Infinity);
23  * // => false
24  *
25  * _.isLength('3');
26  * // => false
27  */
28 function isLength(value) {
29   return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
30 }
31
32 module.exports = isLength;