Created
April 30, 2020 03:14
-
-
Save RienNeVaPlus/fee2ee6b3eadf61b79245896357d7624 to your computer and use it in GitHub Desktop.
Revisions
-
RienNeVaPlus created this gist
Apr 30, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ /** * Similar to Object.getOwnPropertyNames(obj) but including the properties of the entire prototype chain * @param obj * @param maxChainLength */ export function getAllPropertyNames( obj: { new(): any }, maxChainLength: number = 10 ): string[] { let set: Set<string> = new Set(), i: number = 0; do { i++; Object.getOwnPropertyNames(obj).forEach(n => set.add(n)); obj = Object.getPrototypeOf(obj); } while(obj.constructor !== Object && i < maxChainLength); return [...set]; }