UNPKG

@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

32 lines (31 loc) 1.76 kB
import { filterForGetters } from "./filterForGetters.mjs"; import { getOwnPropertyDescriptors } from "./getOwnPropertyDescriptors.mjs"; //#region src/utils/reflection/listOwnGetters.ts /** * # !WARNING! * > If you don't specify the Class's SuperClass (or `BaseClassProto`) via WithProto, the return type will wrongly include inherited property names! This is a design limitation of TypeScript. * * Returns the names of the instantiated (or static), noninherited getters derived from the * given prototype or prototype of the given object. * @template {ClassLike<ConstructorConstraint<Class> & WithProto<SuperClassLike | BaseClassProto>>} Class * @template {InstanceOrStatic} _InstanceOrStatic 'Instance' or 'Static'. Determines the return type. * @param classDefinition Any class cast to ClassLike * @param instanceOrStatic 'Instance' or 'Static'. Determines the return type. * @since 3.0.0 * @returns * An array of names of getters that were not inherited from a parent class. If {@link classDefinition} is a class instance, the names of instanced getters are returned. Otherwise, the names of static getters are returned; */ function listOwnGetters(classDefinition, instanceOrStatic) { if (instanceOrStatic === "Instance") { const getterDescriptorMap = filterForGetters(getOwnPropertyDescriptors(classDefinition, instanceOrStatic)); return Reflect.ownKeys(getterDescriptorMap); } if (instanceOrStatic === "Static") { const getterDescriptorMap = filterForGetters(getOwnPropertyDescriptors(classDefinition, instanceOrStatic)); return Reflect.ownKeys(getterDescriptorMap); } throw new TypeError("Argument `instanceOrStatic` must be \"Instance\" or \"Static\"."); } //#endregion export { listOwnGetters }; //# sourceMappingURL=listOwnGetters.mjs.map