X-Git-Url: https://git.ladys.computer/Pisces/blobdiff_plain/f0b1fb387c82349c2db70ae265dc6910b830a906..a63ba5294bd5cc847a192f6737bc386bfe7187f8:/collection.js diff --git a/collection.js b/collection.js index 20b6fef..38b048c 100644 --- a/collection.js +++ b/collection.js @@ -188,6 +188,20 @@ export const isArrayIndexString = ($) => { } }; +/** 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. * @@ -262,7 +276,7 @@ export const items = makeCallable(Array.prototype.values); * 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