Skip to content

Commit

Permalink
Editorial: FlattenIntoArray: add assertions (#1620)
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jul 10, 2019
1 parent dc1e21c commit e893b3b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -32093,6 +32093,12 @@ <h1>Array.prototype.flat ( [ _depth_ ] )</h1>
<emu-clause id="sec-flattenintoarray" aoid="FlattenIntoArray">
<h1>FlattenIntoArray ( _target_, _source_, _sourceLen_, _start_, _depth_ [ , _mapperFunction_, _thisArg_ ] )</h1>
<emu-alg>
1. Assert: Type(_target_) is Object.
1. Assert: Type(_source_) is Object.
1. Assert: _sourceLen_ is an integer Number &ge; 0.
1. Assert: _start_ is an integer Number &ge; 0.
1. Assert: _depth_ is an integer Number, *+&infin;*, or *-&infin;*.
1. Assert: if _mapperFunction_ is present, ! IsCallable(_mapperFunction_) is *true*, _thisArg_ is present, and _depth_ is *1*.
1. Let _targetIndex_ be _start_.
1. Let _sourceIndex_ be 0.
1. Repeat, while _sourceIndex_ &lt; _sourceLen_
Expand All @@ -32101,7 +32107,6 @@ <h1>FlattenIntoArray ( _target_, _source_, _sourceLen_, _start_, _depth_ [ , _ma
1. If _exists_ is *true*, then
1. Let _element_ be ? Get(_source_, _P_).
1. If _mapperFunction_ is present, then
1. Assert: _thisArg_ is present.
1. Set _element_ to ? Call(_mapperFunction_, _thisArg_, &laquo; _element_, _sourceIndex_, _source_ &raquo;).
1. Let _shouldFlatten_ be *false*.
1. If _depth_ &gt; 0, then
Expand All @@ -32125,7 +32130,7 @@ <h1>Array.prototype.flatMap ( _mapperFunction_ [ , _thisArg_ ] )</h1>
<emu-alg>
1. Let _O_ be ? ToObject(*this* value).
1. Let _sourceLen_ be ? ToLength(? Get(_O_, `"length"`)).
1. If IsCallable(_mapperFunction_) is *false*, throw a *TypeError* exception.
1. If ! IsCallable(_mapperFunction_) is *false*, throw a *TypeError* exception.
1. If _thisArg_ is present, let _T_ be _thisArg_; else let _T_ be *undefined*.
1. Let _A_ be ? ArraySpeciesCreate(_O_, 0).
1. Perform ? FlattenIntoArray(_A_, _O_, _sourceLen_, 0, 1, _mapperFunction_, _T_).
Expand Down

0 comments on commit e893b3b

Please sign in to comment.