1
0
mirror of https://github.com/S2-/minifyfromhtml.git synced 2025-08-03 04:10:04 +02:00

update packages to latest version

This commit is contained in:
s2
2022-08-20 18:51:33 +02:00
parent 09663a35a5
commit 806ebf9a57
4513 changed files with 366205 additions and 92512 deletions

42
node_modules/ws/lib/stream.js generated vendored
View File

@@ -5,7 +5,7 @@ const { Duplex } = require('stream');
/**
* Emits the `'close'` event on a stream.
*
* @param {stream.Duplex} The stream.
* @param {Duplex} stream The stream.
* @private
*/
function emitClose(stream) {
@@ -43,27 +43,12 @@ function duplexOnError(err) {
*
* @param {WebSocket} ws The `WebSocket` to wrap
* @param {Object} [options] The options for the `Duplex` constructor
* @return {stream.Duplex} The duplex stream
* @return {Duplex} The duplex stream
* @public
*/
function createWebSocketStream(ws, options) {
let resumeOnReceiverDrain = true;
let terminateOnDestroy = true;
function receiverOnDrain() {
if (resumeOnReceiverDrain) ws._socket.resume();
}
if (ws.readyState === ws.CONNECTING) {
ws.once('open', function open() {
ws._receiver.removeAllListeners('drain');
ws._receiver.on('drain', receiverOnDrain);
});
} else {
ws._receiver.removeAllListeners('drain');
ws._receiver.on('drain', receiverOnDrain);
}
const duplex = new Duplex({
...options,
autoDestroy: false,
@@ -72,11 +57,11 @@ function createWebSocketStream(ws, options) {
writableObjectMode: false
});
ws.on('message', function message(msg) {
if (!duplex.push(msg)) {
resumeOnReceiverDrain = false;
ws._socket.pause();
}
ws.on('message', function message(msg, isBinary) {
const data =
!isBinary && duplex._readableState.objectMode ? msg.toString() : msg;
if (!duplex.push(data)) ws.pause();
});
ws.once('error', function error(err) {
@@ -84,13 +69,13 @@ function createWebSocketStream(ws, options) {
// Prevent `ws.terminate()` from being called by `duplex._destroy()`.
//
// - If the state of the `WebSocket` connection is `CONNECTING`,
// `ws.terminate()` is a noop as no socket was assigned.
// - Otherwise, the error was re-emitted from the listener of the `'error'`
// - If the `'error'` event is emitted before the `'open'` event, then
// `ws.terminate()` is a noop as no socket is assigned.
// - Otherwise, the error is re-emitted by the listener of the `'error'`
// event of the `Receiver` object. The listener already closes the
// connection by calling `ws.close()`. This allows a close frame to be
// sent to the other peer. If `ws.terminate()` is called right after this,
// the close frame might not be sent.
// then the close frame might not be sent.
terminateOnDestroy = false;
duplex.destroy(err);
});
@@ -152,10 +137,7 @@ function createWebSocketStream(ws, options) {
};
duplex._read = function () {
if (ws.readyState === ws.OPEN && !resumeOnReceiverDrain) {
resumeOnReceiverDrain = true;
if (!ws._receiver._writableState.needDrain) ws._socket.resume();
}
if (ws.isPaused) ws.resume();
};
duplex._write = function (chunk, encoding, callback) {