Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function mitt<Events extends Record<EventType, unknown>>(
| WildcardHandler<Events>;
all = all || new Map();

return {
const instance = {
/**
* A Map of event names to registered handler functions.
*/
Expand All @@ -70,6 +70,9 @@ export default function mitt<Events extends Record<EventType, unknown>>(
} else {
all!.set(type, [handler] as EventHandlerList<Events[keyof Events]>);
}
return () => {
instance.off(type, handler);
};
},

/**
Expand Down Expand Up @@ -120,4 +123,5 @@ export default function mitt<Events extends Record<EventType, unknown>>(
}
}
};
return instance;
}