diff options
Diffstat (limited to 'tools/eslint/node_modules/lodash/isLength.js')
-rw-r--r-- | tools/eslint/node_modules/lodash/isLength.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tools/eslint/node_modules/lodash/isLength.js b/tools/eslint/node_modules/lodash/isLength.js new file mode 100644 index 0000000000..2f04aca810 --- /dev/null +++ b/tools/eslint/node_modules/lodash/isLength.js @@ -0,0 +1,32 @@ +/** Used as references for various `Number` constants. */ +var MAX_SAFE_INTEGER = 9007199254740991; + +/** + * Checks if `value` is a valid array-like length. + * + * **Note:** This function is loosely based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. + * @example + * + * _.isLength(3); + * // => true + * + * _.isLength(Number.MIN_VALUE); + * // => false + * + * _.isLength(Infinity); + * // => false + * + * _.isLength('3'); + * // => false + */ +function isLength(value) { + return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; +} + +module.exports = isLength; |