Skip to content

Commit 523fc9a

Browse files
author
Kent C. Dodds
committed
fix: remove try/catch.
Thanks @sebmck
1 parent 143f628 commit 523fc9a

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/index.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,9 @@ const noop = () => {}
1515
// NOTE: I tried doing the "proper thing" using Symbol.hasInstance
1616
// but no matter what that did, I couldn't make that work with a SyntaxError
1717
// because SyntaxError[Symbol.hasInstance]() returns false. What. The. Heck!?
18-
// So I'm doing this hacky try/catch garbage :-/
18+
// So I'm doing this .prototype stuff :-/
1919
function instanceOf(inst, cls) {
20-
try {
21-
return inst instanceof cls
22-
} catch (error) {
23-
return false
24-
}
20+
return cls.prototype !== undefined && inst instanceof cls
2521
}
2622

2723
module.exports = pluginTester

0 commit comments

Comments
 (0)