foxts
Version:
Opinionated collection of common TypeScript utils by @SukkaW
30 lines (28 loc) • 1.04 kB
TypeScript
/**
* Ponyfill for the TC39 "Property Counting" proposal.
*
* @see https://github.com/tc39/proposal-object-property-count
*/
/**
* Counts own, enumerable, string-keyed properties (including array indices).
*
* Equivalent to `Object.keys(target).length`, but without allocating the
* intermediate array.
*/
declare function keysLength(target: object): number;
/**
* Counts own, string-keyed properties (including array indices), both
* enumerable and non-enumerable.
*
* There is no allocation-free reflection primitive for this, so it delegates to
* `Object.getOwnPropertyNames(target).length`.
*/
declare function getOwnPropertyNamesLength(target: object): number;
/**
* Counts own, symbol-keyed properties, regardless of enumerability.
*
* There is no allocation-free reflection primitive for this, so it delegates to
* `Object.getOwnPropertySymbols(target).length`.
*/
declare function getOwnPropertySymbolsLength(target: object): number;
export { getOwnPropertyNamesLength, getOwnPropertySymbolsLength, keysLength };