X-Git-Url: https://git.ladys.computer/Pisces/blobdiff_plain/0fb1e53a1e78a6bf490cd95cf92a744d3ac6171f..beab7268e7673b036222e64aac924f850e2b976e:/object.js diff --git a/object.js b/object.js index 9c0c973..ee3d51d 100644 --- a/object.js +++ b/object.js @@ -14,6 +14,7 @@ import { toFunctionName, } from "./function.js"; import { + IS_CONCAT_SPREADABLE, ITERATOR, SPECIES, toLength, @@ -810,6 +811,32 @@ export const isArraylikeObject = ($) => { } }; +export const { + /** + * Returns whether the provided value is spreadable during array + * concatenation. + * + * This is also used to determine which things should be treated as + * collections. + */ + isConcatSpreadableObject, +} = (() => { + const { isArray } = Array; + + return { + isConcatSpreadableObject: ($) => { + if (type($) !== "object") { + // The provided value is not an object. + return false; + } else { + // The provided value is an object. + const spreadable = $[IS_CONCAT_SPREADABLE]; + return spreadable !== undefined ? !!spreadable : isArray($); + } + }, + }; +})(); + /** * Returns whether the provided object is extensible. *