diff --git a/modules/types.ts b/modules/types.ts index ec216fd..9b166cc 100644 --- a/modules/types.ts +++ b/modules/types.ts @@ -1,4 +1,4 @@ -export type EventName = string | symbol; +export type EventName = string | symbol | number; export type ConjoinEvents = [EventName, EventName, ...EventName[]]; diff --git a/tests/deno/multiple_events_test.ts b/tests/deno/multiple_events_test.ts index 866834d..b76c25a 100644 --- a/tests/deno/multiple_events_test.ts +++ b/tests/deno/multiple_events_test.ts @@ -23,6 +23,17 @@ describe("Xevt - multiple events", () => { assert(count === 2, `Expected 2, got ${count}`); }); + it("should listen numeric events", () => { + const emitter = new Xevt(); + let result = 0; + emitter.on([0, 1], () => { + result++; + }); + emitter.emit(0); + emitter.emit(1); + assert(result === 1, `Expected 1, got ${result}`); + }); + it("should listen multiple handlers", () => { const emitter = new Xevt(); const result: number[] = []; diff --git a/tests/deno/single_event_test.ts b/tests/deno/single_event_test.ts index c895460..ed2e353 100644 --- a/tests/deno/single_event_test.ts +++ b/tests/deno/single_event_test.ts @@ -20,6 +20,16 @@ describe("Xevt - single event", () => { assert(result === 1, `Expected 1, got ${result}`); }); + it("should listen numeric events", () => { + const emitter = new Xevt(); + let result = 0; + emitter.on(1, () => { + result++; + }); + emitter.emit(1); + assert(result === 1, `Expected 1, got ${result}`); + }); + it("should listen event multiple times", () => { const emitter = new Xevt();