Last active
October 16, 2019 11:23
-
-
Save mdix/0cfa653419932d5a2f35d19f009ee77d to your computer and use it in GitHub Desktop.
Determine base class (last level before builtin)
This file contains 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 characters
function getBaseClass(MaybeClass) { | |
if (typeof MaybeClass !== 'function') { | |
return null; | |
} | |
const Proto = Reflect.getPrototypeOf(MaybeClass); | |
return !Proto.name | |
? MaybeClass | |
: getBaseClass(Proto); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment