Last active
August 19, 2019 17:55
-
-
Save kentcdodds/deb2f43fb7e7683c3f9988d720c28b1c to your computer and use it in GitHub Desktop.
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
// thanks to node throwing an error if you try to use instanceof with an arrow | |
// function we have to have this function. I guess it's spec... SMH... | |
// NOTE: I tried doing the "proper thing" using Symbol.instanceOf | |
// but no matter what that did, I couldn't make that work with a SyntaxError | |
// because SyntaxError[Symbol.hasInstance]() returns false. What. The. Heck!? | |
// So I'm doing this hacky try/catch garbage :-/ | |
function instanceOf(inst, cls) { | |
try { | |
return inst instanceof cls | |
} catch (error) { | |
return false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment