diff --git a/spec.html b/spec.html
index 9ecc527..5a9864c 100644
--- a/spec.html
+++ b/spec.html
@@ -552,14 +552,16 @@
Iterator.prototype.map ( _mapper_ )
1. Let _iterated_ be ? GetIteratorDirect(*this* value).
1. If IsCallable(_mapper_) is *false*, throw a *TypeError* exception.
1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterated_ and _mapper_ and performs the following steps when called:
+ 1. Let _counter_ be 0.
1. Repeat,
1. Let _next_ be ? IteratorStep(_iterated_).
1. If _next_ is *false*, return *undefined*.
1. Let _value_ be ? IteratorValue(_next_).
- 1. Let _mapped_ be Completion(Call(_mapper_, *undefined*, « _value_ »)).
+ 1. Let _mapped_ be Completion(Call(_mapper_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. IfAbruptCloseIterator(_mapped_, _iterated_).
1. Let _completion_ be Completion(Yield(_mapped_)).
1. IfAbruptCloseIterator(_completion_, _iterated_).
+ 1. Set _counter_ to _counter_ + 1.
1. Return CreateIteratorFromClosure(_closure_, *"Iterator Helper"*, %IteratorHelperPrototype%).
@@ -571,15 +573,17 @@ Iterator.prototype.filter ( _filterer_ )
1. Let _iterated_ be ? GetIteratorDirect(*this* value).
1. If IsCallable(_filterer_) is *false*, throw a *TypeError* exception.
1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterated_ and _filterer_ and performs the following steps when called:
+ 1. Let _counter_ be 0.
1. Repeat,
1. Let _next_ be ? IteratorStep(_iterated_).
1. If _next_ is *false*, return *undefined*.
1. Let _value_ be ? IteratorValue(_next_).
- 1. Let _selected_ be Completion(Call(_filterer_, *undefined*, « _value_ »)).
+ 1. Let _selected_ be Completion(Call(_filterer_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. IfAbruptCloseIterator(_selected_, _iterated_).
1. If ToBoolean(_selected_) is *true*, then
1. Let _completion_ be Completion(Yield(_value_)).
1. IfAbruptCloseIterator(_completion_, _iterated_).
+ 1. Set _counter_ to _counter_ + 1.
1. Return CreateIteratorFromClosure(_closure_, *"Iterator Helper"*, %IteratorHelperPrototype%).
@@ -633,25 +637,6 @@ Iterator.prototype.drop ( _limit_ )
-
- Iterator.prototype.indexed ( )
- This method performs the following steps when called:
-
- 1. Let _iterated_ be ? GetIteratorDirect(*this* value).
- 1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterated_ and performs the following steps when called:
- 1. Let _index_ be 0.
- 1. Repeat,
- 1. Let _next_ be ? IteratorStep(_iterated_).
- 1. If _next_ is *false*, return *undefined*.
- 1. Let _value_ be ? IteratorValue(_next_).
- 1. Let _pair_ be CreateArrayFromList(« 𝔽(_index_), _value_ »).
- 1. Set _index_ to _index_ + 1.
- 1. Let _completion_ be Completion(Yield(_pair_)).
- 1. IfAbruptCloseIterator(_completion_, _iterated_).
- 1. Return CreateIteratorFromClosure(_closure_, *"Iterator Helper"*, %IteratorHelperPrototype%).
-
-
-
Iterator.prototype.flatMap ( _mapper_ )
This method performs the following steps when called:
@@ -659,11 +644,12 @@ Iterator.prototype.flatMap ( _mapper_ )
1. Let _iterated_ be ? GetIteratorDirect(*this* value).
1. If IsCallable(_mapper_) is *false*, throw a *TypeError* exception.
1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterated_ and _mapper_ and performs the following steps when called:
+ 1. Let _counter_ be 0.
1. Repeat,
1. Let _next_ be ? IteratorStep(_iterated_).
1. If _next_ is *false*, return *undefined*.
1. Let _value_ be ? IteratorValue(_next_).
- 1. Let _mapped_ be Completion(Call(_mapper_, *undefined*, « _value_ »)).
+ 1. Let _mapped_ be Completion(Call(_mapper_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. IfAbruptCloseIterator(_mapped_, _iterated_).
1. Let _innerIterator_ be Completion(GetIterator(_mapped_, ~sync~)).
1. IfAbruptCloseIterator(_innerIterator_, _iterated_).
@@ -681,6 +667,7 @@ Iterator.prototype.flatMap ( _mapper_ )
1. Let _backupCompletion_ be Completion(IteratorClose(_innerIterator_, _completion_)).
1. IfAbruptCloseIterator(_backupCompletion_, _iterated_).
1. Return ? IteratorClose(_completion_, _iterated_).
+ 1. Set _counter_ to _counter_ + 1.
1. Return CreateIteratorFromClosure(_closure_, *"Iterator Helper"*, %IteratorHelperPrototype%).
@@ -697,13 +684,15 @@ Iterator.prototype.reduce ( _reducer_ [ , _initialValue_ ] )
1. Let _accumulator_ be ? IteratorValue(_next_).
1. Else,
1. Let _accumulator_ be _initialValue_.
+ 1. Let _counter_ be 0.
1. Repeat,
1. Let _next_ be ? IteratorStep(_iterated_).
1. If _next_ is *false*, return _accumulator_.
1. Let _value_ be ? IteratorValue(_next_).
- 1. Let _result_ be Completion(Call(_reducer_, *undefined*, « _accumulator_, _value_ »)).
+ 1. Let _result_ be Completion(Call(_reducer_, *undefined*, « _accumulator_, _value_, 𝔽(_counter_) »)).
1. IfAbruptCloseIterator(_result_, _iterated_).
1. Set _accumulator_ to _result_.[[Value]].
+ 1. Set _counter_ to _counter_ + 1.
@@ -739,12 +728,14 @@ Iterator.prototype.forEach ( _fn_ )
1. Let _iterated_ be ? GetIteratorDirect(*this* value).
1. If IsCallable(_fn_) is *false*, throw a *TypeError* exception.
+ 1. Let _counter_ be 0.
1. Repeat,
1. Let _next_ be ? IteratorStep(_iterated_).
1. If _next_ is *false*, return *undefined*.
1. Let _value_ be ? IteratorValue(_next_).
- 1. Let _result_ be Completion(Call(_fn_, *undefined*, « _value_ »)).
+ 1. Let _result_ be Completion(Call(_fn_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. IfAbruptCloseIterator(_result_, _iterated_).
+ 1. Set _counter_ to _counter_ + 1.
@@ -754,13 +745,15 @@ Iterator.prototype.some ( _fn_ )
1. Let _iterated_ be ? GetIteratorDirect(*this* value).
1. If IsCallable(_fn_) is *false*, throw a *TypeError* exception.
+ 1. Let _counter_ be 0.
1. Repeat,
1. Let _next_ be ? IteratorStep(_iterated_).
1. If _next_ is *false*, return *false*.
1. Let _value_ be ? IteratorValue(_next_).
- 1. Let _result_ be Completion(Call(_fn_, *undefined*, « _value_ »)).
+ 1. Let _result_ be Completion(Call(_fn_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. IfAbruptCloseIterator(_result_, _iterated_).
1. If ToBoolean(_result_) is *true*, return ? IteratorClose(_iterated_, NormalCompletion(*true*)).
+ 1. Set _counter_ to _counter_ + 1.
@@ -770,13 +763,15 @@ Iterator.prototype.every ( _fn_ )
1. Let _iterated_ be ? GetIteratorDirect(*this* value).
1. If IsCallable(_fn_) is *false*, throw a *TypeError* exception.
+ 1. Let _counter_ be 0.
1. Repeat,
1. Let _next_ be ? IteratorStep(_iterated_).
1. If _next_ is *false*, return *true*.
1. Let _value_ be ? IteratorValue(_next_).
- 1. Let _result_ be Completion(Call(_fn_, *undefined*, « _value_ »)).
+ 1. Let _result_ be Completion(Call(_fn_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. IfAbruptCloseIterator(_result_, _iterated_).
1. If ToBoolean(_result_) is *false*, return ? IteratorClose(_iterated_, NormalCompletion(*false*)).
+ 1. Set _counter_ to _counter_ + 1.
@@ -786,13 +781,15 @@ Iterator.prototype.find ( _fn_ )
1. Let _iterated_ be ? GetIteratorDirect(*this* value).
1. If IsCallable(_fn_) is *false*, throw a *TypeError* exception.
+ 1. Let _counter_ be 0.
1. Repeat,
1. Let _next_ be ? IteratorStep(_iterated_).
1. If _next_ is *false*, return *undefined*.
1. Let _value_ be ? IteratorValue(_next_).
- 1. Let _result_ be Completion(Call(_fn_, *undefined*, « _value_ »)).
+ 1. Let _result_ be Completion(Call(_fn_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. IfAbruptCloseIterator(_result_, _iterated_).
1. If ToBoolean(_result_) is *true*, return ? IteratorClose(_iterated_, NormalCompletion(_value_)).
+ 1. Set _counter_ to _counter_ + 1.
@@ -826,16 +823,18 @@ AsyncIterator.prototype.map ( _mapper_ )
1. Let _iterated_ be ? GetIteratorDirect(*this* value).
1. If IsCallable(_mapper_) is *false*, throw a *TypeError* exception.
1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterated_ and _mapper_ and performs the following steps when called:
+ 1. Let _counter_ be 0.
1. Repeat,
1. Let _next_ be ? Await(? IteratorNext(_iterated_)).
1. If ? IteratorComplete(_next_) is *true*, return *undefined*.
1. Let _value_ be ? IteratorValue(_next_).
- 1. Let _mapped_ be Completion(Call(_mapper_, *undefined*, « _value_ »)).
+ 1. Let _mapped_ be Completion(Call(_mapper_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. IfAbruptCloseAsyncIterator(_mapped_, _iterated_).
1. Set _mapped_ to Completion(Await(_mapped_)).
1. IfAbruptCloseAsyncIterator(_mapped_, _iterated_).
1. Let _completion_ be Completion(Yield(_mapped_)).
1. IfAbruptCloseAsyncIterator(_completion_, _iterated_).
+ 1. Set _counter_ to _counter_ + 1.
1. Return CreateAsyncIteratorFromClosure(_closure_, *"Async Iterator Helper"*, %AsyncIteratorHelperPrototype%).
@@ -847,17 +846,19 @@ AsyncIterator.prototype.filter ( _filterer_ )
1. Let _iterated_ be ? GetIteratorDirect(*this* value).
1. If IsCallable(_filterer_) is *false*, throw a *TypeError* exception.
1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterated_ and _filterer_ and performs the following steps when called:
+ 1. Let _counter_ be 0.
1. Repeat,
1. Let _next_ be ? Await(? IteratorNext(_iterated_)).
1. If ? IteratorComplete(_next_) is *true*, return *undefined*.
1. Let _value_ be ? IteratorValue(_next_).
- 1. Let _selected_ be Completion(Call(_filterer_, *undefined*, « _value_ »)).
+ 1. Let _selected_ be Completion(Call(_filterer_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. IfAbruptCloseAsyncIterator(_selected_, _iterated_).
1. Set _selected_ to Completion(Await(_selected_)).
1. IfAbruptCloseAsyncIterator(_selected_, _iterated_).
1. If ToBoolean(_selected_) is *true*, then
1. Let _completion_ be Completion(Yield(_value_)).
1. IfAbruptCloseAsyncIterator(_completion_, _iterated_).
+ 1. Set _counter_ to _counter_ + 1.
1. Return CreateAsyncIteratorFromClosure(_closure_, *"Async Iterator Helper"*, %AsyncIteratorHelperPrototype%).
@@ -911,25 +912,6 @@ AsyncIterator.prototype.drop ( _limit_ )
-
- AsyncIterator.prototype.indexed ( )
- This method performs the following steps when called:
-
- 1. Let _iterated_ be ? GetIteratorDirect(*this* value).
- 1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterated_ and performs the following steps when called:
- 1. Let _index_ be 0.
- 1. Repeat,
- 1. Let _next_ be ? Await(? IteratorNext(_iterated_)).
- 1. If ? IteratorComplete(_next_) is *true*, return *undefined*.
- 1. Let _value_ be ? IteratorValue(_next_).
- 1. Let _pair_ be CreateArrayFromList(« _index_, _value_ »).
- 1. Set _index_ to _index_ + 1.
- 1. Let _completion_ be Completion(Yield(_pair_)).
- 1. IfAbruptCloseAsyncIterator(_completion_, _iterated_).
- 1. Return CreateAsyncIteratorFromClosure(_closure_, *"Async Iterator Helper"*, %AsyncIteratorHelperPrototype%).
-
-
-
AsyncIterator.prototype.flatMap ( _mapper_ )
This method performs the following steps when called:
@@ -937,11 +919,12 @@ AsyncIterator.prototype.flatMap ( _mapper_ )
1. Let _iterated_ be ? GetIteratorDirect(*this* value).
1. If IsCallable(_mapper_) is *false*, throw a *TypeError* exception.
1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterated_ and _mapper_ and performs the following steps when called:
+ 1. Let _counter_ be 0.
1. Repeat,
1. Let _next_ be ? Await(? IteratorNext(_iterated_)).
1. If ? IteratorComplete(_next_) is *true*, return *undefined*.
1. Let _value_ be ? IteratorValue(_next_).
- 1. Let _mapped_ be Completion(Call(_mapper_, *undefined*, « _value_ »)).
+ 1. Let _mapped_ be Completion(Call(_mapper_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. IfAbruptCloseAsyncIterator(_mapped_, _iterated_).
1. Set _mapped_ to Completion(Await(_mapped_)).
1. IfAbruptCloseAsyncIterator(_mapped_, _iterated_).
@@ -968,6 +951,7 @@ AsyncIterator.prototype.flatMap ( _mapper_ )
1. Else if _completion_ is a throw completion, then
1. Assert: Awaiting _innerValue_ during the Yield on step threw.
1. Return ? IteratorClose(_completion_, _iterated_).
+ 1. Set _counter_ to _counter_ + 1.
1. Return CreateAsyncIteratorFromClosure(_closure_, *"Async Iterator Helper"*, %AsyncIteratorHelperPrototype%).
@@ -984,15 +968,17 @@ AsyncIterator.prototype.reduce ( _reducer_ [ , _initialValue_ ] )
1. Let _accumulator_ be ? IteratorValue(_next_).
1. Else,
1. Let _accumulator_ be _initialValue_.
+ 1. Let _counter_ be 0.
1. Repeat,
1. Let _next_ be ? Await(? IteratorNext(_iterated_)).
1. If ? IteratorComplete(_next_) is *true*, return _accumulator_.
1. Let _value_ be ? IteratorValue(_next_).
- 1. Let _result_ be Completion(Call(_reducer_, *undefined*, « _accumulator_, _value_ »)).
+ 1. Let _result_ be Completion(Call(_reducer_, *undefined*, « _accumulator_, _value_, 𝔽(_counter_) »)).
1. IfAbruptCloseAsyncIterator(_result_, _iterated_).
1. Set _result_ to Await(_result_).
1. IfAbruptCloseAsyncIterator(_result_, _iterated_).
1. Set _accumulator_ to _result_.
+ 1. Set _counter_ to _counter_ + 1.
@@ -1016,14 +1002,16 @@ AsyncIterator.prototype.forEach ( _fn_ )
1. Let _iterated_ be ? GetIteratorDirect(*this* value).
1. If IsCallable(_fn_) is *false*, throw a *TypeError* exception.
+ 1. Let _counter_ be 0.
1. Repeat,
1. Let _next_ be ? Await(? IteratorNext(_iterated_)).
1. If ? IteratorComplete(_next_) is *true*, return *undefined*.
1. Let _value_ be ? IteratorValue(_next_).
- 1. Let _r_ be Completion(Call(_fn_, *undefined*, « _value_ »)).
+ 1. Let _r_ be Completion(Call(_fn_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. IfAbruptCloseAsyncIterator(_r_, _iterated_).
1. Set _r_ to Await(r).
1. IfAbruptCloseAsyncIterator(_r_, _iterated_).
+ 1. Set _counter_ to _counter_ + 1.
@@ -1033,15 +1021,17 @@ AsyncIterator.prototype.some ( _fn_ )
1. Let _iterated_ be ? GetIteratorDirect(*this* value).
1. If IsCallable(_fn_) is *false*, throw a *TypeError* exception.
+ 1. Let _counter_ be 0.
1. Repeat,
1. Let _next_ be ? Await(? IteratorNext(_iterated_)).
1. If ? IteratorComplete(_next_) is *true*, return *false*.
1. Let _value_ be ? IteratorValue(_next_).
- 1. Let _result_ be Completion(Call(_fn_, *undefined*, « _value_ »)).
+ 1. Let _result_ be Completion(Call(_fn_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. IfAbruptCloseAsyncIterator(_result_, _iterated_).
1. Set _result_ to Await(_result_).
1. IfAbruptCloseAsyncIterator(_result_, _iterated_).
1. If ToBoolean(_result_) is *true*, return ? AsyncIteratorClose(_iterated_, NormalCompletion(*true*)).
+ 1. Set _counter_ to _counter_ + 1.
@@ -1051,15 +1041,17 @@ AsyncIterator.prototype.every ( _fn_ )
1. Let _iterated_ be ? GetIteratorDirect(*this* value).
1. If IsCallable(_fn_) is *false*, throw a *TypeError* exception.
+ 1. Let _counter_ be 0.
1. Repeat,
1. Let _next_ be ? Await(? IteratorNext(_iterated_)).
1. If ? IteratorComplete(_next_) is *true*, return *true*.
1. Let _value_ be ? IteratorValue(_next_).
- 1. Let _result_ be Completion(Call(_fn_, *undefined*, « _value_ »)).
+ 1. Let _result_ be Completion(Call(_fn_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. IfAbruptCloseAsyncIterator(_result_, _iterated_).
1. Set _result_ to Await(_result_).
1. IfAbruptCloseAsyncIterator(_result_, _iterated_).
1. If ToBoolean(_result_) is *false*, return ? AsyncIteratorClose(_iterated_, NormalCompletion(*false*)).
+ 1. Set _counter_ to _counter_ + 1.
@@ -1069,15 +1061,17 @@ AsyncIterator.prototype.find ( _fn_ )
1. Let _iterated_ be ? GetIteratorDirect(*this* value).
1. If IsCallable(_fn_) is *false*, throw a *TypeError* exception.
+ 1. Let _counter_ be 0.
1. Repeat,
1. Let _next_ be ? Await(? IteratorNext(_iterated_)).
1. If ? IteratorComplete(_next_) is *true*, return *undefined*.
1. Let _value_ be ? IteratorValue(_next_).
- 1. Let _result_ be Completion(Call(_fn_, *undefined*, « _value_ »)).
+ 1. Let _result_ be Completion(Call(_fn_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. IfAbruptCloseAsyncIterator(_result_, _iterated_).
1. Set _result_ to Await(_result_).
1. IfAbruptCloseAsyncIterator(_result_, _iterated_).
1. If ToBoolean(_result_) is *true*, return ? AsyncIteratorClose(_iterated_, NormalCompletion(_value_)).
+ 1. Set _counter_ to _counter_ + 1.