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

35 lines (34 loc) 1.65 kB
import { getOwnPropertyDescriptors } from "./getOwnPropertyDescriptors.mjs"; import { getPrototypesChainOf } from "./getPrototypeChainOf.mjs"; //#region src/utils/reflection/getOwnPropertyDescriptorsRecursively.ts /** * Walks the class inheritance chain to get a PropertyDescriptorMap of each class. * * While you _can_ use this to get an array of getter names/keys, you should use {@link getPrototypeOf} and {@link listOwnGetters}, instead! * @template Class Any class definition type-cast to {@link ClassLike} * @template _InstanceOrStatic * @param classDefinition Any class definition type-cast to {@link ClassLike} * @param instanceOrStatic 'Instance' or 'Static'. Determines the return type. * @returns An * ordered array of {@link OwnPropertyDescriptorMap} or * {@link InstancePropertyDescriptorMap} starting with {@link classDefinition} * and ending with a {@link BaseClass}. * @since 3.0.0 */ function getOwnPropertyDescriptorsRecursively(classDefinition, instanceOrStatic) { const staticPrototypeChain = getPrototypesChainOf(classDefinition, "classes"); if (isSingleTuple(staticPrototypeChain)) return [getOwnPropertyDescriptors(staticPrototypeChain[0], instanceOrStatic)]; return staticPrototypeChain.map((classDefinition) => getOwnPropertyDescriptors(classDefinition, instanceOrStatic)); } /** * Simple utility for single-tuple type assertion * @template {T} T T in T[] * @param array an array * @returns array is [T] */ function isSingleTuple(array) { return Array.isArray(array) && array.length === 1; } //#endregion export { getOwnPropertyDescriptorsRecursively }; //# sourceMappingURL=getOwnPropertyDescriptorsRecursively.mjs.map