Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #86 from syg/convert-ta-with-value-first
Browse files Browse the repository at this point in the history
Convert value in TypedArray#with before the copy loop
  • Loading branch information
Robin Ricard committed Jun 7, 2022
2 parents fde312d + 0aad930 commit 0cd4150
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions spec.html
Expand Up @@ -471,22 +471,19 @@ <h1>%TypedArray%.prototype.with ( _index_, _value_ )</h1>
1. Let _relativeIndex_ be ? ToIntegerOrInfinity(_index_).
1. If _relativeIndex_ &ge; 0, let _actualIndex_ be _relativeIndex_.
1. Else, let _actualIndex_ be _len_ + _relativeIndex_.
1. If _O_.[[ContentType]] is ~BigInt~, set _value_ to ? ToBigInt(_value_).
1. Else, set _value_ to ? ToNumber(_value_).
1. If ! IsValidIntegerIndex(_O_, 𝔽(_actualIndex_)) is *false*, throw a *RangeError* exception.
1. Let _A_ be ? TypedArrayCreateSameType(_O_, &laquo; 𝔽(_len_) &raquo;).
1. Let _k_ be 0.
1. Repeat, while _k_ &lt; _len_,
1. Let _Pk_ be ! ToString(𝔽(_k_)).
1. If _k_ is _actualIndex_, then
1. [id="step-typedarray-with-set"] Perform ? Set(_A_, _Pk_, _value_, *true*).
1. Else,
1. Let _fromValue_ be ! Get(_O_, _Pk_).
1. Perform ! Set(_A_, _Pk_, _fromValue_, *true*).
1. If _k_ is _actualIndex_, let _fromValue_ be _value_.
1. Else, let _fromValue_ be ! Get(_O_, _Pk_).
1. Perform ! Set(_A_, _Pk_, _fromValue_, *true*).
1. Set _k_ to _k_ + 1.
1. Return _A_.
</emu-alg>
<emu-note>
Step <emu-xref href="#step-typedarray-with-set"></emu-xref> may return an abrupt completion because _value_ is a value of any ECMAScript language type and is passed to ToBigInt or ToNumber.
</emu-note>
</emu-clause>
</emu-clause>
</emu-clause>
Expand Down

0 comments on commit 0cd4150

Please sign in to comment.