Skip to content

Commit

Permalink
Editorial: Add IfAbruptCloseIterator shorthand (#2113)
Browse files Browse the repository at this point in the history
Co-authored-by: ExE Boss <3889017+ExE-Boss@users.noreply.github.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
  • Loading branch information
ExE-Boss and ljharb committed Aug 25, 2021
1 parent 4fde514 commit 56ed133
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -6820,6 +6820,19 @@ <h1>
</emu-alg>
</emu-clause>

<emu-clause id="sec-ifabruptcloseiterator" aoid="IfAbruptCloseIterator">
<h1>IfAbruptCloseIterator ( _value_, _iteratorRecord_ )</h1>
<p>IfAbruptCloseIterator is a shorthand for a sequence of algorithm steps that use an Iterator Record. An algorithm step of the form:</p>
<emu-alg>
1. IfAbruptCloseIterator(_value_, _iteratorRecord_).
</emu-alg>
<p>means the same thing as:</p>
<emu-alg>
1. If _value_ is an abrupt completion, return ? IteratorClose(_iteratorRecord_, _value_).
1. Else if _value_ is a Completion Record, set _value_ to _value_.[[Value]].
</emu-alg>
</emu-clause>

<emu-clause id="sec-asynciteratorclose" type="abstract operation">
<h1>
AsyncIteratorClose (
Expand Down Expand Up @@ -36009,11 +36022,10 @@ <h1>Array.from ( _items_ [ , _mapfn_ [ , _thisArg_ ] ] )</h1>
1. Let _nextValue_ be ? IteratorValue(_next_).
1. If _mapping_ is *true*, then
1. Let _mappedValue_ be Call(_mapfn_, _thisArg_, &laquo; _nextValue_, 𝔽(_k_) &raquo;).
1. If _mappedValue_ is an abrupt completion, return ? IteratorClose(_iteratorRecord_, _mappedValue_).
1. Set _mappedValue_ to _mappedValue_.[[Value]].
1. IfAbruptCloseIterator(_mappedValue_, _iteratorRecord_).
1. Else, let _mappedValue_ be _nextValue_.
1. Let _defineStatus_ be CreateDataPropertyOrThrow(_A_, _Pk_, _mappedValue_).
1. If _defineStatus_ is an abrupt completion, return ? IteratorClose(_iteratorRecord_, _defineStatus_).
1. IfAbruptCloseIterator(_defineStatus_, _iteratorRecord_).
1. Set _k_ to _k_ + 1.
1. NOTE: _items_ is not an Iterable so assume it is an array-like object.
1. Let _arrayLike_ be ! ToObject(_items_).
Expand Down Expand Up @@ -38832,11 +38844,11 @@ <h1>
1. Let _error_ be ThrowCompletion(a newly created *TypeError* object).
1. Return ? IteratorClose(_iteratorRecord_, _error_).
1. Let _k_ be Get(_nextItem_, *"0"*).
1. If _k_ is an abrupt completion, return ? IteratorClose(_iteratorRecord_, _k_).
1. IfAbruptCloseIterator(_k_, _iteratorRecord_).
1. Let _v_ be Get(_nextItem_, *"1"*).
1. If _v_ is an abrupt completion, return ? IteratorClose(_iteratorRecord_, _v_).
1. Let _status_ be Call(_adder_, _target_, &laquo; _k_.[[Value]], _v_.[[Value]] &raquo;).
1. If _status_ is an abrupt completion, return ? IteratorClose(_iteratorRecord_, _status_).
1. IfAbruptCloseIterator(_v_, _iteratorRecord_).
1. Let _status_ be Call(_adder_, _target_, &laquo; _k_, _v_ &raquo;).
1. IfAbruptCloseIterator(_status_, _iteratorRecord_).
</emu-alg>
<emu-note>
<p>The parameter _iterable_ is expected to be an object that implements an @@iterator method that returns an iterator object that produces a two element array-like object whose first element is a value that will be used as a Map key and whose second element is the value to associate with that key.</p>
Expand Down Expand Up @@ -39141,7 +39153,7 @@ <h1>Set ( [ _iterable_ ] )</h1>
1. If _next_ is *false*, return _set_.
1. Let _nextValue_ be ? IteratorValue(_next_).
1. Let _status_ be Call(_adder_, _set_, &laquo; _nextValue_ &raquo;).
1. If _status_ is an abrupt completion, return ? IteratorClose(_iteratorRecord_, _status_).
1. IfAbruptCloseIterator(_status_, _iteratorRecord_).
</emu-alg>
</emu-clause>
</emu-clause>
Expand Down Expand Up @@ -39581,7 +39593,7 @@ <h1>WeakSet ( [ _iterable_ ] )</h1>
1. If _next_ is *false*, return _set_.
1. Let _nextValue_ be ? IteratorValue(_next_).
1. Let _status_ be Call(_adder_, _set_, &laquo; _nextValue_ &raquo;).
1. If _status_ is an abrupt completion, return ? IteratorClose(_iteratorRecord_, _status_).
1. IfAbruptCloseIterator(_status_, _iteratorRecord_).
</emu-alg>
</emu-clause>
</emu-clause>
Expand Down

0 comments on commit 56ed133

Please sign in to comment.