Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 90 additions & 1 deletion spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -7243,6 +7243,20 @@ <h1>
</emu-alg>
</emu-clause>

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

<emu-clause id="sec-createiterresultobject" type="abstract operation">
<h1>
CreateIteratorResultObject (
Expand Down Expand Up @@ -39734,7 +39748,7 @@ <h1>Properties of the Array Constructor</h1>

<emu-clause id="sec-array.from">
<h1>Array.from ( _items_ [ , _mapper_ [ , _thisArg_ ] ] )</h1>
<p>This method performs the following steps when called:</p>
<p>This function performs the following steps when called:</p>
<emu-alg>
1. Let _C_ be the *this* value.
1. If _mapper_ is *undefined*, then
Expand Down Expand Up @@ -39792,6 +39806,81 @@ <h1>Array.from ( _items_ [ , _mapper_ [ , _thisArg_ ] ] )</h1>
</emu-note>
</emu-clause>

<emu-clause id="sec-array.fromasync">
<h1>Array.fromAsync ( _items_ [ , _mapper_ [ , _thisArg_ ] ] )</h1>

<p>This async function performs the following steps when called:</p>
<emu-alg>
1. Let _C_ be the *this* value.
1. Let _mapping_ be *false*.
1. If _mapper_ is not *undefined*, then
1. If IsCallable(_mapper_) is *false*, throw a *TypeError* exception.
1. Set _mapping_ to *true*.
1. Let _iteratorRecord_ be *undefined*.
1. Let _usingAsyncIterator_ be ? GetMethod(_items_, %Symbol.asyncIterator%).
1. If _usingAsyncIterator_ is *undefined*, then
1. Let _usingSyncIterator_ be ? GetMethod(_items_, %Symbol.iterator%).
1. If _usingSyncIterator_ is not *undefined*, then
1. Set _iteratorRecord_ to CreateAsyncFromSyncIterator(? GetIteratorFromMethod(_items_, _usingSyncIterator_)).
1. Else,
1. Set _iteratorRecord_ to ? GetIteratorFromMethod(_items_, _usingAsyncIterator_).
1. If _iteratorRecord_ is not *undefined*, then
1. If IsConstructor(_C_) is *true*, then
1. Let _A_ be ? Construct(_C_).
1. Else,
1. Let _A_ be ! ArrayCreate(0).
1. Let _k_ be 0.
1. Repeat,
1. If _k_ ≥ 2<sup>53</sup> - 1, then
1. Let _error_ be ThrowCompletion(a newly created *TypeError* object).
1. Return ? AsyncIteratorClose(_iteratorRecord_, _error_).
1. Let _Pk_ be ! ToString(𝔽(_k_)).
1. Let _nextResult_ be ? Call(_iteratorRecord_.[[NextMethod]], _iteratorRecord_.[[Iterator]]).
1. Set _nextResult_ to ? Await(_nextResult_).
1. If _nextResult_ is not an Object, throw a *TypeError* exception.
1. Let _done_ be ? IteratorComplete(_nextResult_).
1. If _done_ is *true*, then
1. Perform ? Set(_A_, *"length"*, 𝔽(_k_), *true*).
1. Return _A_.
1. Let _nextValue_ be ? IteratorValue(_nextResult_).
1. If _mapping_ is *true*, then
1. Let _mappedValue_ be Completion(Call(_mapper_, _thisArg_, « _nextValue_, 𝔽(_k_) »)).
1. IfAbruptCloseAsyncIterator(_mappedValue_, _iteratorRecord_).
1. Set _mappedValue_ to Completion(Await(_mappedValue_)).
1. IfAbruptCloseAsyncIterator(_mappedValue_, _iteratorRecord_).
1. Else,
1. Let _mappedValue_ be _nextValue_.
1. Let _defineStatus_ be Completion(CreateDataPropertyOrThrow(_A_, _Pk_, _mappedValue_)).
1. IfAbruptCloseAsyncIterator(_defineStatus_, _iteratorRecord_).
1. Set _k_ to _k_ + 1.
1. Else,
1. NOTE: _items_ is neither async iterable nor iterable so assume it is an array-like object.
1. Let _arrayLike_ be ! ToObject(_items_).
1. Let _len_ be ? LengthOfArrayLike(_arrayLike_).
1. If IsConstructor(_C_) is *true*, then
1. Let _A_ be ? Construct(_C_, « 𝔽(_len_) »).
1. Else,
1. Let _A_ be ? ArrayCreate(_len_).
1. Let _k_ be 0.
1. Repeat, while _k_ &lt; _len_,
1. Let _Pk_ be ! ToString(𝔽(_k_)).
1. Let _kValue_ be ? Get(_arrayLike_, _Pk_).
1. Set _kValue_ to ? Await(_kValue_).
1. If _mapping_ is *true*, then
1. Let _mappedValue_ be ? Call(_mapper_, _thisArg_, « _kValue_, 𝔽(_k_) »).
1. Set _mappedValue_ to ? Await(_mappedValue_).
1. Else,
1. Let _mappedValue_ be _kValue_.
1. Perform ? CreateDataPropertyOrThrow(_A_, _Pk_, _mappedValue_).
1. Set _k_ to _k_ + 1.
1. Perform ? Set(_A_, *"length"*, 𝔽(_len_), *true*).
1. Return _A_.
</emu-alg>
<emu-note>
<p>This method is an intentionally generic factory method; it does not require that its *this* value be the Array constructor. Therefore it can be transferred to or inherited by any other constructors that may be called with a single numeric argument.</p>
</emu-note>
</emu-clause>

<emu-clause id="sec-array.isarray">
<h1>Array.isArray ( _arg_ )</h1>
<p>This function performs the following steps when called:</p>
Expand Down
Loading