websocket-as-promised
Advanced tools
Comparing version 1.0.1 to 1.1.0
{ | ||
"name": "websocket-as-promised", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "A WebSocket client library providing Promise-based API for connecting, disconnecting and messaging with server", | ||
@@ -22,3 +22,3 @@ "author": { | ||
"test-installed": "node scripts/install-local && LIB_PATH=../.installed/node_modules/websocket-as-promised npm t", | ||
"ci": "run-s lint test test-installed", | ||
"test-ci": "run-s lint test test-installed", | ||
"docs": "node scripts/docs", | ||
@@ -41,5 +41,5 @@ "prerelease": "run-s lint test test-installed", | ||
"dependencies": { | ||
"chnl": "^1.0.0", | ||
"chnl": "^1.2.0", | ||
"promise-controller": "^1.0.0", | ||
"promise.prototype.finally": "^3.1.1" | ||
"promise.prototype.finally": "^3.1.2" | ||
}, | ||
@@ -49,13 +49,13 @@ "devDependencies": { | ||
"chai-as-promised": "^7.1.1", | ||
"eslint": "^6.6.0", | ||
"eslint-plugin-mocha": "^6.2.1", | ||
"get-port": "^5.0.0", | ||
"husky": "^3.1.0", | ||
"install-local": "^1.0.0", | ||
"jsdoc-to-markdown": "^5.0.3", | ||
"lint-staged": "^9.4.3", | ||
"mocha": "^6.2.2", | ||
"eslint": "^7.11.0", | ||
"eslint-plugin-mocha": "^8.0.0", | ||
"get-port": "^5.1.1", | ||
"husky": "^4.3.0", | ||
"install-local": "^2.0.0", | ||
"jsdoc-to-markdown": "^6.0.1", | ||
"lint-staged": "^10.4.0", | ||
"mocha": "^8.1.3", | ||
"npm-run-all": "^4.1.5", | ||
"websocket": "^1.0.30", | ||
"ws": "^7.2.0" | ||
"websocket": "^1.0.32", | ||
"ws": "^7.3.1" | ||
}, | ||
@@ -62,0 +62,0 @@ "keywords": [ |
@@ -256,8 +256,10 @@ /** | ||
* | ||
* @param {number=} [code=1000] A numeric value indicating the status code. | ||
* @param {string=} [reason] A human-readable reason for closing connection. | ||
* @returns {Promise<Event>} | ||
*/ | ||
close() { | ||
close(code, reason) { // https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close | ||
return this.isClosed | ||
? Promise.resolve(this._closing.value) | ||
: this._closing.call(() => this._ws.close()); | ||
: this._closing.call(() => this._ws.close(code, reason)); | ||
} | ||
@@ -307,6 +309,6 @@ | ||
this._wsSubscription = new Channel.Subscription([ | ||
{channel: this._ws, event: 'open', listener: e => this._handleOpen(e)}, | ||
{channel: this._ws, event: 'message', listener: e => this._handleMessage(e)}, | ||
{channel: this._ws, event: 'error', listener: e => this._handleError(e)}, | ||
{channel: this._ws, event: 'close', listener: e => this._handleClose(e)}, | ||
{ channel: this._ws, event: 'open', listener: e => this._handleOpen(e) }, | ||
{ channel: this._ws, event: 'message', listener: e => this._handleMessage(e) }, | ||
{ channel: this._ws, event: 'error', listener: e => this._handleError(e) }, | ||
{ channel: this._ws, event: 'close', listener: e => this._handleClose(e) }, | ||
]).on(); | ||
@@ -382,3 +384,3 @@ } | ||
_assertPackingHandlers() { | ||
const {packMessage, unpackMessage} = this._options; | ||
const { packMessage, unpackMessage } = this._options; | ||
throwIf(!packMessage || !unpackMessage, | ||
@@ -390,3 +392,3 @@ `Please define 'options.packMessage / options.unpackMessage' for sending packed messages.` | ||
_assertRequestIdHandlers() { | ||
const {attachRequestId, extractRequestId} = this._options; | ||
const { attachRequestId, extractRequestId } = this._options; | ||
throwIf(!attachRequestId || !extractRequestId, | ||
@@ -393,0 +395,0 @@ `Please define 'options.attachRequestId / options.extractRequestId' for sending requests.` |
@@ -10,4 +10,5 @@ | ||
extractRequestId?: (data: any) => string | number | undefined; | ||
extractMessageData?: (event: any) => any; | ||
timeout?: number; | ||
connectionTimeout?: number; | ||
} |
35548
10
531
Updatedchnl@^1.2.0