// file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
import { call, createCallableFunction } from "./function.js";
+import { isConcatSpreadableObject } from "./object.js";
import { toIndex, type } from "./value.js";
const { prototype: arrayPrototype } = Array;
"indices",
);
-
/**
* Returns whether the provided object is a collection.
*
} 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`.