Skip to content

Commit

Permalink
allow implementations to avoid creating String wrapper objects (#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelficarra committed Jul 11, 2023
1 parent 0938104 commit 3e275cf
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions spec.html
Expand Up @@ -129,12 +129,14 @@ <h1>
<h1>
GetIteratorFlattenable (
_obj_: an ECMAScript language value,
_stringHandling_: ~iterate-strings~ or ~reject-strings~,
): either a normal completion containing an Iterator Record or a throw completion
</h1>
<dl class="header">
</dl>
<emu-alg>
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_.
Expand Down Expand Up @@ -187,8 +189,7 @@ <h1>Iterator.prototype</h1>
<emu-clause id="sec-iterator.from">
<h1>Iterator.from ( _O_ )</h1>
<emu-alg>
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]].
Expand Down Expand Up @@ -415,7 +416,7 @@ <h1>Iterator.prototype.flatMap ( _mapper_ )</h1>
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*,
Expand Down

0 comments on commit 3e275cf

Please sign in to comment.