mirror of
https://github.com/atlanticbiomedical/biomedjs.git
synced 2025-07-02 00:47:26 -04:00
21 lines
667 B
JavaScript
21 lines
667 B
JavaScript
![]() |
/**
|
||
|
* Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
|
||
|
* of an array-like value.
|
||
|
*/
|
||
|
var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
|
||
|
|
||
|
/**
|
||
|
* Checks if `value` is a valid array-like length.
|
||
|
*
|
||
|
* **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength).
|
||
|
*
|
||
|
* @private
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
|
||
|
*/
|
||
|
function isLength(value) {
|
||
|
return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
||
|
}
|
||
|
|
||
|
module.exports = isLength;
|