{"id":51133696,"url":"https://github.com/trananhtung/typemit","last_synced_at":"2026-06-25T15:01:50.080Z","repository":{"id":366597516,"uuid":"1275960621","full_name":"trananhtung/typemit","owner":"trananhtung","description":"Tiny, fully type-safe event emitter with a wildcard listener and a promise-based waitFor. Zero dependencies.","archived":false,"fork":false,"pushed_at":"2026-06-22T15:00:33.000Z","size":48,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-22T15:05:08.574Z","etag":null,"topics":["abortsignal","emitter","event-emitter","events","mitt","pubsub","type-safe","typescript","waitfor","zero-dependency"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trananhtung.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-21T11:13:38.000Z","updated_at":"2026-06-22T15:02:11.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/trananhtung/typemit","commit_stats":null,"previous_names":["trananhtung/typemit"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/trananhtung/typemit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trananhtung%2Ftypemit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trananhtung%2Ftypemit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trananhtung%2Ftypemit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trananhtung%2Ftypemit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trananhtung","download_url":"https://codeload.github.com/trananhtung/typemit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trananhtung%2Ftypemit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34780126,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-25T02:00:05.521Z","response_time":101,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["abortsignal","emitter","event-emitter","events","mitt","pubsub","type-safe","typescript","waitfor","zero-dependency"],"created_at":"2026-06-25T15:01:49.191Z","updated_at":"2026-06-25T15:01:50.060Z","avatar_url":"https://github.com/trananhtung.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# typemit\n\n[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)\n\n\u003e Tiny, **fully type-safe** event emitter — with a wildcard listener and a promise-based **`waitFor`**. **Zero dependencies**.\n\n[![CI](https://github.com/trananhtung/typemit/actions/workflows/ci.yml/badge.svg)](https://github.com/trananhtung/typemit/actions/workflows/ci.yml)\n[![npm version](https://img.shields.io/npm/v/@billdaddy/typemit.svg)](https://www.npmjs.com/package/@billdaddy/typemit)\n[![bundle size](https://img.shields.io/bundlephobia/minzip/@billdaddy/typemit)](https://bundlephobia.com/package/@billdaddy/typemit)\n[![types](https://img.shields.io/npm/types/@billdaddy/typemit.svg)](https://www.npmjs.com/package/@billdaddy/typemit)\n[![license](https://img.shields.io/npm/l/@billdaddy/typemit.svg)](./LICENSE)\n\nMost event emitters take `(string, ...any[])` and hope for the best. `typemit`\ntakes an **event map**, so the event name is checked, the payload type is inferred,\nand a typo or wrong payload is a compile error — not a 2 a.m. bug.\n\n```ts\nimport { createEmitter } from \"@billdaddy/typemit\";\n\nconst bus = createEmitter\u003c{\n  login: { id: string };\n  message: string;\n  ready: void;\n}\u003e();\n\nbus.on(\"login\", (user) =\u003e console.log(user.id)); // user: { id: string }\nbus.emit(\"login\", { id: \"42\" });\nbus.emit(\"ready\");                                // void event — no payload\nbus.emit(\"login\", \"oops\");                        // ❌ compile error\n```\n\n## Why typemit?\n\n- **Type-safe end to end.** `on`/`once`/`emit`/`waitFor` are all checked against\n  your event map; `void` events take no payload.\n- **`waitFor` as a promise.** Await the next event — with an optional `filter` and\n  an `AbortSignal` to bail out. Great for tests and request/response flows.\n- **Wildcard listener.** `onAny((event, payload) =\u003e …)` for logging/debugging.\n- **Tidy lifecycle.** `on`/`once`/`onAny` return an unsubscribe; `clear()` and\n  `listenerCount()` for housekeeping. Handlers may unsubscribe themselves mid-emit.\n- **Zero dependencies**, ESM + CJS + types, ~1 kB.\n\n## Install\n\n```bash\nnpm install @billdaddy/typemit\n# or: pnpm add @billdaddy/typemit  /  yarn add @billdaddy/typemit  /  bun add @billdaddy/typemit\n```\n\n## API\n\n```ts\nconst bus = createEmitter\u003cEvents\u003e();\n```\n\n### Subscribe / emit\n\n```ts\nconst off = bus.on(\"message\", (text) =\u003e …);  // returns unsubscribe\nbus.once(\"ready\", () =\u003e …);                    // fires once\nbus.off(\"message\", handler);\nbus.emit(\"message\", \"hello\");\noff();\n```\n\n### `waitFor(event, { signal?, filter? }) → Promise\u003cpayload\u003e`\n\n```ts\nconst user = await bus.waitFor(\"login\");\nconst big = await bus.waitFor(\"message\", { filter: (m) =\u003e m.length \u003e 100 });\n\nconst ac = new AbortController();\nconst next = bus.waitFor(\"login\", { signal: ac.signal }); // rejects if aborted\n```\n\n### Wildcard \u0026 housekeeping\n\n```ts\nconst offAny = bus.onAny((event, payload) =\u003e log(event, payload));\nbus.listenerCount(\"message\"); // listeners for one event\nbus.listenerCount();          // all listeners, incl. wildcard\nbus.clear(\"message\");         // remove one event's listeners\nbus.clear();                  // remove everything\n```\n\n## Pairs well with\n\n- [`timefence`](https://www.npmjs.com/package/timefence) — race `waitFor` against a deadline.\n\n## Contributors ✨\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome — code, docs, bug reports, ideas, reviews! See the [emoji key](https://allcontributors.org/docs/en/emoji-key) for how each contribution is recognized, and open a PR or issue to get involved.\n\nThanks goes to these wonderful people:\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/trananhtung\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/30992229?v=4?s=100\" width=\"100px;\" alt=\"Tung Tran\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eTung Tran\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/trananhtung/typemit/commits?author=trananhtung\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"#maintenance-trananhtung\" title=\"Maintenance\"\u003e🚧\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\n## License\n\n[MIT](./LICENSE) © Tung Tran\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrananhtung%2Ftypemit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrananhtung%2Ftypemit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrananhtung%2Ftypemit/lists"}