* numeric index string; otherwise, returns undefined.
*
* There is no clamping of the numeric index, but note that numbers
- * above 2^53 − 1 are not safe nor valid integer indices.
+ * above 2^53 − 1 are not safe nor valid integer indices.
*/
export const canonicalNumericIndexString = ($) => {
if (typeof $ !== "string") {
}
};
+/** Returns whether the provided value is arraylike. */
+export const isArraylikeObject = ($) => {
+ if (type($) !== "object") {
+ return false;
+ } else {
+ try {
+ lengthOfArraylike($); // throws if not arraylike
+ return true;
+ } catch {
+ return false;
+ }
+ }
+};
+
/**
* Returns whether the provided object is a collection.
*
* The definition of “collection” used by Piscēs is similar to
* Ecmascript’s definition of an arraylike object, but it differs in
- * a few ways :—
+ * a few ways :—
*
* - It requires the provided value to be a proper object.
*
* This can produce larger lengths than can actually be stored in
* arrays, because no such restrictions exist on arraylike methods.
*/
-export const lengthOfArrayLike = ({ length }) => toLength(length);
+export const lengthOfArraylike = ({ length }) => toLength(length);
/**
* Returns the result of mapping the provided value with the provided