summaryrefslogtreecommitdiff
path: root/ext/net/01_net.js
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2022-02-01 18:06:11 +0100
committerGitHub <noreply@github.com>2022-02-01 18:06:11 +0100
commit8176a4d1663529fb8aeebf7734c4994fa1d583f4 (patch)
tree94c7d6eb2679e641f59cf78640340f5b7af0022e /ext/net/01_net.js
parentabf89f8c4675ed78c992fafd6d758bf4bfca8a1a (diff)
refactor: primordials for instanceof (#13527)
Diffstat (limited to 'ext/net/01_net.js')
-rw-r--r--ext/net/01_net.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/ext/net/01_net.js b/ext/net/01_net.js
index 6f54ec999..f135a1655 100644
--- a/ext/net/01_net.js
+++ b/ext/net/01_net.js
@@ -3,8 +3,9 @@
((window) => {
const core = window.Deno.core;
- const { BadResource, Interrupted } = core;
+ const { BadResourcePrototype, InterruptedPrototype } = core;
const {
+ ObjectPrototypeIsPrototypeOf,
PromiseResolve,
SymbolAsyncIterator,
Uint8Array,
@@ -132,7 +133,10 @@
try {
conn = await this.accept();
} catch (error) {
- if (error instanceof BadResource || error instanceof Interrupted) {
+ if (
+ ObjectPrototypeIsPrototypeOf(BadResourcePrototype, error) ||
+ ObjectPrototypeIsPrototypeOf(InterruptedPrototype, error)
+ ) {
return { value: undefined, done: true };
}
throw error;
@@ -199,7 +203,10 @@
try {
yield await this.receive();
} catch (err) {
- if (err instanceof BadResource || err instanceof Interrupted) {
+ if (
+ ObjectPrototypeIsPrototypeOf(BadResourcePrototype, err) ||
+ ObjectPrototypeIsPrototypeOf(InterruptedPrototype, err)
+ ) {
break;
}
throw err;