Skip to content

Commit

Permalink
Editorial: Simplify ToClampedIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
gibson042 committed Oct 11, 2022
1 parent 37cd577 commit df66bad
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -5807,19 +5807,15 @@ <h1>
ToClampedIndex (
_value_: an ECMAScript language value,
_length_: a non-negative integer,
optional _lowerBound_: an integer,
optional _upperBound_: an integer,
): either a normal completion containing an integer or a throw completion
</h1>
<dl class="header">
<dt>description</dt>
<dd>It converts _value_ to an integer (interpreting negative values relative to _length_) and clamps the result to the inclusive interval from _lowerBound_ to _upperBound_ (respectively defaulting to 0 and _length_).</dd>
<dd>It converts _value_ to an integer (interpreting negative values relative to _length_) and clamps the result to the inclusive interval from 0 to _length_.</dd>
</dl>
<emu-alg>
1. If _lowerBound_ is not present, set _lowerBound_ to 0.
1. If _upperBound_ is not present, set _upperBound_ to _length_.
1. Assert: _lowerBound_ &le; _upperBound_.
1. Return the result of clamping ? ToAbsoluteIndex(_value_, _length_) between _lowerBound_ and _upperBound_.
1. Let _index_ be ? ToAbsoluteIndex(_value_, _length_).
1. Return the result of clamping _index_ between 0 and _length_.
</emu-alg>
</emu-clause>
</emu-clause>
Expand Down Expand Up @@ -37657,7 +37653,8 @@ <h1>Array.prototype.lastIndexOf ( _searchElement_ [ , _fromIndex_ ] )</h1>
1. Let _O_ be ? ToObject(*this* value).
1. Let _len_ be ? LengthOfArrayLike(_O_).
1. If _len_ is 0, return *-1*<sub>𝔽</sub>.
1. If _fromIndex_ is not present, let _k_ be _len_ - 1; else let _k_ be ? ToClampedIndex(_fromIndex_, _len_, -1, _len_ - 1).
1. If _fromIndex_ is not present, let _k_ be _len_ - 1.
1. Else, let _k_ be min(? ToAbsoluteIndex(_fromIndex_, _len_), _len_ - 1).
1. Repeat, while _k_ &ge; 0,
1. Let _kPresent_ be ? HasProperty(_O_, ! ToString(𝔽(_k_))).
1. If _kPresent_ is *true*, then
Expand Down Expand Up @@ -39067,7 +39064,8 @@ <h1>%TypedArray%.prototype.lastIndexOf ( _searchElement_ [ , _fromIndex_ ] )</h1
1. Perform ? ValidateTypedArray(_O_).
1. Let _len_ be _O_.[[ArrayLength]].
1. If _len_ is 0, return *-1*<sub>𝔽</sub>.
1. If _fromIndex_ is not present, let _k_ be _len_ - 1; else let _k_ be ? ToClampedIndex(_fromIndex_, _len_, -1, _len_ - 1).
1. If _fromIndex_ is not present, let _k_ be _len_ - 1.
1. Else, let _k_ be min(? ToAbsoluteIndex(_fromIndex_, _len_), _len_ - 1).
1. Repeat, while _k_ &ge; 0,
1. Let _kPresent_ be ! HasProperty(_O_, ! ToString(𝔽(_k_))).
1. If _kPresent_ is *true*, then
Expand Down

0 comments on commit df66bad

Please sign in to comment.