X-Git-Url: https://git.ladys.computer/Pisces/blobdiff_plain/f1283dfa8f4f1482dac6325fbcb66f8778af1002..fb3e0d562e2dbe9e3ea911a80bfdabc8851f92b2:/collection.js?ds=inline 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