Reinstalled with --fix
Some checks failed
Lint / pre-commit Linting (push) Failing after 51s

This commit is contained in:
2023-11-26 16:51:02 +01:00
parent ae8a515ded
commit 67796af83c
671 changed files with 158468 additions and 19041 deletions

78
node_modules/ws/lib/event-target.js generated vendored
View File

@@ -10,10 +10,9 @@ class Event {
* Create a new `Event`.
*
* @param {String} type The name of the event
* @param {Object} target A reference to the target to which the event was
* dispatched
* @param {Object} target A reference to the target to which the event was dispatched
*/
constructor(type, target) {
constructor (type, target) {
this.target = target;
this.type = type;
}
@@ -30,10 +29,9 @@ class MessageEvent extends Event {
* Create a new `MessageEvent`.
*
* @param {(String|Buffer|ArrayBuffer|Buffer[])} data The received data
* @param {WebSocket} target A reference to the target to which the event was
* dispatched
* @param {WebSocket} target A reference to the target to which the event was dispatched
*/
constructor(data, target) {
constructor (data, target) {
super('message', target);
this.data = data;
@@ -50,14 +48,11 @@ class CloseEvent extends Event {
/**
* Create a new `CloseEvent`.
*
* @param {Number} code The status code explaining why the connection is being
* closed
* @param {String} reason A human-readable string explaining why the
* connection is closing
* @param {WebSocket} target A reference to the target to which the event was
* dispatched
* @param {Number} code The status code explaining why the connection is being closed
* @param {String} reason A human-readable string explaining why the connection is closing
* @param {WebSocket} target A reference to the target to which the event was dispatched
*/
constructor(code, reason, target) {
constructor (code, reason, target) {
super('close', target);
this.wasClean = target._closeFrameReceived && target._closeFrameSent;
@@ -76,10 +71,9 @@ class OpenEvent extends Event {
/**
* Create a new `OpenEvent`.
*
* @param {WebSocket} target A reference to the target to which the event was
* dispatched
* @param {WebSocket} target A reference to the target to which the event was dispatched
*/
constructor(target) {
constructor (target) {
super('open', target);
}
}
@@ -95,10 +89,9 @@ class ErrorEvent extends Event {
* Create a new `ErrorEvent`.
*
* @param {Object} error The error that generated this event
* @param {WebSocket} target A reference to the target to which the event was
* dispatched
* @param {WebSocket} target A reference to the target to which the event was dispatched
*/
constructor(error, target) {
constructor (error, target) {
super('error', target);
this.message = error.message;
@@ -116,66 +109,59 @@ const EventTarget = {
/**
* Register an event listener.
*
* @param {String} type A string representing the event type to listen for
* @param {String} method A string representing the event type to listen for
* @param {Function} listener The listener to add
* @param {Object} [options] An options object specifies characteristics about
* the event listener
* @param {Boolean} [options.once=false] A `Boolean`` indicating that the
* listener should be invoked at most once after being added. If `true`,
* the listener would be automatically removed when invoked.
* @public
*/
addEventListener(type, listener, options) {
addEventListener (method, listener) {
if (typeof listener !== 'function') return;
function onMessage(data) {
function onMessage (data) {
listener.call(this, new MessageEvent(data, this));
}
function onClose(code, message) {
function onClose (code, message) {
listener.call(this, new CloseEvent(code, message, this));
}
function onError(error) {
function onError (error) {
listener.call(this, new ErrorEvent(error, this));
}
function onOpen() {
function onOpen () {
listener.call(this, new OpenEvent(this));
}
const method = options && options.once ? 'once' : 'on';
if (type === 'message') {
if (method === 'message') {
onMessage._listener = listener;
this[method](type, onMessage);
} else if (type === 'close') {
this.on(method, onMessage);
} else if (method === 'close') {
onClose._listener = listener;
this[method](type, onClose);
} else if (type === 'error') {
this.on(method, onClose);
} else if (method === 'error') {
onError._listener = listener;
this[method](type, onError);
} else if (type === 'open') {
this.on(method, onError);
} else if (method === 'open') {
onOpen._listener = listener;
this[method](type, onOpen);
this.on(method, onOpen);
} else {
this[method](type, listener);
this.on(method, listener);
}
},
/**
* Remove an event listener.
*
* @param {String} type A string representing the event type to remove
* @param {String} method A string representing the event type to remove
* @param {Function} listener The listener to remove
* @public
*/
removeEventListener(type, listener) {
const listeners = this.listeners(type);
removeEventListener (method, listener) {
const listeners = this.listeners(method);
for (let i = 0; i < listeners.length; i++) {
for (var i = 0; i < listeners.length; i++) {
if (listeners[i] === listener || listeners[i]._listener === listener) {
this.removeListener(type, listeners[i]);
this.removeListener(method, listeners[i]);
}
}
}