Skip to content

Commit

Permalink
Merge pull request #6 from jaredwray/fix-for-typescript-to-see-multip…
Browse files Browse the repository at this point in the history
…le-args

fix for typescript to see multiple args
  • Loading branch information
jaredwray authored Sep 6, 2024
2 parents cc94ce7 + 1d6e71c commit c53728c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hookified",
"version": "0.7.0",
"version": "0.7.1",
"description": "Event and Middleware Hooks",
"type": "module",
"main": "./dist/index.js",
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ export class Hookified extends Emittery {
}

// Triggers all handlers for a specific event with provided data
async hook(event: string, ...data: any[]) {
async hook<T>(event: string, ...arguments_: T[]) {
const eventHandlers = this._hooks.get(event);
if (eventHandlers) {
for (const handler of eventHandlers) {
try {
// eslint-disable-next-line no-await-in-loop, @typescript-eslint/no-unsafe-argument
await handler(...data);
// eslint-disable-next-line no-await-in-loop
await handler(...arguments_);
} catch (error) {
// eslint-disable-next-line no-await-in-loop
await this.emit('error', new Error(`Error in hook handler for event "${event}": ${(error as Error).message}`));
Expand Down

0 comments on commit c53728c

Please sign in to comment.