]> Lady’s Gitweb - Pisces/blobdiff - iterable.js
Add methods for own entries and values to object.js
[Pisces] / iterable.js
index 2eb9aa46120f0183796623854769d2e8f5f94cf7..7149a28fb4b836ee47f1c3a5aa7ad76a688fbb5b 100644 (file)
@@ -9,11 +9,13 @@
 
 import { bind, call, identity } from "./function.js";
 import {
+  defineOwnDataProperty,
   defineOwnProperty,
   getPrototype,
   objectCreate,
+  setPropertyValues,
 } from "./object.js";
-import { ITERATOR, TO_STRING_TAG } from "./value.js";
+import { ITERATOR, TO_STRING_TAG, UNDEFINED } from "./value.js";
 
 export const {
   /**
@@ -228,7 +230,7 @@ export const {
         const nextIterator = this.#nextIterator;
         if (baseIterator === null) {
           // The base iterator has already been exhausted.
-          return { value: undefined, done: true };
+          return { value: UNDEFINED, done: true };
         } else if (nextIterator === null) {
           // This iterator is not currently yielding values from the
           // provided generator function, either because it doesn’t
@@ -296,20 +298,20 @@ export const {
     objectCreate(
       iteratorPrototype,
       {
-        next: {
+        next: setPropertyValues(objectCreate(null), {
           configurable: true,
           enumerable: false,
           value: function next() {
             return call(iteratorNext, this, []);
           },
           writable: true,
-        },
-        [TO_STRING_TAG]: {
+        }),
+        [TO_STRING_TAG]: setPropertyValues(objectCreate(null), {
           configurable: true,
           enumerable: false,
           value: stringTag,
           writable: false,
-        },
+        }),
       },
     );
 
@@ -330,7 +332,7 @@ export const {
     stringTag = "Iterator",
   ) => {
     const prototype = makePrototype(stringTag); // intentionally cached
-    return ($, thisArg = undefined) =>
+    return ($, thisArg = UNDEFINED) =>
       new Iterator(
         prototype,
         call(makeBaseIterator, $, []),
@@ -343,16 +345,20 @@ export const {
     arrayIteratorFunction: defineOwnProperty(
       bind(
         iteratorFunction,
-        undefined,
+        UNDEFINED,
         [arrayIterator, arrayIteratorNext],
       ),
       "name",
-      { value: "arrayIteratorFunction" },
+      defineOwnDataProperty(
+        objectCreate(null),
+        "value",
+        "arrayIteratorFunction",
+      ),
     ),
     generatorIteratorFunction: defineOwnProperty(
       bind(
         iteratorFunction,
-        undefined,
+        UNDEFINED,
         [
           function () {
             return this();
@@ -361,34 +367,50 @@ export const {
         ],
       ),
       "name",
-      { value: "generatorIteratorFunction" },
+      defineOwnDataProperty(
+        objectCreate(null),
+        "value",
+        "generatorIteratorFunction",
+      ),
     ),
     mapIteratorFunction: defineOwnProperty(
       bind(
         iteratorFunction,
-        undefined,
+        UNDEFINED,
         [mapIterator, mapIteratorNext],
       ),
       "name",
-      { value: "mapIteratorFunction" },
+      defineOwnDataProperty(
+        objectCreate(null),
+        "value",
+        "mapIteratorFunction",
+      ),
     ),
     setIteratorFunction: defineOwnProperty(
       bind(
         iteratorFunction,
-        undefined,
+        UNDEFINED,
         [setIterator, setIteratorNext],
       ),
       "name",
-      { value: "setIteratorFunction" },
+      defineOwnDataProperty(
+        objectCreate(null),
+        "value",
+        "setIteratorFunction",
+      ),
     ),
     stringIteratorFunction: defineOwnProperty(
       bind(
         iteratorFunction,
-        undefined,
+        UNDEFINED,
         [stringIterator, stringIteratorNext],
       ),
       "name",
-      { value: "stringIteratorFunction" },
+      defineOwnDataProperty(
+        objectCreate(null),
+        "value",
+        "stringIteratorFunction",
+      ),
     ),
   };
 })();
This page took 0.0291 seconds and 4 git commands to generate.