summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/node_modules/lodash/_isIndex.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/node_modules/eslint/node_modules/lodash/_isIndex.js')
-rw-r--r--tools/node_modules/eslint/node_modules/lodash/_isIndex.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/node_modules/eslint/node_modules/lodash/_isIndex.js b/tools/node_modules/eslint/node_modules/lodash/_isIndex.js
new file mode 100644
index 0000000000..e123dde8bc
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/lodash/_isIndex.js
@@ -0,0 +1,22 @@
+/** Used as references for various `Number` constants. */
+var MAX_SAFE_INTEGER = 9007199254740991;
+
+/** Used to detect unsigned integer values. */
+var reIsUint = /^(?:0|[1-9]\d*)$/;
+
+/**
+ * Checks if `value` is a valid array-like index.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
+ * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
+ */
+function isIndex(value, length) {
+ length = length == null ? MAX_SAFE_INTEGER : length;
+ return !!length &&
+ (typeof value == 'number' || reIsUint.test(value)) &&
+ (value > -1 && value % 1 == 0 && value < length);
+}
+
+module.exports = isIndex;