Skip to content

Commit 60c4df0

Browse files
gibson042ljharb
authored andcommitted
Editorial: Define SetTypedArrayFromArrayLike before SetTypedArrayFromTypedArray (#3632)
The new [serendipitously alphabetical] ordering makes more obvious how SetTypedArrayFromTypedArray is a specialized adaptation of SetTypedArrayFromArrayLike when viewing the spec in top-to-bottom order.
1 parent 427ef8a commit 60c4df0

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

spec.html

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -42181,6 +42181,37 @@ <h1>%TypedArray%.prototype.set ( _source_ [ , _offset_ ] )</h1>
4218142181
</emu-alg>
4218242182
<p>This method is not generic. The *this* value must be an object with a [[TypedArrayName]] internal slot.</p>
4218342183

42184+
<emu-clause id="sec-settypedarrayfromarraylike" type="abstract operation" oldids="sec-%typedarray%.prototype.set-array-offset">
42185+
<h1>
42186+
SetTypedArrayFromArrayLike (
42187+
_target_: a TypedArray,
42188+
_targetOffset_: a non-negative integer or +&infin;,
42189+
_source_: an ECMAScript language value, but not a TypedArray,
42190+
): either a normal completion containing ~unused~ or a throw completion
42191+
</h1>
42192+
<dl class="header">
42193+
<dt>description</dt>
42194+
<dd>It sets multiple values in _target_, starting at index _targetOffset_, reading the values from _source_.</dd>
42195+
</dl>
42196+
<emu-alg>
42197+
1. Let _targetRecord_ be MakeTypedArrayWithBufferWitnessRecord(_target_, ~seq-cst~).
42198+
1. If IsTypedArrayOutOfBounds(_targetRecord_) is *true*, throw a *TypeError* exception.
42199+
1. Let _targetLength_ be TypedArrayLength(_targetRecord_).
42200+
1. Let _src_ be ? ToObject(_source_).
42201+
1. Let _srcLength_ be ? LengthOfArrayLike(_src_).
42202+
1. If _targetOffset_ = +∞, throw a *RangeError* exception.
42203+
1. If _srcLength_ + _targetOffset_ > _targetLength_, throw a *RangeError* exception.
42204+
1. Let _k_ be 0.
42205+
1. Repeat, while _k_ &lt; _srcLength_,
42206+
1. Let _Pk_ be ! ToString(𝔽(_k_)).
42207+
1. Let _value_ be ? Get(_src_, _Pk_).
42208+
1. Let _targetIndex_ be 𝔽(_targetOffset_ + _k_).
42209+
1. Perform ? TypedArraySetElement(_target_, _targetIndex_, _value_).
42210+
1. Set _k_ to _k_ + 1.
42211+
1. Return ~unused~.
42212+
</emu-alg>
42213+
</emu-clause>
42214+
4218442215
<emu-clause id="sec-settypedarrayfromtypedarray" type="abstract operation" oldids="sec-%typedarray%.prototype.set-typedarray-offset">
4218542216
<h1>
4218642217
SetTypedArrayFromTypedArray (
@@ -42236,37 +42267,6 @@ <h1>
4223642267
1. Return ~unused~.
4223742268
</emu-alg>
4223842269
</emu-clause>
42239-
42240-
<emu-clause id="sec-settypedarrayfromarraylike" type="abstract operation" oldids="sec-%typedarray%.prototype.set-array-offset">
42241-
<h1>
42242-
SetTypedArrayFromArrayLike (
42243-
_target_: a TypedArray,
42244-
_targetOffset_: a non-negative integer or +&infin;,
42245-
_source_: an ECMAScript language value, but not a TypedArray,
42246-
): either a normal completion containing ~unused~ or a throw completion
42247-
</h1>
42248-
<dl class="header">
42249-
<dt>description</dt>
42250-
<dd>It sets multiple values in _target_, starting at index _targetOffset_, reading the values from _source_.</dd>
42251-
</dl>
42252-
<emu-alg>
42253-
1. Let _targetRecord_ be MakeTypedArrayWithBufferWitnessRecord(_target_, ~seq-cst~).
42254-
1. If IsTypedArrayOutOfBounds(_targetRecord_) is *true*, throw a *TypeError* exception.
42255-
1. Let _targetLength_ be TypedArrayLength(_targetRecord_).
42256-
1. Let _src_ be ? ToObject(_source_).
42257-
1. Let _srcLength_ be ? LengthOfArrayLike(_src_).
42258-
1. If _targetOffset_ = +∞, throw a *RangeError* exception.
42259-
1. If _srcLength_ + _targetOffset_ > _targetLength_, throw a *RangeError* exception.
42260-
1. Let _k_ be 0.
42261-
1. Repeat, while _k_ &lt; _srcLength_,
42262-
1. Let _Pk_ be ! ToString(𝔽(_k_)).
42263-
1. Let _value_ be ? Get(_src_, _Pk_).
42264-
1. Let _targetIndex_ be 𝔽(_targetOffset_ + _k_).
42265-
1. Perform ? TypedArraySetElement(_target_, _targetIndex_, _value_).
42266-
1. Set _k_ to _k_ + 1.
42267-
1. Return ~unused~.
42268-
</emu-alg>
42269-
</emu-clause>
4227042270
</emu-clause>
4227142271

4227242272
<emu-clause id="sec-%typedarray%.prototype.slice">

0 commit comments

Comments
 (0)