- if (value !== undefined) {
- // The provided value is a canonical numeric index string.
- return sameValue(value, 0) || value > 0 && value < -1 >>> 0 &&
- value === toLength(value);
+ if (value !== UNDEFINED) {
+ // The provided value is a canonical numeric index string; return
+ // whether it is in range for array indices.
+ return sameValue(value, 0) ||
+ value === toLength(value) && value > 0 && value < -1 >>> 0;
+ } else {
+ // The provided value is not a canonical numeric index string.
+ return false;
+ }
+};
+
+/** Returns whether the provided value is an integer index string. */
+export const isIntegerIndexString = ($) => {
+ const value = canonicalNumericIndexString($);
+ if (value !== UNDEFINED) {
+ // The provided value is a canonical numeric index string; return
+ // whether it is in range for integer indices.
+ return sameValue(value, 0) ||
+ value === toLength(value) && value > 0;