1e3f11c10d5f351a681c81303b8149e952977d05
[platform/framework/web/crosswalk-tizen.git] /
1 /**
2  * Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
3  * of an array-like value.
4  */
5 var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
6
7 /**
8  * Checks if `value` is a valid array-like length.
9  *
10  * **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength).
11  *
12  * @private
13  * @param {*} value The value to check.
14  * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
15  */
16 function isLength(value) {
17   return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
18 }
19
20 module.exports = isLength;