Skip to content

Commit 00b920f

Browse files
gibson042jhnaldo
authored andcommitted
Normative: When TA.copyWithin argument handling shrinks TA, use whatever elements still fit (tc39#3619)
...regardless of copy direction Fixes tc39#3618 This aligns the spec with implementation reality.
1 parent 39cc925 commit 00b920f

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

spec.html

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41732,9 +41732,10 @@ <h1>%TypedArray%.prototype.copyWithin ( _target_, _start_ [ , _end_ ] )</h1>
4173241732
1. Set _taRecord_ to MakeTypedArrayWithBufferWitnessRecord(_O_, ~seq-cst~).
4173341733
1. If IsTypedArrayOutOfBounds(_taRecord_) is *true*, throw a *TypeError* exception.
4173441734
1. Set _len_ to TypedArrayLength(_taRecord_).
41735+
1. NOTE: Side-effects of the above steps may have reduced the size of _O_, in which case copying should proceed with the longest still-applicable prefix.
41736+
1. Set _count_ to min(_count_, _len_ - _startIndex_, _len_ - _targetIndex_).
4173541737
1. Let _elementSize_ be TypedArrayElementSize(_O_).
4173641738
1. Let _byteOffset_ be _O_.[[ByteOffset]].
41737-
1. Let _bufferByteLimit_ be (_len_ × _elementSize_) + _byteOffset_.
4173841739
1. Let _toByteIndex_ be (_targetIndex_ × _elementSize_) + _byteOffset_.
4173941740
1. Let _fromByteIndex_ be (_startIndex_ × _elementSize_) + _byteOffset_.
4174041741
1. Let _countBytes_ be _count_ × _elementSize_.
@@ -41745,14 +41746,11 @@ <h1>%TypedArray%.prototype.copyWithin ( _target_, _start_ [ , _end_ ] )</h1>
4174541746
1. Else,
4174641747
1. Let _direction_ be 1.
4174741748
1. Repeat, while _countBytes_ > 0,
41748-
1. If _fromByteIndex_ &lt; _bufferByteLimit_ and _toByteIndex_ &lt; _bufferByteLimit_, then
41749-
1. Let _value_ be GetValueFromBuffer(_buffer_, _fromByteIndex_, ~uint8~, *true*, ~unordered~).
41750-
1. Perform SetValueInBuffer(_buffer_, _toByteIndex_, ~uint8~, _value_, *true*, ~unordered~).
41751-
1. Set _fromByteIndex_ to _fromByteIndex_ + _direction_.
41752-
1. Set _toByteIndex_ to _toByteIndex_ + _direction_.
41753-
1. Set _countBytes_ to _countBytes_ - 1.
41754-
1. Else,
41755-
1. Set _countBytes_ to 0.
41749+
1. Let _value_ be GetValueFromBuffer(_buffer_, _fromByteIndex_, ~uint8~, *true*, ~unordered~).
41750+
1. Perform SetValueInBuffer(_buffer_, _toByteIndex_, ~uint8~, _value_, *true*, ~unordered~).
41751+
1. Set _fromByteIndex_ to _fromByteIndex_ + _direction_.
41752+
1. Set _toByteIndex_ to _toByteIndex_ + _direction_.
41753+
1. Set _countBytes_ to _countBytes_ - 1.
4175641754
1. Return _O_.
4175741755
</emu-alg>
4175841756
</emu-clause>

0 commit comments

Comments
 (0)