From: Lady Date: Sun, 19 Nov 2023 16:04:50 +0000 (-0500) Subject: Simplify implementation of defineOwnProperties X-Git-Url: https://git.ladys.computer/Pisces/commitdiff_plain/0fb1e53a1e78a6bf490cd95cf92a744d3ac6171f Simplify implementation of defineOwnProperties There was no reason to create a custom iterable here; just iterate the splat array manually. --- diff --git a/object.js b/object.js index 3052f15..9c0c973 100644 --- 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; },