From 3e275cfde3484109293ca885f796ed102304578a Mon Sep 17 00:00:00 2001 From: Michael Ficarra Date: Wed, 12 Jul 2023 00:12:46 +0200 Subject: [PATCH] allow implementations to avoid creating String wrapper objects (#281) --- spec.html | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spec.html b/spec.html index e8480c7..c64c64d 100644 --- a/spec.html +++ b/spec.html @@ -129,12 +129,14 @@

GetIteratorFlattenable ( _obj_: an ECMAScript language value, + _stringHandling_: ~iterate-strings~ or ~reject-strings~, ): either a normal completion containing an Iterator Record or a throw completion

- 1. If _obj_ is not an Object, throw a *TypeError* exception. + 1. If _obj_ is not an Object, then + 1. If _stringHandling_ is ~reject-strings~ or _obj_ is not a String, throw a *TypeError* exception. 1. Let _method_ be ? GetMethod(_obj_, @@iterator). 1. If _method_ is *undefined*, then 1. Let _iterator_ be _obj_. @@ -187,8 +189,7 @@

Iterator.prototype

Iterator.from ( _O_ )

- 1. If _O_ is a String, set _O_ to ! ToObject(_O_). - 1. Let _iteratorRecord_ be ? GetIteratorFlattenable(_O_). + 1. Let _iteratorRecord_ be ? GetIteratorFlattenable(_O_, ~iterate-strings~). 1. Let _hasInstance_ be ? OrdinaryHasInstance(%Iterator%, _iteratorRecord_.[[Iterator]]). 1. If _hasInstance_ is *true*, then 1. Return _iteratorRecord_.[[Iterator]]. @@ -415,7 +416,7 @@

Iterator.prototype.flatMap ( _mapper_ )

1. Let _value_ be ? IteratorValue(_next_). 1. Let _mapped_ be Completion(Call(_mapper_, *undefined*, « _value_, 𝔽(_counter_) »)). 1. IfAbruptCloseIterator(_mapped_, _iterated_). - 1. Let _innerIterator_ be Completion(GetIteratorFlattenable(_mapped_)). + 1. Let _innerIterator_ be Completion(GetIteratorFlattenable(_mapped_, ~reject-strings~)). 1. IfAbruptCloseIterator(_innerIterator_, _iterated_). 1. Let _innerAlive_ be *true*. 1. Repeat, while _innerAlive_ is *true*,