Skip to content

Commit

Permalink
apply same prettier config
Browse files Browse the repository at this point in the history
  • Loading branch information
jokester committed Aug 12, 2024
1 parent 77e9d5f commit 5df244e
Show file tree
Hide file tree
Showing 43 changed files with 220 additions and 211 deletions.
3 changes: 3 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"trailingComma": "es5"
}
4 changes: 2 additions & 2 deletions packages/engine.io-client/lib/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,8 @@ export class SocketWithoutUpgrade extends Emitter<
(typeof location !== "undefined" && location.port
? location.port
: this.secure
? "443"
: "80");
? "443"
: "80");

this.transports = [];
this._transportsByName = {};
Expand Down
2 changes: 1 addition & 1 deletion packages/engine.io-parser/lib/decodePacket.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const withNativeArrayBuffer = typeof ArrayBuffer === "function";

export const decodePacket = (
encodedPacket: RawData,
binaryType?: BinaryType,
binaryType?: BinaryType
): Packet => {
if (typeof encodedPacket !== "string") {
return {
Expand Down
4 changes: 2 additions & 2 deletions packages/engine.io-parser/lib/decodePacket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {

export const decodePacket = (
encodedPacket: RawData,
binaryType?: BinaryType,
binaryType?: BinaryType
): Packet => {
if (typeof encodedPacket !== "string") {
return {
Expand Down Expand Up @@ -47,7 +47,7 @@ const mapBinary = (data: RawData, binaryType?: BinaryType) => {
// from HTTP long-polling
return data.buffer.slice(
data.byteOffset,
data.byteOffset + data.byteLength,
data.byteOffset + data.byteLength
);
} else {
// from WebTransport (Uint8Array)
Expand Down
6 changes: 3 additions & 3 deletions packages/engine.io-parser/lib/encodePacket.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const isView = (obj) => {
const encodePacket = (
{ type, data }: Packet,
supportsBinary: boolean,
callback: (encodedPacket: RawData) => void,
callback: (encodedPacket: RawData) => void
) => {
if (withNativeBlob && data instanceof Blob) {
if (supportsBinary) {
Expand All @@ -40,7 +40,7 @@ const encodePacket = (

const encodeBlobAsBase64 = (
data: Blob,
callback: (encodedPacket: RawData) => void,
callback: (encodedPacket: RawData) => void
) => {
const fileReader = new FileReader();
fileReader.onload = function () {
Expand All @@ -64,7 +64,7 @@ let TEXT_ENCODER;

export function encodePacketToBinary(
packet: Packet,
callback: (encodedPacket: RawData) => void,
callback: (encodedPacket: RawData) => void
) {
if (withNativeBlob && packet.data instanceof Blob) {
return packet.data.arrayBuffer().then(toArray).then(callback);
Expand Down
6 changes: 3 additions & 3 deletions packages/engine.io-parser/lib/encodePacket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { PACKET_TYPES, Packet, RawData } from "./commons.js";
export const encodePacket = (
{ type, data }: Packet,
supportsBinary: boolean,
callback: (encodedPacket: RawData) => void,
callback: (encodedPacket: RawData) => void
) => {
if (data instanceof ArrayBuffer || ArrayBuffer.isView(data)) {
return callback(
supportsBinary ? data : "b" + toBuffer(data, true).toString("base64"),
supportsBinary ? data : "b" + toBuffer(data, true).toString("base64")
);
}
// plain string
Expand All @@ -31,7 +31,7 @@ let TEXT_ENCODER;

export function encodePacketToBinary(
packet: Packet,
callback: (encodedPacket: RawData) => void,
callback: (encodedPacket: RawData) => void
) {
if (packet.data instanceof ArrayBuffer || ArrayBuffer.isView(packet.data)) {
return callback(toBuffer(packet.data, false));
Expand Down
14 changes: 7 additions & 7 deletions packages/engine.io-parser/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const SEPARATOR = String.fromCharCode(30); // see https://en.wikipedia.org/wiki/

const encodePayload = (
packets: Packet[],
callback: (encodedPayload: string) => void,
callback: (encodedPayload: string) => void
) => {
// some packets may be added to the array while encoding, so the initial length must be saved
const length = packets.length;
Expand All @@ -32,7 +32,7 @@ const encodePayload = (

const decodePayload = (
encodedPayload: string,
binaryType?: BinaryType,
binaryType?: BinaryType
): Packet[] => {
const encodedPackets = encodedPayload.split(SEPARATOR);
const packets = [];
Expand Down Expand Up @@ -112,7 +112,7 @@ const enum State {

export function createPacketDecoderStream(
maxPayload: number,
binaryType: BinaryType,
binaryType: BinaryType
): any {
if (!TEXT_DECODER) {
TEXT_DECODER = new TextDecoder();
Expand Down Expand Up @@ -148,7 +148,7 @@ export function createPacketDecoderStream(
expectedLength = new DataView(
headerArray.buffer,
headerArray.byteOffset,
headerArray.length,
headerArray.length
).getUint16(0);
state = State.READ_PAYLOAD;
} else if (state === State.READ_EXTENDED_LENGTH_64) {
Expand All @@ -160,7 +160,7 @@ export function createPacketDecoderStream(
const view = new DataView(
headerArray.buffer,
headerArray.byteOffset,
headerArray.length,
headerArray.length
);

const n = view.getUint32(0);
Expand All @@ -181,8 +181,8 @@ export function createPacketDecoderStream(
controller.enqueue(
decodePacket(
isBinary ? data : TEXT_DECODER.decode(data),
binaryType,
),
binaryType
)
);
state = State.READ_HEADER;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/engine.io-parser/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ describe("engine.io-parser", () => {

const header = await reader.read();
expect(header.value).to.eql(
Uint8Array.of(255, 0, 0, 0, 0, 7, 91, 205, 21),
Uint8Array.of(255, 0, 0, 0, 0, 7, 91, 205, 21)
);

const payload = await reader.read();
Expand Down
5 changes: 4 additions & 1 deletion packages/engine.io/lib/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,10 @@ export abstract class BaseServer extends EventEmitter {
* @see https://nodejs.org/api/http.html#class-httpserverresponse
*/
class WebSocketResponse {
constructor(readonly req, readonly socket: Duplex) {
constructor(
readonly req,
readonly socket: Duplex
) {
// temporarily store the response headers on the req object (see the "headers" event)
req[kResponseHeaders] = {};
}
Expand Down
6 changes: 5 additions & 1 deletion packages/engine.io/lib/transports/webtransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ const debug = debugModule("engine:webtransport");
export class WebTransport extends Transport {
private readonly writer;

constructor(private readonly session, stream, reader) {
constructor(
private readonly session,
stream,
reader
) {
super({ _query: { EIO: "4" } });

const transformStream = createPacketEncoderStream();
Expand Down
5 changes: 4 additions & 1 deletion packages/socket.io-adapter/test/cluster-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ const NODES_COUNT = 3;
class EventEmitterAdapter extends ClusterAdapterWithHeartbeat {
private offset = 1;

constructor(nsp, readonly eventBus) {
constructor(
nsp,
readonly eventBus
) {
super(nsp, {});
this.eventBus.on("message", (message) => {
this.onMessage(message as ClusterMessage);
Expand Down
4 changes: 2 additions & 2 deletions packages/socket.io-client/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ const cache: Record<string, Manager> = {};
function lookup(opts?: Partial<ManagerOptions & SocketOptions>): Socket;
function lookup(
uri: string,
opts?: Partial<ManagerOptions & SocketOptions>,
opts?: Partial<ManagerOptions & SocketOptions>
): Socket;
function lookup(
uri?: string | Partial<ManagerOptions & SocketOptions>,
opts?: Partial<ManagerOptions & SocketOptions>,
opts?: Partial<ManagerOptions & SocketOptions>
): Socket {
if (typeof uri === "object") {
opts = uri;
Expand Down
6 changes: 3 additions & 3 deletions packages/socket.io-client/lib/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ export class Manager<
constructor(uri?: string, opts?: Partial<ManagerOptions>);
constructor(
uri?: string | Partial<ManagerOptions>,
opts?: Partial<ManagerOptions>,
opts?: Partial<ManagerOptions>
);
constructor(
uri?: string | Partial<ManagerOptions>,
opts?: Partial<ManagerOptions>,
opts?: Partial<ManagerOptions>
) {
super();
if (uri && "object" === typeof uri) {
Expand Down Expand Up @@ -405,7 +405,7 @@ export class Manager<
on(socket, "error", this.onerror.bind(this)),
on(socket, "close", this.onclose.bind(this)),
// @ts-ignore
on(this.decoder, "decoded", this.ondecoded.bind(this)),
on(this.decoder, "decoded", this.ondecoded.bind(this))
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/socket.io-client/lib/on.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Emitter } from "@socket.io/component-emitter";
export function on(
obj: Emitter<any, any>,
ev: string,
fn: (err?: any) => any,
fn: (err?: any) => any
): VoidFunction {
obj.on(ev, fn);
return function subDestroy(): void {
Expand Down
16 changes: 8 additions & 8 deletions packages/socket.io-client/lib/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ interface SocketReservedEvents {
connect_error: (err: Error) => void;
disconnect: (
reason: Socket.DisconnectReason,
description?: DisconnectDescription,
description?: DisconnectDescription
) => void;
}

Expand Down Expand Up @@ -554,7 +554,7 @@ export class Socket<
debug(
"packet [%d] is discarded after %d tries",
packet.id,
packet.tryCount,
packet.tryCount
);
this._queue.shift();
if (ack) {
Expand Down Expand Up @@ -591,7 +591,7 @@ export class Socket<
if (packet.pending && !force) {
debug(
"packet [%d] has already been sent and is waiting for an ack",
packet.id,
packet.id
);
return;
}
Expand Down Expand Up @@ -665,7 +665,7 @@ export class Socket<
*/
private onclose(
reason: Socket.DisconnectReason,
description?: DisconnectDescription,
description?: DisconnectDescription
): void {
debug("close (%s)", reason);
this.connected = false;
Expand All @@ -683,7 +683,7 @@ export class Socket<
private _clearAcks() {
Object.keys(this.acks).forEach((id) => {
const isBuffered = this.sendBuffer.some(
(packet) => String(packet.id) === id,
(packet) => String(packet.id) === id
);
if (!isBuffered) {
// note: handlers that do not accept an error as first argument are ignored here
Expand Down Expand Up @@ -716,8 +716,8 @@ export class Socket<
this.emitReserved(
"connect_error",
new Error(
"It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)",
),
"It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"
)
);
}
break;
Expand Down Expand Up @@ -967,7 +967,7 @@ export class Socket<
* @returns self
*/
public timeout(
timeout: number,
timeout: number
): Socket<ListenEvents, DecorateAcknowledgements<EmitEvents>> {
this.flags.timeout = timeout;
return this;
Expand Down
2 changes: 1 addition & 1 deletion packages/socket.io-client/lib/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type ParsedUrl = {
export function url(
uri: string | ParsedUrl,
path: string = "",
loc?: Location,
loc?: Location
): ParsedUrl {
let obj = uri as ParsedUrl;

Expand Down
2 changes: 1 addition & 1 deletion packages/socket.io-client/test/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ describe("connection", () => {
reconnectionAttempts: 2,
});
let delay = Math.floor(
manager.reconnectionDelay() * manager.randomizationFactor() * 0.5,
manager.reconnectionDelay() * manager.randomizationFactor() * 0.5
);
delay = Math.max(delay, 10);

Expand Down
2 changes: 1 addition & 1 deletion packages/socket.io-client/test/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ describe("socket", () => {
const socket = io(BASE_URL + "/no", { forceNew: true });

expect(() => socket.emit("disconnecting", "goodbye")).to.throwException(
/"disconnecting" is a reserved event name/,
/"disconnecting" is a reserved event name/
);
});

Expand Down
8 changes: 4 additions & 4 deletions packages/socket.io-client/test/typed-events.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe("typed events", () => {
const value = await socket.emitWithAck(
"ackFromClientSingleArg",
"1",
2,
2
);
expectType<any>(value);

Expand Down Expand Up @@ -155,12 +155,12 @@ describe("typed events", () => {
ackFromClient: (
a: string,
b: number,
ack: (c: string, d: boolean) => void,
ack: (c: string, d: boolean) => void
) => void;
ackFromClientSingleArg: (
a: string,
b: number,
ack: (c: string) => void,
ack: (c: string) => void
) => void;
ackFromClientNoArg: (ack: () => void) => void;
}
Expand Down Expand Up @@ -232,7 +232,7 @@ describe("typed events", () => {
const value = await socket.emitWithAck(
"ackFromClientSingleArg",
"1",
2,
2
);
expectType<string>(value);

Expand Down
4 changes: 2 additions & 2 deletions packages/socket.io-client/wdio.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ if (process.env.CI === "true") {
{
appiumVersion: "2.0.0",
},
BASE_SAUCE_OPTIONS,
BASE_SAUCE_OPTIONS
),
},
{
Expand All @@ -92,7 +92,7 @@ if (process.env.CI === "true") {
{
appiumVersion: "2.0.0",
},
BASE_SAUCE_OPTIONS,
BASE_SAUCE_OPTIONS
),
},
];
Expand Down
5 changes: 4 additions & 1 deletion packages/socket.io-cluster-engine/test/in-memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import { type ServerOptions } from "engine.io";
import { url, handshake } from "./util";

class InMemoryEngine extends ClusterEngine {
constructor(readonly eventBus: EventEmitter, opts?: ServerOptions) {
constructor(
readonly eventBus: EventEmitter,
opts?: ServerOptions
) {
super(opts);
eventBus.on("message", (message) => this.onMessage(message));
}
Expand Down
Loading

0 comments on commit 5df244e

Please sign in to comment.