diff --git a/lib/index.ts b/lib/index.ts index 587dd540..636df237 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -245,7 +245,7 @@ export class Decoder extends Emitter { return typeof payload === "string" || typeof payload === "object"; case PacketType.EVENT: case PacketType.BINARY_EVENT: - return Array.isArray(payload) && typeof payload[0] === "string"; + return Array.isArray(payload) && payload.length > 0; case PacketType.ACK: case PacketType.BINARY_ACK: return Array.isArray(payload); diff --git a/test/parser.js b/test/parser.js index 0554d93b..426e77c5 100644 --- a/test/parser.js +++ b/test/parser.js @@ -47,6 +47,17 @@ describe("parser", () => { ); }); + it("encodes an event (with an integer as event name)", (done) => { + helpers.test( + { + type: PacketType.EVENT, + data: [1, "a", {}], + nsp: "/", + }, + done + ); + }); + it("encodes an event (with ack)", (done) => { helpers.test( {