diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-02-01 18:06:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-01 18:06:11 +0100 |
commit | 8176a4d1663529fb8aeebf7734c4994fa1d583f4 (patch) | |
tree | 94c7d6eb2679e641f59cf78640340f5b7af0022e /ext/websocket/02_websocketstream.js | |
parent | abf89f8c4675ed78c992fafd6d758bf4bfca8a1a (diff) |
refactor: primordials for instanceof (#13527)
Diffstat (limited to 'ext/websocket/02_websocketstream.js')
-rw-r--r-- | ext/websocket/02_websocketstream.js | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/ext/websocket/02_websocketstream.js b/ext/websocket/02_websocketstream.js index 0a14657e9..0f4cecaa5 100644 --- a/ext/websocket/02_websocketstream.js +++ b/ext/websocket/02_websocketstream.js @@ -11,18 +11,19 @@ const { add, remove } = window.__bootstrap.abortSignal; const { + ArrayPrototypeJoin, + ArrayPrototypeMap, + Error, + ObjectPrototypeIsPrototypeOf, + PromisePrototypeCatch, + PromisePrototypeThen, + Set, StringPrototypeEndsWith, StringPrototypeToLowerCase, Symbol, SymbolFor, - Set, - ArrayPrototypeMap, - ArrayPrototypeJoin, - PromisePrototypeThen, - PromisePrototypeCatch, - Uint8Array, TypeError, - Error, + Uint8ArrayPrototype, } = window.__bootstrap.primordials; webidl.converters.WebSocketStreamOptions = webidl.createDictionaryConverter( @@ -70,7 +71,7 @@ [_url]; get url() { - webidl.assertBranded(this, WebSocketStream); + webidl.assertBranded(this, WebSocketStreamPrototype); return this[_url]; } @@ -195,7 +196,9 @@ kind: "text", value: chunk, }); - } else if (chunk instanceof Uint8Array) { + } else if ( + ObjectPrototypeIsPrototypeOf(Uint8ArrayPrototype, chunk) + ) { await core.opAsync("op_ws_send", this[_rid], { kind: "binary", value: chunk, @@ -296,7 +299,7 @@ } }, (err) => { - if (err instanceof core.Interrupted) { + if (ObjectPrototypeIsPrototypeOf(core.InterruptedPrototype, err)) { // The signal was aborted. err = options.signal.reason; } else { @@ -311,19 +314,19 @@ [_connection] = new Deferred(); get connection() { - webidl.assertBranded(this, WebSocketStream); + webidl.assertBranded(this, WebSocketStreamPrototype); return this[_connection].promise; } [_earlyClose] = false; [_closed] = new Deferred(); get closed() { - webidl.assertBranded(this, WebSocketStream); + webidl.assertBranded(this, WebSocketStreamPrototype); return this[_closed].promise; } close(closeInfo) { - webidl.assertBranded(this, WebSocketStream); + webidl.assertBranded(this, WebSocketStreamPrototype); closeInfo = webidl.converters.WebSocketCloseInfo(closeInfo, { prefix: "Failed to execute 'close' on 'WebSocketStream'", context: "Argument 1", @@ -381,5 +384,7 @@ } } + const WebSocketStreamPrototype = WebSocketStream.prototype; + window.__bootstrap.webSocket.WebSocketStream = WebSocketStream; })(this); |