]> Lady’s Gitweb - Pisces/commitdiff
Simplify implementation of defineOwnProperties
authorLady <redacted>
Sun, 19 Nov 2023 16:04:50 +0000 (11:04 -0500)
committerLady <redacted>
Sun, 19 Nov 2023 16:04:50 +0000 (11:04 -0500)
There was no reason to create a custom iterable here; just iterate the
splat array manually.

object.js

index 3052f15030bd5a2606684f8a9342a4622a89952a..9c0c973b6fd11c9bc6b9871035c4081a95a878a4 100644 (file)
--- a/object.js
+++ b/object.js
@@ -501,24 +501,9 @@ export const {
     isSealed,
     setPrototypeOf,
   } = Object;
-  const { [ITERATOR]: arrayIterator } = Array.prototype;
-  const { next: arrayIteratorNext } = getPrototypeOf([][ITERATOR]());
   const {
     next: generatorIteratorNext,
   } = getPrototypeOf(function* () {}.prototype);
-  const splatIterablePrototype = {
-    [ITERATOR]() {
-      return {
-        next: bind(
-          arrayIteratorNext,
-          call(arrayIterator, this.args, []),
-          [],
-        ),
-      };
-    },
-  };
-  const splatIterable = ($) =>
-    create(splatIterablePrototype, { args: { value: $ } });
   const propertyDescriptorEntryIterablePrototype = {
     [ITERATOR]() {
       return {
@@ -533,8 +518,9 @@ export const {
 
   return {
     defineOwnProperties: (O, ...sources) => {
-      for (const source of splatIterable(sources)) {
-        defineProperties(O, source);
+      const { length } = sources;
+      for (let index = 0; index < length; ++index) {
+        defineProperties(O, sources[index]);
       }
       return O;
     },
This page took 0.086908 seconds and 4 git commands to generate.