Skip to content

Commit fab75ff

Browse files
committed
Make voting separately easier
1 parent 8dc8a61 commit fab75ff

4 files changed

Lines changed: 83 additions & 45 deletions

File tree

‎README.md‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ This proposal introduces three built-in methods that efficiently obtain the coun
1616
- `Object.getOwnPropertyNamesLength(target)` — counts all own string-keyed properties, mirroring `Object.getOwnPropertyNames`.
1717
- `Object.getOwnPropertySymbolsLength(target)` — counts all own symbol-keyed properties, mirroring `Object.getOwnPropertySymbols`.
1818

19+
To make review and advancement straightforward, the specification is split into two independently-advancable documents. One for Object.keysLength, and one for the other two combines.
20+
1921
## Motivation
2022

2123
Developers frequently rely on patterns like:
@@ -261,7 +263,10 @@ The native implementation should strictly avoid creating intermediate arrays or
261263
- For `Object.getOwnPropertySymbolsLength`: if the key is a symbol (enumerable or not), increment `count`.
262264
4. Return `count`.
263265

264-
See the [spec proposal](./spec.emu) for details.
266+
See the spec documents for details:
267+
268+
- `Object.keysLength`: [spec-keyslength.emu](./spec-keyslength.emu)
269+
- `Object.getOwnPropertyNamesLength` and `Object.getOwnPropertySymbolsLength`: [spec-names-symbols-length.emu](./spec-names-symbols-length.emu)
265270

266271
## Alternatives Considered
267272

‎spec-keyslength.emu‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!doctype html>
2+
<meta charset="utf8">
3+
<link rel="stylesheet" href="./spec.css">
4+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css">
5+
<script src="./spec.js"></script>
6+
<pre class="metadata">
7+
title: Object.keysLength
8+
stage: 1
9+
contributors: Ruben Bridgewater, Jordan Harband
10+
</pre>
11+
12+
<emu-clause id="sec-object-keyslength">
13+
<h1>Object.keysLength ( _target_ )</h1>
14+
<p>When the `Object.keysLength` method is called, the following steps are taken:</p>
15+
<emu-alg>
16+
1. If _target_ is not an Object, throw a *TypeError* exception.
17+
1. Let _count_ be 0.
18+
1. Let _ownKeys_ be ? _target_.[[OwnPropertyKeys]]().
19+
1. For each element _key_ of _ownKeys_, do
20+
1. If _key_ is a String, then
21+
1. Let _desc_ be ? _target_.[[GetOwnProperty]](_key_).
22+
1. If _desc_ is not *undefined* and _desc_.[[Enumerable]] is *true*, then
23+
1. Set _count_ to _count_ + 1.
24+
1. Return 𝔽(_count_).
25+
</emu-alg>
26+
</emu-clause>
27+
28+

‎spec-names-symbols-length.emu‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!doctype html>
2+
<meta charset="utf8">
3+
<link rel="stylesheet" href="./spec.css">
4+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css">
5+
<script src="./spec.js"></script>
6+
<pre class="metadata">
7+
title: Object.getOwnPropertyNamesLength, Object.getOwnPropertySymbolsLength
8+
stage: 1
9+
contributors: Ruben Bridgewater, Jordan Harband
10+
</pre>
11+
12+
<emu-clause id="sec-object-getownpropertynameslength">
13+
<h1>Object.getOwnPropertyNamesLength ( _target_ )</h1>
14+
<p>When the `Object.getOwnPropertyNamesLength` method is called, the following steps are taken:</p>
15+
<emu-alg>
16+
1. If _target_ is not an Object, throw a *TypeError* exception.
17+
1. Let _count_ be 0.
18+
1. Let _ownKeys_ be ? _target_.[[OwnPropertyKeys]]().
19+
1. For each element _key_ of _ownKeys_, do
20+
1. If _key_ is a String, then
21+
1. Set _count_ to _count_ + 1.
22+
1. Return 𝔽(_count_).
23+
</emu-alg>
24+
</emu-clause>
25+
26+
<emu-clause id="sec-object-getownpropertysymbolslength">
27+
<h1>Object.getOwnPropertySymbolsLength ( _target_ )</h1>
28+
<p>When the `Object.getOwnPropertySymbolsLength` method is called, the following steps are taken:</p>
29+
<emu-alg>
30+
1. If _target_ is not an Object, throw a *TypeError* exception.
31+
1. Let _count_ be 0.
32+
1. Let _ownKeys_ be ? _target_.[[OwnPropertyKeys]]().
33+
1. For each element _key_ of _ownKeys_, do
34+
1. If _key_ is a Symbol, then
35+
1. Set _count_ to _count_ + 1.
36+
1. Return 𝔽(_count_).
37+
</emu-alg>
38+
</emu-clause>
39+
40+

