]> Lady’s Gitweb - Pisces/blobdiff - object.js
Move isConcatSpreadable[Object] into object.js
[Pisces] / object.js
index 9c0c973b6fd11c9bc6b9871035c4081a95a878a4..ee3d51da336d6f1c5a09123cd41b8ec921550f80 100644 (file)
--- a/object.js
+++ b/object.js
@@ -14,6 +14,7 @@ import {
   toFunctionName,
 } from "./function.js";
 import {
   toFunctionName,
 } from "./function.js";
 import {
+  IS_CONCAT_SPREADABLE,
   ITERATOR,
   SPECIES,
   toLength,
   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.
  *
 /**
  * Returns whether the provided object is extensible.
  *
This page took 0.019867 seconds and 4 git commands to generate.