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

Convert value in TypedArray#with before the copy loop #86

Merged
merged 1 commit into from Jun 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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