UNPKG

340 BPlain TextView Raw
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
6export 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}