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 {
/**
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
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,
- },
+ }),
},
);
stringTag = "Iterator",
) => {
const prototype = makePrototype(stringTag); // intentionally cached
- return ($, thisArg = undefined) =>
+ return ($, thisArg = UNDEFINED) =>
new Iterator(
prototype,
call(makeBaseIterator, $, []),
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();
],
),
"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",
+ ),
),
};
})();