‎spec.emu‎

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,51 +4,16 @@
44
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css">
55
<script src="./spec.js"></script>
66
<pre class="metadata">
7-
title: Object.keysLength, Object.getOwnPropertyNamesLength, Object.getOwnPropertySymbolsLength
7+
title: Performant object property counting (index)
88
stage: 1
99
contributors: Ruben Bridgewater, Jordan Harband
1010
</pre>
1111

12-
<emu-clause id="sec-object-keyslength">
13-
<h1>Object.keysLength ( _target_ )</h1>
14-
<p>When the `Object.keysLength` method is called, the following steps are taken:</p>
15-
<emu-alg>
16-
1. If _target_ is not an Object, throw a *TypeError* exception.
17-
1. Let _count_ be 0.
18-
1. Let _ownKeys_ be ? _target_.[[OwnPropertyKeys]]().
19-
1. For each element _key_ of _ownKeys_, do
20-
1. If _key_ is a String, then
21-
1. Let _desc_ be ? _target_.[[GetOwnProperty]](_key_).
22-
1. If _desc_ is not *undefined* and _desc_.[[Enumerable]] is *true*, then
23-
1. Set _count_ to _count_ + 1.
24-
1. Return 𝔽(_count_).
25-
</emu-alg>
26-
</emu-clause>
27-
28-
<emu-clause id="sec-object-getownpropertynameslength">
29-
<h1>Object.getOwnPropertyNamesLength ( _target_ )</h1>
30-
<p>When the `Object.getOwnPropertyNamesLength` method is called, the following steps are taken:</p>
31-
<emu-alg>
32-
1. If _target_ is not an Object, throw a *TypeError* exception.
33-
1. Let _count_ be 0.
34-
1. Let _ownKeys_ be ? _target_.[[OwnPropertyKeys]]().
35-
1. For each element _key_ of _ownKeys_, do
36-
1. If _key_ is a String, then
37-
1. Set _count_ to _count_ + 1.
38-
1. Return 𝔽(_count_).
39-
</emu-alg>
40-
</emu-clause>
41-
42-
<emu-clause id="sec-object-getownpropertysymbolslength">
43-
<h1>Object.getOwnPropertySymbolsLength ( _target_ )</h1>
44-
<p>When the `Object.getOwnPropertySymbolsLength` method is called, the following steps are taken:</p>
45-
<emu-alg>
46-
1. If _target_ is not an Object, throw a *TypeError* exception.
47-
1. Let _count_ be 0.
48-
1. Let _ownKeys_ be ? _target_.[[OwnPropertyKeys]]().
49-
1. For each element _key_ of _ownKeys_, do
50-
1. If _key_ is a Symbol, then
51-
1. Set _count_ to _count_ + 1.
52-
1. Return 𝔽(_count_).
53-
</emu-alg>
54-
</emu-clause>
12+
<emu-intro id="sec-index-intro">
13+
<h1>Overview</h1>
14+
<p>This index groups the specification work for performant object property counting methods that avoid intermediate array allocation. Each item is a separate, independently-advancable proposal.</p>
15+
<ul>
16+
<li><a href="./spec-keyslength.html">Object.keysLength</a> — counts own enumerable string-keyed properties.</li>
17+
<li><a href="./spec-names-symbols-length.html">Object.getOwnPropertyNamesLength &amp; Object.getOwnPropertySymbolsLength</a> — counts own string-keyed (all) and own symbol-keyed (all) properties.</li>
18+
</ul>
19+
</emu-intro>

0 commit comments

Comments
 (0)