@@ -176,6 +176,81 @@ contributors: Mark S. Miller, Richard Gibson
176176 <emu-clause id="sec-typedarray-objects" number="2">
177177 <h1>TypedArray Objects</h1>
178178
179+ <emu-clause id="sec-properties-of-the-%typedarray%-intrinsic-object" number="2">
180+ <h1>Properties of the %TypedArray% Intrinsic Object</h1>
181+ <p>The %TypedArray% intrinsic object:</p>
182+ <ul>
183+ <li>has a [[Prototype]] internal slot whose value is %Function.prototype%.</li>
184+ <li>has a *"name"* property whose value is *"TypedArray"*.</li>
185+ <li>has the following properties:</li>
186+ </ul>
187+
188+ <emu-clause id="sec-%typedarray%.from">
189+ <h1>%TypedArray%.from ( _source_ [ , _mapper_ [ , _thisArg_ ] ] )</h1>
190+ <p>This method performs the following steps when called:</p>
191+ <emu-alg>
192+ 1. Let _C_ be the *this* value.
193+ 1. If IsConstructor(_C_) is *false*, throw a *TypeError* exception.
194+ 1. If _mapper_ is *undefined*, then
195+ 1. Let _mapping_ be *false*.
196+ 1. Else,
197+ 1. If IsCallable(_mapper_) is *false*, throw a *TypeError* exception.
198+ 1. Let _mapping_ be *true*.
199+ 1. Let _usingIterator_ be ? GetMethod(_source_, %Symbol.iterator%).
200+ 1. If _usingIterator_ is not *undefined*, then
201+ 1. Let _values_ be ? IteratorToList(? GetIteratorFromMethod(_source_, _usingIterator_)).
202+ 1. Let _len_ be the number of elements in _values_.
203+ 1. Let _targetObj_ be ? TypedArrayCreateFromConstructor(_C_, « 𝔽(_len_) »<ins>, ~write~</ins>).
204+ 1. Let _k_ be 0.
205+ 1. Repeat, while _k_ < _len_,
206+ 1. Let _Pk_ be ! ToString(𝔽(_k_)).
207+ 1. Let _kValue_ be the first element of _values_.
208+ 1. Remove the first element from _values_.
209+ 1. If _mapping_ is *true*, then
210+ 1. Let _mappedValue_ be ? Call(_mapper_, _thisArg_, « _kValue_, 𝔽(_k_) »).
211+ 1. Else,
212+ 1. Let _mappedValue_ be _kValue_.
213+ 1. Perform ? Set(_targetObj_, _Pk_, _mappedValue_, *true*).
214+ 1. Set _k_ to _k_ + 1.
215+ 1. Assert: _values_ is now an empty List.
216+ 1. Return _targetObj_.
217+ 1. NOTE: _source_ is not an iterable object, so assume it is already an array-like object.
218+ 1. Let _arrayLike_ be ! ToObject(_source_).
219+ 1. Let _len_ be ? LengthOfArrayLike(_arrayLike_).
220+ 1. Let _targetObj_ be ? TypedArrayCreateFromConstructor(_C_, « 𝔽(_len_) »<ins>, ~write~</ins>).
221+ 1. Let _k_ be 0.
222+ 1. Repeat, while _k_ < _len_,
223+ 1. Let _Pk_ be ! ToString(𝔽(_k_)).
224+ 1. Let _kValue_ be ? Get(_arrayLike_, _Pk_).
225+ 1. If _mapping_ is *true*, then
226+ 1. Let _mappedValue_ be ? Call(_mapper_, _thisArg_, « _kValue_, 𝔽(_k_) »).
227+ 1. Else,
228+ 1. Let _mappedValue_ be _kValue_.
229+ 1. Perform ? Set(_targetObj_, _Pk_, _mappedValue_, *true*).
230+ 1. Set _k_ to _k_ + 1.
231+ 1. Return _targetObj_.
232+ </emu-alg>
233+ </emu-clause>
234+
235+ <emu-clause id="sec-%typedarray%.of">
236+ <h1>%TypedArray%.of ( ..._items_ )</h1>
237+ <p>This method performs the following steps when called:</p>
238+ <emu-alg>
239+ 1. Let _len_ be the number of elements in _items_.
240+ 1. Let _C_ be the *this* value.
241+ 1. If IsConstructor(_C_) is *false*, throw a *TypeError* exception.
242+ 1. Let _newObj_ be ? TypedArrayCreateFromConstructor(_C_, « 𝔽(_len_) »<ins>, ~write~</ins>).
243+ 1. Let _k_ be 0.
244+ 1. Repeat, while _k_ < _len_,
245+ 1. Let _kValue_ be _items_[_k_].
246+ 1. Let _Pk_ be ! ToString(𝔽(_k_)).
247+ 1. Perform ? Set(_newObj_, _Pk_, _kValue_, *true*).
248+ 1. Set _k_ to _k_ + 1.
249+ 1. Return _newObj_.
250+ </emu-alg>
251+ </emu-clause>
252+ </emu-clause>
253+
179254 <emu-clause id="sec-properties-of-the-%typedarrayprototype%-object" number="3">
180255 <h1>Properties of the %TypedArray% Prototype Object</h1>
181256
@@ -457,15 +532,38 @@ contributors: Mark S. Miller, Richard Gibson
457532 1. <ins>If _accessMode_ is not present, set _accessMode_ to ~read~.</ins>
458533 1. Let _defaultConstructor_ be the intrinsic object associated with the constructor name _exemplar_.[[TypedArrayName]] in <emu-xref href="#table-the-typedarray-constructors"></emu-xref>.
459534 1. Let _constructor_ be ? SpeciesConstructor(_exemplar_, _defaultConstructor_).
460- 1. Let _result_ be ? TypedArrayCreateFromConstructor(_constructor_, _argumentList_).
535+ 1. Let _result_ be ? TypedArrayCreateFromConstructor(_constructor_, _argumentList_<ins>, _accessMode_</ins> ).
461536 1. <del>Assert: _result_ has [[TypedArrayName]] and [[ContentType]] internal slots.</del>
462537 1. <ins>Assert: _result_ has all of the internal slots of a <var>TypedArray</var> instance (<emu-xref href="#sec-properties-of-typedarray-instances"></emu-xref>).</ins>
463538 1. If _result_.[[ContentType]] is not _exemplar_.[[ContentType]], throw a *TypeError* exception.
464- 1. <ins>If _accessMode_ is ~write~ and IsImmutableBuffer(_result_.[[ViewedArrayBuffer]]) is *true*, throw a *TypeError* exception.</ins>
465539 1. Return _result_.
466540 </emu-alg>
467541 </emu-clause>
468542
543+ <emu-clause id="sec-typedarraycreatefromconstructor" oldids="typedarray-create" type="abstract operation">
544+ <h1>
545+ TypedArrayCreateFromConstructor (
546+ _constructor_: a constructor,
547+ _argumentList_: a List of ECMAScript language values,
548+ <ins>optional _accessMode_: ~read~ or ~write~,</ins>
549+ ): either a normal completion containing a TypedArray or a throw completion
550+ </h1>
551+ <dl class="header">
552+ <dt>description</dt>
553+ <dd>It is used to specify the creation of a new TypedArray using a constructor function.</dd>
554+ </dl>
555+ <emu-alg>
556+ 1. <ins>If _accessMode_ is not present, set _accessMode_ to ~read~.</ins>
557+ 1. Let _newTypedArray_ be ? Construct(_constructor_, _argumentList_).
558+ 1. Let _taRecord_ be ? ValidateTypedArray(_newTypedArray_, ~seq-cst~<ins>, _accessMode_</ins>).
559+ 1. If the number of elements in _argumentList_ is 1 and _argumentList_[0] is a Number, then
560+ 1. If IsTypedArrayOutOfBounds(_taRecord_) is *true*, throw a *TypeError* exception.
561+ 1. Let _length_ be TypedArrayLength(_taRecord_).
562+ 1. If _length_ < ℝ(_argumentList_[0]), throw a *TypeError* exception.
563+ 1. Return _newTypedArray_.
564+ </emu-alg>
565+ </emu-clause>
566+
469567 <emu-clause id="sec-validatetypedarray" type="abstract operation" number="4">
470568 <h1>
471569 ValidateTypedArray (
0 commit comments