diff options
| author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2019-05-30 14:59:30 +0200 |
|---|---|---|
| committer | Ryan Dahl <ry@tinyclouds.org> | 2019-05-30 08:59:30 -0400 |
| commit | 50a79584cb12129b3db1ef3e0eb9d0c8b9f20b62 (patch) | |
| tree | ee9a90a8b8018c03b1e1a6ace07abdaa494ea90d /ws/mod.ts | |
| parent | 80b3c486f6222f65b52eb2eca903b67312e8ce0c (diff) | |
chore: Implement strict mode (denoland/deno_std#453)
Original: https://github.com/denoland/deno_std/commit/be24677d15494e83eea2e99bfc5ccfdde31cb892
Diffstat (limited to 'ws/mod.ts')
| -rw-r--r-- | ws/mod.ts | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -31,19 +31,25 @@ export interface WebSocketCloseEvent { reason?: string; } -export function isWebSocketCloseEvent(a): a is WebSocketCloseEvent { - return a && typeof a["code"] === "number"; +export function isWebSocketCloseEvent( + a: WebSocketEvent +): a is WebSocketCloseEvent { + return typeof a === "object" && a.hasOwnProperty("code"); } export type WebSocketPingEvent = ["ping", Uint8Array]; -export function isWebSocketPingEvent(a): a is WebSocketPingEvent { +export function isWebSocketPingEvent( + a: WebSocketEvent +): a is WebSocketPingEvent { return Array.isArray(a) && a[0] === "ping" && a[1] instanceof Uint8Array; } export type WebSocketPongEvent = ["pong", Uint8Array]; -export function isWebSocketPongEvent(a): a is WebSocketPongEvent { +export function isWebSocketPongEvent( + a: WebSocketEvent +): a is WebSocketPongEvent { return Array.isArray(a) && a[0] === "pong" && a[1] instanceof Uint8Array; } @@ -436,6 +442,8 @@ async function handshake( if (!m) { throw new Error("ws: invalid status line: " + statusLine); } + + // @ts-ignore const { version, statusCode } = m.groups; if (version !== "HTTP/1.1" || statusCode !== "101") { throw new Error( |
