Skip to content
This repository was archived by the owner on Oct 8, 2024. It is now read-only.

Commit 3e275cf

Browse files
allow implementations to avoid creating String wrapper objects (#281)
1 parent 0938104 commit 3e275cf

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

spec.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,14 @@ <h1>
129129
<h1>
130130
GetIteratorFlattenable (
131131
_obj_: an ECMAScript language value,
132+
_stringHandling_: ~iterate-strings~ or ~reject-strings~,
132133
): either a normal completion containing an Iterator Record or a throw completion
133134
</h1>
134135
<dl class="header">
135136
</dl>
136137
<emu-alg>
137-
1. If _obj_ is not an Object, throw a *TypeError* exception.
138+
1. If _obj_ is not an Object, then
139+
1. If _stringHandling_ is ~reject-strings~ or _obj_ is not a String, throw a *TypeError* exception.
138140
1. Let _method_ be ? GetMethod(_obj_, @@iterator).
139141
1. If _method_ is *undefined*, then
140142
1. Let _iterator_ be _obj_.
@@ -187,8 +189,7 @@ <h1>Iterator.prototype</h1>
187189
<emu-clause id="sec-iterator.from">
188190
<h1>Iterator.from ( _O_ )</h1>
189191
<emu-alg>
190-
1. If _O_ is a String, set _O_ to ! ToObject(_O_).
191-
1. Let _iteratorRecord_ be ? GetIteratorFlattenable(_O_).
192+
1. Let _iteratorRecord_ be ? GetIteratorFlattenable(_O_, ~iterate-strings~).
192193
1. Let _hasInstance_ be ? OrdinaryHasInstance(%Iterator%, _iteratorRecord_.[[Iterator]]).
193194
1. If _hasInstance_ is *true*, then
194195
1. Return _iteratorRecord_.[[Iterator]].
@@ -415,7 +416,7 @@ <h1>Iterator.prototype.flatMap ( _mapper_ )</h1>
415416
1. Let _value_ be ? IteratorValue(_next_).
416417
1. Let _mapped_ be Completion(Call(_mapper_, *undefined*, « _value_, 𝔽(_counter_) »)).
417418
1. IfAbruptCloseIterator(_mapped_, _iterated_).
418-
1. Let _innerIterator_ be Completion(GetIteratorFlattenable(_mapped_)).
419+
1. Let _innerIterator_ be Completion(GetIteratorFlattenable(_mapped_, ~reject-strings~)).
419420
1. IfAbruptCloseIterator(_innerIterator_, _iterated_).
420421
1. Let _innerAlive_ be *true*.
421422
1. Repeat, while _innerAlive_ is *true*,

0 commit comments

Comments
 (0)