Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 79604f2

Browse files
committed
Add TypedArray Support
This builds on #2 to add `TypedArray` support, where the values of the objects are instances of the `TypedArray` class.
1 parent f603437 commit 79604f2

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

index.html

+17-1
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,11 @@
10951095
});
10961096
10971097
let sdoMap = JSON.parse(`{}`);
1098+
<<<<<<< HEAD
10981099
let biblio = JSON.parse(`{"refsByClause":{"sec-array.prototype.groupby":["_ref_0","_ref_1","_ref_2","_ref_3","_ref_4","_ref_5","_ref_6","_ref_7","_ref_8","_ref_9","_ref_10","_ref_11"]},"entries":[{"type":"clause","id":"sec-scope","aoid":null,"titleHTML":"Scope","number":"1","referencingIds":[],"key":"Scope"},{"type":"clause","id":"sec-array.prototype.groupby","aoid":null,"titleHTML":"Array.prototype.groupBy ( <var>callbackfn</var> [ , <var>thisArg</var> ] )","number":"2.1","referencingIds":[],"key":"Array.prototype.groupBy ( callbackfn [ , thisArg ] )"},{"type":"clause","id":"sec-properties-of-the-array-prototype-object","aoid":null,"titleHTML":"Properties of the Array Prototype Object (<a href=\\"https://tc39.es/ecma262/#sec-properties-of-the-array-prototype-object\\">22.1.3</a>)","number":"2","referencingIds":[],"key":"Properties of the Array Prototype Object (22.1.3)"},{"type":"clause","id":"sec-copyright-and-software-license","aoid":null,"titleHTML":"Copyright &amp; Software License","number":"A","referencingIds":[],"key":"Copyright & Software License"}]}`);
1100+
=======
1101+
let biblio = JSON.parse(`{"refsByClause":{"sec-array.prototype.groupby":["_ref_0","_ref_1","_ref_2","_ref_3","_ref_4","_ref_5","_ref_6","_ref_7","_ref_8","_ref_9"]},"entries":[{"type":"clause","id":"sec-scope","aoid":null,"titleHTML":"Scope","number":"1","referencingIds":[],"key":"Scope"},{"type":"clause","id":"sec-array.prototype.groupby","aoid":null,"titleHTML":"Array.prototype.groupBy ( <var>callbackfn</var> [ , <var>thisArg</var> ] )","number":"2.1","referencingIds":[],"key":"Array.prototype.groupBy ( callbackfn [ , thisArg ] )"},{"type":"clause","id":"sec-properties-of-the-array-prototype-object","aoid":null,"titleHTML":"Properties of the Array Prototype Object (<a href=\\"https://tc39.es/ecma262/#sec-properties-of-the-array-prototype-object\\">22.1.3</a>)","number":"2","referencingIds":[],"key":"Properties of the Array Prototype Object (22.1.3)"},{"type":"clause","id":"sec-%typedarray%.prototype.groupBy","aoid":null,"titleHTML":"%TypedArray%.prototype.groupBy ( <var>callbackfn</var> [ , <var>thisArg</var> ] )","number":"3.1","referencingIds":[],"key":"%TypedArray%.prototype.groupBy ( callbackfn [ , thisArg ] )"},{"type":"clause","id":"sec-typedarray-objects","aoid":null,"titleHTML":"TypedArray Objects","number":"3","referencingIds":[],"key":"TypedArray Objects"},{"type":"clause","id":"sec-copyright-and-software-license","aoid":null,"titleHTML":"Copyright &amp; Software License","number":"A","referencingIds":[],"key":"Copyright & Software License"}]}`);
1102+
>>>>>>> bf2815b... Add TypedArray Support
10991103
;let usesMultipage = false</script><style>body {
11001104
display: flex;
11011105
font-size: 18px;
@@ -2240,7 +2244,7 @@
22402244
.normative-optional-tag a {
22412245
color: #884400;
22422246
}
2243-
</style></head><body><div id="menu-toggle">☰</div><div id="menu-spacer"></div><div id="menu"><div id="menu-search"><input type="text" id="menu-search-box" placeholder="Search..."><div id="menu-search-results" class="inactive"></div></div><div id="menu-pins"><div class="menu-pane-header">Pins</div><ul id="menu-pins-list"></ul></div><div class="menu-pane-header">Table of Contents</div><div id="menu-toc"><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-scope" title="Scope"><span class="secnum">1</span> Scope</a></li><li><span class="item-toggle">◢</span><a href="#sec-properties-of-the-array-prototype-object" title="Properties of the Array Prototype Object (22.1.3)"><span class="secnum">2</span> Properties of the Array Prototype Object (</a><a href="https://tc39.es/ecma262/#sec-properties-of-the-array-prototype-object">22.1.3</a>)<ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-array.prototype.groupby" title="Array.prototype.groupBy ( callbackfn [ , thisArg ] )"><span class="secnum">2.1</span> Array.prototype.groupBy ( <var>callbackfn</var> [ , <var>thisArg</var> ] )</a></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-copyright-and-software-license" title="Copyright &amp; Software License"><span class="secnum">A</span> Copyright &amp; Software License</a></li></ol></div></div><div id="spec-container"><h1 class="version">Stage 1 Draft / July 15, 2021</h1><h1 class="title">Array Grouping</h1>
2247+
</style></head><body><div id="menu-toggle">☰</div><div id="menu-spacer"></div><div id="menu"><div id="menu-search"><input type="text" id="menu-search-box" placeholder="Search..."><div id="menu-search-results" class="inactive"></div></div><div id="menu-pins"><div class="menu-pane-header">Pins</div><ul id="menu-pins-list"></ul></div><div class="menu-pane-header">Table of Contents</div><div id="menu-toc"><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-scope" title="Scope"><span class="secnum">1</span> Scope</a></li><li><span class="item-toggle">◢</span><a href="#sec-properties-of-the-array-prototype-object" title="Properties of the Array Prototype Object (22.1.3)"><span class="secnum">2</span> Properties of the Array Prototype Object (</a><a href="https://tc39.es/ecma262/#sec-properties-of-the-array-prototype-object">22.1.3</a>)<ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-array.prototype.groupby" title="Array.prototype.groupBy ( callbackfn [ , thisArg ] )"><span class="secnum">2.1</span> Array.prototype.groupBy ( <var>callbackfn</var> [ , <var>thisArg</var> ] )</a></li></ol></li><li><span class="item-toggle">◢</span><a href="#sec-typedarray-objects" title="TypedArray Objects"><span class="secnum">3</span> TypedArray Objects</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-%typedarray%.prototype.groupBy" title="%TypedArray%.prototype.groupBy ( callbackfn [ , thisArg ] )"><span class="secnum">3.1</span> %TypedArray%.prototype.groupBy ( <var>callbackfn</var> [ , <var>thisArg</var> ] )</a></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-copyright-and-software-license" title="Copyright &amp; Software License"><span class="secnum">A</span> Copyright &amp; Software License</a></li></ol></div></div><div id="spec-container"><h1 class="version">Stage 1 Draft / July 15, 2021</h1><h1 class="title">Array Grouping</h1>
22442248
22452249
<emu-clause id="sec-scope">
22462250
<h1><span class="secnum">1</span> Scope</h1>
@@ -2270,6 +2274,18 @@ <h1><span class="secnum">2.1</span> Array.prototype.groupBy ( <var>callbackfn</v
22702274
</div></emu-note>
22712275
</emu-clause>
22722276
</ins>
2277+
</emu-clause>
2278+
2279+
<emu-clause id="sec-typedarray-objects">
2280+
<h1><span class="secnum">3</span> TypedArray Objects</h1>
2281+
2282+
<ins class="block">
2283+
<emu-clause id="sec-%typedarray%.prototype.groupBy">
2284+
<h1><span class="secnum">3.1</span> %TypedArray%.prototype.groupBy ( <var>callbackfn</var> [ , <var>thisArg</var> ] )</h1>
2285+
<p>The interpretation and use of the arguments of <emu-xref href="#sec-%typedarray%-intrinsic-object"><a href="https://tc39.es/ecma262/#sec-%typedarray%-intrinsic-object">%TypedArray%</a></emu-xref><code>.prototype.groupBy</code> are the same as for <code>Array.prototype.groupBy</code> as defined in <emu-xref href="#sec-array.prototype.filter"><a href="https://tc39.es/ecma262/#sec-array.prototype.filter">22.1.3.7</a></emu-xref>.</p>
2286+
<p>When the <code>groupBy</code> method is called, the following steps are taken:</p>
2287+
</emu-clause>
2288+
</ins>
22732289
</emu-clause><emu-annex id="sec-copyright-and-software-license">
22742290
<h1><span class="secnum">A</span> Copyright &amp; Software License</h1>
22752291

spec.emu

+44
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,47 @@ location: https://tc39.es/proposal-array-grouping/
7070
</emu-clause>
7171
</ins>
7272
</emu-clause>
73+
74+
<emu-clause id="sec-typedarray-objects">
75+
<h1>TypedArray Objects</h1>
76+
77+
<ins class="block">
78+
<emu-clause id="sec-%typedarray%.prototype.groupBy">
79+
<h1>%TypedArray%.prototype.groupBy ( _callbackfn_ [ , _thisArg_ ] )</h1>
80+
<p>The interpretation and use of the arguments of %TypedArray%`.prototype.groupBy` are the same as for `Array.prototype.groupBy` as defined in <emu-xref href="#sec-array.prototype.groupBy"></emu-xref>.</p>
81+
<p>When the `groupBy` method is called, the following steps are taken:</p>
82+
<emu-alg>
83+
1. Let _O_ be the *this* value.
84+
1. Perform ? ValidateTypedArray(_O_).
85+
1. Let _len_ be _O_.[[ArrayLength]].
86+
1. If IsCallable(_callbackfn_) is *false*, throw a *TypeError* exception.
87+
1. Let _k_ be 0.
88+
1. Let _groups_ be a new empty List.
89+
1. Repeat, while _k_ &lt; _len_
90+
1. Let _Pk_ be ! ToString(_k_).
91+
1. Let _kValue_ be ? Get(_O_, _Pk_).
92+
1. Let _propertyKey_ be ? ToPropertyKey(? Call(_callbackfn_, _thisArg_, &laquo; _kValue_, _k_, _O_ &raquo;)).
93+
1. Let _group_ be ~empty~.
94+
1. For each Record { [[Key]], [[Elements]] } _g_ of _groups_, do
95+
1. If ! SameValueNonNumeric(_g_.[[Key]], _propertyKey_) is *true*, then
96+
1. Set _group_ to _g_.
97+
1. If _group_ is ~empty~, then
98+
1. Let _elements_ be a new empty List.
99+
1. Set _group_ to the Record { [[Key]]: _propertyKey_, [[Elements]]: _elements_ }.
100+
1. Append _group_ as the last element of _groups_.
101+
1. Append _kValue_ as the last element of _group_.[[Elements]].
102+
1. Set _k_ to _k_ + 1.
103+
1. Let _obj_ be ! OrdinaryObjectCreate(*null*).
104+
1. For each Record { [[Key]], [[Elements]] } _g_ of _groups_, do
105+
1. Let _len_ be the number of elements in _g_.[[Elements]].
106+
1. Let _elements_ be ? TypedArraySpeciesCreate(_O_, &laquo; 𝔽(_len_) &raquo;).
107+
1. Let _i_ be 0.
108+
1. For each element _e_ of _g_.[[Elements]], do
109+
1. Perform ! Set(_elements_, ! ToString(𝔽(_i_)), _e_, *true*).
110+
1. Set _i_ to _i_ + 1.
111+
1. Perform ! CreateDataPropertyOrThrow(_obj_, _g_.[[Key]], _elements_).
112+
1. Return _obj_.
113+
</emu-alg>
114+
</emu-clause>
115+
</ins>
116+
</emu-clause>

0 commit comments

Comments
 (0)