]> Lady’s Gitweb - Pisces/blobdiff - collection.js
Add methods for own entries and values to object.js
[Pisces] / collection.js
index 69c0beefabf16bd9d64fe57f17f82d8ab11dd3e7..d340709750c26f1ca902f0ee6d0d8eceae33b483 100644 (file)
@@ -8,7 +8,8 @@
 // file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
 
 import { call, createCallableFunction } from "./function.js";
-import { lengthOfArraylike, toIndex, type } from "./value.js";
+import { isConcatSpreadableObject } from "./object.js";
+import { toIndex, type } from "./value.js";
 
 const { prototype: arrayPrototype } = Array;
 
@@ -193,20 +194,6 @@ export const indices = createCallableFunction(
   "indices",
 );
 
-/** 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.
  *
@@ -228,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`.
This page took 0.02235 seconds and 4 git commands to generate.