{"id":15643082,"url":"https://github.com/azu/eventmit","last_synced_at":"2025-04-05T06:08:01.315Z","repository":{"id":40360444,"uuid":"267898220","full_name":"azu/eventmit","owner":"azu","description":"Simple EventEmitter. A single event object per an event.","archived":false,"fork":false,"pushed_at":"2025-01-12T00:21:18.000Z","size":261,"stargazers_count":61,"open_issues_count":2,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-29T05:07:42.941Z","etag":null,"topics":["browser","eventemitter","events","nodejs","pubsub"],"latest_commit_sha":null,"homepage":"","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/azu.png","metadata":{"funding":{"github":"azu"},"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2020-05-29T15:57:57.000Z","updated_at":"2025-03-07T09:41:45.000Z","dependencies_parsed_at":"2025-01-28T15:39:08.835Z","dependency_job_id":"030427a0-738e-443d-9d71-88cbeb70bac7","html_url":"https://github.com/azu/eventmit","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azu%2Feventmit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azu%2Feventmit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azu%2Feventmit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azu%2Feventmit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/azu","download_url":"https://codeload.github.com/azu/eventmit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247294539,"owners_count":20915340,"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":["browser","eventemitter","events","nodejs","pubsub"],"created_at":"2024-10-03T11:58:55.138Z","updated_at":"2025-04-05T06:08:01.299Z","avatar_url":"https://github.com/azu.png","language":"TypeScript","funding_links":["https://github.com/sponsors/azu"],"categories":[],"sub_categories":[],"readme":"# eventmit [![Actions Status](https://github.com/azu/eventmit/workflows/test/badge.svg)](https://github.com/azu/eventmit/actions?query=workflow%3A\"test\")\n\nA single event object per an event.\n\n## Feature\n\n- A single event object per an event\n- Tiny code base - less 1kb\n- Written by TypeScript\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n    npm install eventmit\n\nRequirement: ECMAScript 2015 because this library use [`Set`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set).\n\n## Usage\n\nCreate an eventmit object and register handler and invoke handlers.\n\n```ts\nimport { eventmit } from \"eventmit\";\nconst event = eventmit\u003c{ key: string }\u003e();\n// Register handler\nevent.on((value) =\u003e {\n    console.log(1, value);\n});\nevent.on((value) =\u003e {\n    console.log(2, value);\n});\n// Invoke handler\nevent.emit({\n    key: \"value\"\n});\n// Unregister handler\nevent.offAll();\n```\n\n## API\n\n```ts\nexport declare type EventmitHandler\u003cT\u003e = (value: T) =\u003e any;\nexport declare type Eventmitter\u003cT\u003e = {\n    /**\n     * Register an event handler\n     */\n    on: (handler: EventmitHandler\u003cT\u003e) =\u003e void;\n    /**\n     * Remove an event handler\n     */\n    off: (handler: EventmitHandler\u003cT\u003e) =\u003e void;\n    /**\n     * Remove all event handlers\n     */\n    offAll: () =\u003e void;\n    /**\n     * Invoke all handlers\n     */\n    emit: (value: T) =\u003e void;\n};\nexport declare const eventmit: \u003cT\u003e() =\u003e Eventmitter\u003cT\u003e;\n```\n\n## ECMAScript Modules\n\nYou can import `eventmit` as ES Modules.\n\n```js\nimport { eventmit } from \"https://unpkg.com/eventmit?module\";\nconst event = eventmit();\n// Register handler\nevent.on((value) =\u003e {\n    console.log(value);\n});\n// Invoke handler\nevent.emit(\"value\");\n```\n\nIt means that eventmit work on Browser and [Deno](https://deno.land/).\n\n### Import at Deno\nIf you are using Deno, import `eventmit` from a URL.  \nFor example, using a CDN:\n\n```typescript\nimport { eventmit } from \"https://cdn.skypack.dev/eventmit?dts\";\n```\n\n## Changelog\n\nSee [Releases page](https://github.com/azu/eventmit/releases).\n\n## Running tests\n\nInstall devDependencies and Run `npm test`:\n\n    npm test\n\n## Contributing\n\nPull requests and stars are always welcome.\n\nFor bugs and feature requests, [please create an issue](https://github.com/azu/eventmit/issues).\n\n1. Fork it!\n2. Create your feature branch: `git checkout -b my-new-feature`\n3. Commit your changes: `git commit -am 'Add some feature'`\n4. Push to the branch: `git push origin my-new-feature`\n5. Submit a pull request :D\n\n## Author\n\n- [github/azu](https://github.com/azu)\n- [twitter/azu_re](https://twitter.com/azu_re)\n\n## License\n\nMIT © azu\n\n## Related\n\n- [developit/mitt: 🥊 Tiny 200 byte functional event emitter / pubsub.](https://github.com/developit/mitt)\n    - Support multiple event type\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazu%2Feventmit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fazu%2Feventmit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazu%2Feventmit/lists"}