mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-29 21:49:17 +00:00
new Map, new Set, new WeakMap and new WeakSet read their argument by index (an array, a string or an object with a length), so a generator, a Map, a Set or any other iterable was a TypeError, and an array whose @@iterator was replaced was still read by index. They now read it through GetIterator and close the iterator when adding an entry throws (ECMAScript 2015, sections 23.1.1.1, 23.2.1.1, 23.3.1.1 and 23.4.1.1). A Map or WeakMap entry that is not an object is a TypeError. The typed array constructors and %TypedArray%.from read a source with an @@iterator method through its iterator to the end before mapping it, and any other source as an array-like object (sections 22.2.1.4 and 22.2.2.1). Map.prototype[@@iterator] is entries, Set.prototype[@@iterator] is values, %TypedArray%.prototype[@@iterator] is values, and the Map, Set and array iterators inherit %IteratorPrototype%, so for-of and spread walk them. Changed behavior: an array-like object without @@iterator passed to new Set or new Map is now a TypeError, and Uint8Array.from([1, 1], f) with an f that changes the array maps the values read before f ran.