sturdy-websocket
Advanced tools
Comparing version 0.1.11 to 0.1.12
@@ -23,8 +23,8 @@ export interface Options { | ||
static readonly CLOSED = 3; | ||
onclose: (event: CloseEvent) => void; | ||
onerror: (event: Event) => void; | ||
onmessage: (event: MessageEvent) => void; | ||
onopen: (event: Event) => void; | ||
ondown: (event: CloseEvent) => void; | ||
onreopen: (event: Event) => void; | ||
onclose: ((event: CloseEvent) => void) | null; | ||
onerror: ((event: Event) => void) | null; | ||
onmessage: ((event: MessageEvent) => void) | null; | ||
onopen: ((event: Event) => void) | null; | ||
ondown: ((event: CloseEvent) => void) | null; | ||
onreopen: ((event: Event) => void) | null; | ||
readonly CONNECTING = 0; | ||
@@ -31,0 +31,0 @@ readonly OPEN = 1; |
@@ -9,8 +9,8 @@ "use strict"; | ||
this.url = url; | ||
this.onclose = noop; | ||
this.onerror = noop; | ||
this.onmessage = noop; | ||
this.onopen = noop; | ||
this.ondown = noop; | ||
this.onreopen = noop; | ||
this.onclose = null; | ||
this.onerror = null; | ||
this.onmessage = null; | ||
this.onopen = null; | ||
this.ondown = null; | ||
this.onreopen = null; | ||
this.CONNECTING = SturdyWebSocket.CONNECTING; | ||
@@ -274,18 +274,30 @@ this.OPEN = SturdyWebSocket.OPEN; | ||
case "close": | ||
this.onclose(event); | ||
if (this.onclose) { | ||
this.onclose(event); | ||
} | ||
break; | ||
case "error": | ||
this.onerror(event); | ||
if (this.onerror) { | ||
this.onerror(event); | ||
} | ||
break; | ||
case "message": | ||
this.onmessage(event); | ||
if (this.onmessage) { | ||
this.onmessage(event); | ||
} | ||
break; | ||
case "open": | ||
this.onopen(event); | ||
if (this.onopen) { | ||
this.onopen(event); | ||
} | ||
break; | ||
case "down": | ||
this.ondown(event); | ||
if (this.ondown) { | ||
this.ondown(event); | ||
} | ||
break; | ||
case "reopen": | ||
this.onreopen(event); | ||
if (this.onreopen) { | ||
this.onreopen(event); | ||
} | ||
break; | ||
@@ -336,5 +348,2 @@ } | ||
exports.default = SturdyWebSocket; | ||
function noop() { | ||
return undefined; | ||
} | ||
function getDataByteLength(data) { | ||
@@ -341,0 +350,0 @@ if (typeof data === "string") { |
{ | ||
"name": "sturdy-websocket", | ||
"version": "0.1.11", | ||
"version": "0.1.12", | ||
"description": "Tiny WebSocket wrapper that reconnects and resends failed messages.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52518
441