From e73aa401511ed3db91b8c7613aa11eefb2fd2fa6 Mon Sep 17 00:00:00 2001 From: ZyLacx Date: Mon, 27 Dec 2021 17:15:57 +0100 Subject: [PATCH] Update sender.js --- node_modules/ws/lib/sender.js | 85 +++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 34 deletions(-) diff --git a/node_modules/ws/lib/sender.js b/node_modules/ws/lib/sender.js index 3ea2fc1..441171c 100644 --- a/node_modules/ws/lib/sender.js +++ b/node_modules/ws/lib/sender.js @@ -1,5 +1,9 @@ +/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^net|tls$" }] */ + 'use strict'; +const net = require('net'); +const tls = require('tls'); const { randomFillSync } = require('crypto'); const PerMessageDeflate = require('./permessage-deflate'); @@ -16,8 +20,8 @@ class Sender { /** * Creates a Sender instance. * - * @param {net.Socket} socket The connection socket - * @param {Object} extensions An object containing the negotiated extensions + * @param {(net.Socket|tls.Socket)} socket The connection socket + * @param {Object} [extensions] An object containing the negotiated extensions */ constructor(socket, extensions) { this._extensions = extensions || {}; @@ -37,10 +41,14 @@ class Sender { * @param {Buffer} data The data to frame * @param {Object} options Options object * @param {Number} options.opcode The opcode - * @param {Boolean} options.readOnly Specifies whether `data` can be modified - * @param {Boolean} options.fin Specifies whether or not to set the FIN bit - * @param {Boolean} options.mask Specifies whether or not to mask `data` - * @param {Boolean} options.rsv1 Specifies whether or not to set the RSV1 bit + * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be + * modified + * @param {Boolean} [options.fin=false] Specifies whether or not to set the + * FIN bit + * @param {Boolean} [options.mask=false] Specifies whether or not to mask + * `data` + * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the + * RSV1 bit * @return {Buffer[]} The framed data as a list of `Buffer` instances * @public */ @@ -93,10 +101,10 @@ class Sender { /** * Sends a close message to the other peer. * - * @param {(Number|undefined)} code The status code component of the body - * @param {String} data The message component of the body - * @param {Boolean} mask Specifies whether or not to mask the message - * @param {Function} cb Callback + * @param {Number} [code] The status code component of the body + * @param {String} [data] The message component of the body + * @param {Boolean} [mask=false] Specifies whether or not to mask the message + * @param {Function} [cb] Callback * @public */ close(code, data, mask, cb) { @@ -132,8 +140,8 @@ class Sender { * Frames and sends a close message. * * @param {Buffer} data The message to send - * @param {Boolean} mask Specifies whether or not to mask `data` - * @param {Function} cb Callback + * @param {Boolean} [mask=false] Specifies whether or not to mask `data` + * @param {Function} [cb] Callback * @private */ doClose(data, mask, cb) { @@ -153,8 +161,8 @@ class Sender { * Sends a ping message to the other peer. * * @param {*} data The message to send - * @param {Boolean} mask Specifies whether or not to mask `data` - * @param {Function} cb Callback + * @param {Boolean} [mask=false] Specifies whether or not to mask `data` + * @param {Function} [cb] Callback * @public */ ping(data, mask, cb) { @@ -175,9 +183,9 @@ class Sender { * Frames and sends a ping message. * * @param {Buffer} data The message to send - * @param {Boolean} mask Specifies whether or not to mask `data` - * @param {Boolean} readOnly Specifies whether `data` can be modified - * @param {Function} cb Callback + * @param {Boolean} [mask=false] Specifies whether or not to mask `data` + * @param {Boolean} [readOnly=false] Specifies whether `data` can be modified + * @param {Function} [cb] Callback * @private */ doPing(data, mask, readOnly, cb) { @@ -197,8 +205,8 @@ class Sender { * Sends a pong message to the other peer. * * @param {*} data The message to send - * @param {Boolean} mask Specifies whether or not to mask `data` - * @param {Function} cb Callback + * @param {Boolean} [mask=false] Specifies whether or not to mask `data` + * @param {Function} [cb] Callback * @public */ pong(data, mask, cb) { @@ -219,9 +227,9 @@ class Sender { * Frames and sends a pong message. * * @param {Buffer} data The message to send - * @param {Boolean} mask Specifies whether or not to mask `data` - * @param {Boolean} readOnly Specifies whether `data` can be modified - * @param {Function} cb Callback + * @param {Boolean} [mask=false] Specifies whether or not to mask `data` + * @param {Boolean} [readOnly=false] Specifies whether `data` can be modified + * @param {Function} [cb] Callback * @private */ doPong(data, mask, readOnly, cb) { @@ -242,11 +250,15 @@ class Sender { * * @param {*} data The message to send * @param {Object} options Options object - * @param {Boolean} options.compress Specifies whether or not to compress `data` - * @param {Boolean} options.binary Specifies whether `data` is binary or text - * @param {Boolean} options.fin Specifies whether the fragment is the last one - * @param {Boolean} options.mask Specifies whether or not to mask `data` - * @param {Function} cb Callback + * @param {Boolean} [options.compress=false] Specifies whether or not to + * compress `data` + * @param {Boolean} [options.binary=false] Specifies whether `data` is binary + * or text + * @param {Boolean} [options.fin=false] Specifies whether the fragment is the + * last one + * @param {Boolean} [options.mask=false] Specifies whether or not to mask + * `data` + * @param {Function} [cb] Callback * @public */ send(data, options, cb) { @@ -300,14 +312,19 @@ class Sender { * Dispatches a data message. * * @param {Buffer} data The message to send - * @param {Boolean} compress Specifies whether or not to compress `data` + * @param {Boolean} [compress=false] Specifies whether or not to compress + * `data` * @param {Object} options Options object * @param {Number} options.opcode The opcode - * @param {Boolean} options.readOnly Specifies whether `data` can be modified - * @param {Boolean} options.fin Specifies whether or not to set the FIN bit - * @param {Boolean} options.mask Specifies whether or not to mask `data` - * @param {Boolean} options.rsv1 Specifies whether or not to set the RSV1 bit - * @param {Function} cb Callback + * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be + * modified + * @param {Boolean} [options.fin=false] Specifies whether or not to set the + * FIN bit + * @param {Boolean} [options.mask=false] Specifies whether or not to mask + * `data` + * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the + * RSV1 bit + * @param {Function} [cb] Callback * @private */ dispatch(data, compress, options, cb) { @@ -374,7 +391,7 @@ class Sender { * Sends a frame. * * @param {Buffer[]} list The frame to send - * @param {Function} cb Callback + * @param {Function} [cb] Callback * @private */ sendFrame(list, cb) {