websocket-polyfill
Advanced tools
Comparing version 0.0.2 to 0.0.3
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
} | ||
return function (d, b) { | ||
@@ -7,0 +10,0 @@ extendStatics(d, b); |
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
} | ||
return function (d, b) { | ||
@@ -7,0 +10,0 @@ extendStatics(d, b); |
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
} | ||
return function (d, b) { | ||
@@ -7,0 +10,0 @@ extendStatics(d, b); |
@@ -15,2 +15,6 @@ import { EventTarget } from "./events/EventTarget"; | ||
private on_; | ||
/** | ||
* @hidden | ||
*/ | ||
private state_; | ||
constructor(url: string, protocols?: string | string[]); | ||
@@ -22,3 +26,5 @@ close(code?: number, reason?: string): void; | ||
readonly extensions: string; | ||
readonly readyState: string; | ||
readonly readyState: number; | ||
readonly bufferedAmount: number; | ||
readonly binaryType: string; | ||
onopen: Listener<"open">; | ||
@@ -49,4 +55,10 @@ onclose: Listener<"close">; | ||
} | ||
export declare namespace WebSocket { | ||
const CONNECTING = 0; | ||
const OPEN = 1; | ||
const CLOSING = 2; | ||
const CLOSED = 3; | ||
} | ||
declare type Listener<K extends keyof WebSocketEventMap> = (event: WebSocketEventMap[K]) => void; | ||
export {}; | ||
//# sourceMappingURL=WebSocket.d.ts.map |
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
} | ||
return function (d, b) { | ||
@@ -12,9 +15,12 @@ extendStatics(d, b); | ||
})(); | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
@@ -36,2 +42,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
_this.on_ = {}; | ||
_this.state_ = WebSocket.CONNECTING; | ||
//---- | ||
@@ -51,2 +58,3 @@ // CLIENT | ||
WebSocket.prototype.close = function (code, reason) { | ||
this.state_ = WebSocket.CLOSING; | ||
if (code === undefined) | ||
@@ -111,4 +119,3 @@ this.connection_.sendCloseFrame(); | ||
get: function () { | ||
var state = this.connection_.state; | ||
return state; | ||
return this.state_; | ||
}, | ||
@@ -118,2 +125,16 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(WebSocket.prototype, "bufferedAmount", { | ||
get: function () { | ||
return this.connection_.bytesWaitingToFlush; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(WebSocket.prototype, "binaryType", { | ||
get: function () { | ||
return "arraybuffer"; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(WebSocket.prototype, "onopen", { | ||
@@ -179,2 +200,3 @@ /* ---------------------------------------------------------------- | ||
this.connection_ = connection; | ||
this.state_ = WebSocket.OPEN; | ||
this.connection_.on("message", this._Handle_message.bind(this)); | ||
@@ -191,2 +213,3 @@ this.connection_.on("error", this._Handle_error.bind(this)); | ||
var event = new CloseEvent_1.CloseEvent("close", __assign({}, EVENT_INIT, { code: code, reason: reason })); | ||
this.state_ = WebSocket.CLOSED; | ||
this.dispatchEvent(event); | ||
@@ -208,2 +231,4 @@ }; | ||
var event = new ErrorEvent_1.ErrorEvent("error", __assign({}, EVENT_INIT, { error: error, message: error.message })); | ||
if (this.state_ === WebSocket.CONNECTING) | ||
this.state_ = WebSocket.CLOSED; | ||
this.dispatchEvent(event); | ||
@@ -214,2 +239,9 @@ }; | ||
exports.WebSocket = WebSocket; | ||
(function (WebSocket) { | ||
WebSocket.CONNECTING = 0; | ||
WebSocket.OPEN = 1; | ||
WebSocket.CLOSING = 2; | ||
WebSocket.CLOSED = 3; | ||
})(WebSocket = exports.WebSocket || (exports.WebSocket = {})); | ||
exports.WebSocket = WebSocket; | ||
var EVENT_INIT = { | ||
@@ -216,0 +248,0 @@ bubbles: false, |
@@ -9,3 +9,3 @@ { | ||
}, | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"main": "lib/index.js", | ||
@@ -18,3 +18,3 @@ "typings": "lib/index.d.ts", | ||
"dependencies": { | ||
"tstl": "^2.0.6", | ||
"tstl": "^2.0.7", | ||
"websocket": "^1.0.28" | ||
@@ -21,0 +21,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
23660
25
488
0
24
Updatedtstl@^2.0.7