Skip to content

Commit

Permalink
Editorial: Tweak EnumerateObjectProperties informative definition (#656)
Browse files Browse the repository at this point in the history
* add missing semicolon
* improve variable naming consistency
* early return for symbols
* prefer const over let
* new Set --> new Set()
  • Loading branch information
shvaikalesh authored and bterlson committed Aug 12, 2016
1 parent 6306693 commit 5ee666e
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -16171,20 +16171,19 @@ <h1>EnumerateObjectProperties (_O_)</h1>
<p>The following is an informative definition of an ECMAScript generator function that conforms to these rules:</p>
<pre><code class="javascript">
function* EnumerateObjectProperties(obj) {
let visited = new Set;
for (let key of Reflect.ownKeys(obj)) {
if (typeof key === "string") {
let desc = Reflect.getOwnPropertyDescriptor(obj, key);
if (desc && !visited.has(key)) {
visited.add(key);
if (desc.enumerable) yield key;
}
const visited = new Set();
for (const key of Reflect.ownKeys(obj)) {
if (typeof key === "symbol") continue;
const desc = Reflect.getOwnPropertyDescriptor(obj, key);
if (desc && !visited.has(key)) {
visited.add(key);
if (desc.enumerable) yield key;
}
}
let proto = Reflect.getPrototypeOf(obj)
const proto = Reflect.getPrototypeOf(obj);
if (proto === null) return;
for (let protoName of EnumerateObjectProperties(proto)) {
if (!visited.has(protoName)) yield protoName;
for (const protoKey of EnumerateObjectProperties(proto)) {
if (!visited.has(protoKey)) yield protoKey;
}
}
</code></pre>
Expand Down

0 comments on commit 5ee666e

Please sign in to comment.