|
Last change
on this file since a762898 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
326 bytes
|
| Line | |
|---|
| 1 | // Fast method for counting an object's keys
|
|---|
| 2 | // without resorting to `Object.keys(obj).length
|
|---|
| 3 | // Will this make a big difference in perf? Probably not
|
|---|
| 4 | // But we can save a few allocations.
|
|---|
| 5 |
|
|---|
| 6 | export function countObjectKeys(obj: Record<any, any>) {
|
|---|
| 7 | let count = 0
|
|---|
| 8 |
|
|---|
| 9 | for (const _key in obj) {
|
|---|
| 10 | count++
|
|---|
| 11 | }
|
|---|
| 12 |
|
|---|
| 13 | return count
|
|---|
| 14 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.