Skip to content

Instantly share code, notes, and snippets.

@kentcdodds
Last active August 19, 2019 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kentcdodds/deb2f43fb7e7683c3f9988d720c28b1c to your computer and use it in GitHub Desktop.
Save kentcdodds/deb2f43fb7e7683c3f9988d720c28b1c to your computer and use it in GitHub Desktop.
// 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