WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-16Lines changed: 16 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -145,7 +145,7 @@ This creates intermediate arrays, causing unnecessary memory usage and garbage c
145
145
146
146
On top of that, it is also not possible to identify an array that is sparse without calling `Object.keys()` (or similar). This API would allow that by explicitly checking for own index properties.
147
147
148
-
## Proposed Syntax
148
+
## Proposed API
149
149
150
150
```javascript
151
151
Object.propertyCount(target[, options])
@@ -250,22 +250,22 @@ When the `propertyCount` method is called, the following steps are taken:
250
250
3. Let _keyTypes_ be ? Get(_options_, "keyTypes").
251
251
4. If _keyTypes_ is undefined, set _keyTypes_ to the array `['index', 'nonIndexString']`.
252
252
5. Else, perform the following:
253
-
a. If Type(_keyTypes_) is not Object, throw a TypeError exception.
254
-
b. Set _keyTypes_ to an internal List whose elements are the String values of the elements of _keyTypes_.
255
-
c. If _keyTypes_ contains any value other than "index", "nonIndexString", or "symbol", throw a TypeError exception.
256
-
6. Let _enumerable_ be ? Get(_options_, "enumerable").
257
-
7. If _enumerable_ is undefined, set _enumerable_ to true.
258
-
8. Else if _enumerable_ is not one of true, false, or "all", throw a TypeError exception.
259
-
9. Let _count_ be 0.
260
-
10. Let _ownKeys_ be the List of own property keys of _target_, in the order returned by OrdinaryOwnPropertyKeys(_target_). (Note: No intermediate array should be allocated.)
261
-
11. For each element _key_ of _ownKeys_, perform the following steps:
262
-
a. Let _desc_ be ? OrdinaryGetOwnProperty(_target_, _key_).
263
-
b. If _enumerable_ is not 'all'
253
+
1. If Type(_keyTypes_) is not Object, throw a TypeError exception.
254
+
2. Set _keyTypes_ to an internal List whose elements are the String values of the elements of _keyTypes_.
255
+
3. If _keyTypes_ contains any value other than "index", "nonIndexString", or "symbol", throw a TypeError exception.
256
+
1. Let _enumerable_ be ? Get(_options_, "enumerable").
257
+
2. If _enumerable_ is undefined, set _enumerable_ to true.
258
+
3. Else if _enumerable_ is not one of true, false, or "all", throw a TypeError exception.
259
+
4. Let _count_ be 0.
260
+
5. Let _ownKeys_ be the List of own property keys of _target_, in the order returned by OrdinaryOwnPropertyKeys(_target_). (Note: No intermediate array should be allocated.)
261
+
6. For each element _key_ of _ownKeys_, perform the following steps:
262
+
1. Let _desc_ be ? OrdinaryGetOwnProperty(_target_, _key_).
263
+
2. If _enumerable_ is not 'all'
264
264
i. If _enumerable_ is unequal to _desc_.[[Enumerable]], continue to the next _key_.
265
-
c. If Type(_key_) is Symbol and "symbol" is present in _keyTypes_, increment _count_ by 1.
266
-
d. Else if Type(_key_) is array index and "index" is present in _keyTypes_, increment _count_ by 1.
267
-
e. Else if "nonIndexString" is present in _keyTypes_, increment _count_ by 1
268
-
12. Return _count_.
265
+
3. If Type(_key_) is Symbol and "symbol" is present in _keyTypes_, increment _count_ by 1.
266
+
4. Else if Type(_key_) is array index and "index" is present in _keyTypes_, increment _count_ by 1.
267
+
5. Else if "nonIndexString" is present in _keyTypes_, increment _count_ by 1
0 commit comments