{"id":24125641,"url":"https://github.com/denosaurs/event","last_synced_at":"2025-09-18T16:30:46.708Z","repository":{"id":41059746,"uuid":"294529823","full_name":"denosaurs/event","owner":"denosaurs","description":"📆 Strictly typed event emitter with asynciterator support","archived":false,"fork":false,"pushed_at":"2024-03-03T20:43:43.000Z","size":53,"stargazers_count":40,"open_issues_count":2,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-04-14T00:49:18.400Z","etag":null,"topics":["asynciterator","deno","event-emitter","events","hacktoberfest","typed"],"latest_commit_sha":null,"homepage":"https://deno.land/x/event","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/denosaurs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"open_collective":"denosaurs","github":"denosaurs"}},"created_at":"2020-09-10T21:48:00.000Z","updated_at":"2024-03-04T14:45:26.000Z","dependencies_parsed_at":"2022-07-16T05:30:33.857Z","dependency_job_id":"8346ca3f-30ac-47e8-9ebf-28fc31bf092f","html_url":"https://github.com/denosaurs/event","commit_stats":{"total_commits":32,"total_committers":5,"mean_commits":6.4,"dds":0.28125,"last_synced_commit":"45f4b0b550cb6b5014efbb7dc0240b71da6ced5c"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denosaurs%2Fevent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denosaurs%2Fevent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denosaurs%2Fevent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denosaurs%2Fevent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/denosaurs","download_url":"https://codeload.github.com/denosaurs/event/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232659194,"owners_count":18557024,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["asynciterator","deno","event-emitter","events","hacktoberfest","typed"],"created_at":"2025-01-11T15:25:49.624Z","updated_at":"2025-09-18T16:30:41.177Z","avatar_url":"https://github.com/denosaurs.png","language":"TypeScript","funding_links":["https://opencollective.com/denosaurs","https://github.com/sponsors/denosaurs"],"categories":[],"sub_categories":[],"readme":"# event\n\n[![Tags](https://img.shields.io/github/release/denosaurs/event)](https://github.com/denosaurs/event/releases)\n[![CI Status](https://img.shields.io/github/workflow/status/denosaurs/event/check)](https://github.com/denosaurs/event/actions)\n[![Dependencies](https://img.shields.io/github/workflow/status/denosaurs/event/depsbot?label=dependencies)](https://github.com/denosaurs/depsbot)\n[![License](https://img.shields.io/github/license/denosaurs/event)](https://github.com/denosaurs/event/blob/master/LICENSE)\n\nStrictly typed event emitter with asynciterator support.\n\nEvents should be defined as a literal object type where the key is the event\nname, and the value is a tuple with any amount of elements of any type.\n\nThe constructor takes an optional argument which defines the maximum amount of\nlisteners per event, which defaults to 10. If this limit is surpassed, an error\nis thrown.\n\n---\n\n\u003e ⚠️ Events must be a type, and can't be an interface due to their design\n\u003e differences.\n\n---\n\n```ts\ntype Events = {\n  foo: [string];\n  bar: [number, boolean];\n};\n\nclass MyClass extends EventEmitter\u003cEvents\u003e {}\nconst MyClassInstance = new MyClass();\n\nfunction listener(num, bool) {}\n\n// add a listener to the bar event\nMyClassInstance.on(\"bar\", listener);\n\n// remove a listener from the bar event\nMyClassInstance.off(\"bar\", listener);\n\n// remove all listeners from the bar event\nMyClassInstance.off(\"bar\");\n\n// remove all listeners from the event emitter\nMyClassInstance.off();\n\n// add a one-time listener to the bar event\nMyClassInstance.once(\"bar\", listener);\n\n// on, once, and off are chainable\nMyClassInstance.on(\"bar\", listener).off(\"bar\", listener);\n\n// emit the bar event with the wanted data\nMyClassInstance.emit(\"bar\", 42, true);\n\n// listen to all events with an async iterator\nfor await (const event of MyClassInstance) {\n  if (event.name === \"bar\") {\n    // event.value is of type [number, boolean]\n  }\n}\n\n// listen to a specific event with an async iterator\nfor await (const [num, bool] of MyClassInstance.on(\"bar\")) {\n}\n\n// removes all listeners and closes async iterators\nMyClassInstance.close(\"bar\");\n```\n\n## Maintainers\n\n- crowlKats ([@crowlKats](https://github.com/crowlKats))\n\n## Other\n\n### Contribution\n\nPull request, issues and feedback are very welcome. Code style is formatted with\n`deno fmt` and commit messages are done following Conventional Commits spec.\n\n### Licence\n\nCopyright 2020-present, the denosaurs team. All rights reserved. MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenosaurs%2Fevent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdenosaurs%2Fevent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenosaurs%2Fevent/lists"}