X-Git-Url: https://git.ladys.computer/Pisces/blobdiff_plain/0fb1e53a1e78a6bf490cd95cf92a744d3ac6171f..beab7268e7673b036222e64aac924f850e2b976e:/collection.js?ds=sidebyside diff --git a/collection.js b/collection.js index 03326a6..d340709 100644 --- a/collection.js +++ b/collection.js @@ -8,6 +8,7 @@ // file, You can obtain one at . import { call, createCallableFunction } from "./function.js"; +import { isConcatSpreadableObject } from "./object.js"; import { toIndex, type } from "./value.js"; const { prototype: arrayPrototype } = Array; @@ -193,7 +194,6 @@ export const indices = createCallableFunction( "indices", ); - /** * Returns whether the provided object is a collection. * @@ -215,31 +215,13 @@ export const isCollection = ($) => { } else { try { toIndex($.length); // will throw if `length` is not an index - return isConcatSpreadable($); + return isConcatSpreadableObject($); } catch { return false; } } }; -/** - * Returns whether the provided value is spreadable during array - * concatenation. - * - * This is also used to determine which things should be treated as - * collections. - */ -export const isConcatSpreadable = ($) => { - if (type($) !== "object") { - // The provided value is not an object. - return false; - } else { - // The provided value is an object. - const spreadable = $[Symbol.isConcatSpreadable]; - return spreadable !== undefined ? !!spreadable : isArray($); - } -}; - /** * Returns an iterator over the items in the provided value according * to the algorithm of `Array::values`.