@halospv3/hce.shared-config
Version:
Automate commit message quality, changelogs, and CI/CD releases. Its `main` entry point is a Semantic Release config. Functions and classes are exposed for customization. An ESLint config, a Commitlint config, and addl. resources for .NET projects are als
26 lines (25 loc) • 1.1 kB
JavaScript
//#region src/utils/reflection/filterForGetters.ts
/**
* Iterates through the descriptors object, checking for property descriptors whose `get` is a function.
* Returns an {@link OwnGetterDescriptorMap} of the getters.
* If you want only own, non-inherited getters, you must filter sanitize the
* type the `descriptors` parameter yourself e.g. `Omit<Class, keyof
* SuperClass>`.
* @param descriptorMap An object like the return value of Object.getOwnPropertyDescriptors
* @template Class Any ClassLike type
* @template T Any `object`-like type.
* @template [__proto__=null] If {@link Class} is not {@link ClassLike}, the `__proto__` of {@link T}.
* @returns An {@link OwnGetterDescriptorMap}.
* @since 3.0.0
*/
function filterForGetters(descriptorMap) {
let getterDescriptorMap = {};
for (const key in descriptorMap) {
const element = descriptorMap[key];
if (typeof element.get === "function") getterDescriptorMap = Object.assign(getterDescriptorMap, { [key]: element });
}
return getterDescriptorMap;
}
//#endregion
export { filterForGetters };
//# sourceMappingURL=filterForGetters.mjs.map