{"id":40910695,"url":"https://github.com/parfeon/event-emitter","last_synced_at":"2026-01-22T03:03:54.207Z","repository":{"id":63691303,"uuid":"569042349","full_name":"parfeon/event-emitter","owner":"parfeon","description":"Easy to use strongly-typed event emitter.","archived":false,"fork":false,"pushed_at":"2023-05-14T08:53:19.000Z","size":113,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-08T21:26:45.852Z","etag":null,"topics":[],"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/parfeon.png","metadata":{"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":"2022-11-22T00:30:32.000Z","updated_at":"2022-11-22T01:28:24.000Z","dependencies_parsed_at":"2024-10-31T15:12:16.503Z","dependency_job_id":null,"html_url":"https://github.com/parfeon/event-emitter","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"c37607b293d19cd60c44ae4e17be70ffb3845a8b"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/parfeon/event-emitter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parfeon%2Fevent-emitter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parfeon%2Fevent-emitter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parfeon%2Fevent-emitter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parfeon%2Fevent-emitter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/parfeon","download_url":"https://codeload.github.com/parfeon/event-emitter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parfeon%2Fevent-emitter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28651817,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T01:17:37.254Z","status":"online","status_checked_at":"2026-01-22T02:00:07.137Z","response_time":144,"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":[],"created_at":"2026-01-22T03:03:54.134Z","updated_at":"2026-01-22T03:03:54.197Z","avatar_url":"https://github.com/parfeon.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Event listener\n\n[![Tests](https://github.com/parfeon/event-emitter/actions/workflows/run-tests.yml/badge.svg)](https://github.com/parfeon/event-emitter/actions/workflows/run-tests.yml) [![NPM Version](https://img.shields.io/npm/v/@randombytes/event-emitter.svg?style=flat)](https://www.npmjs.org/package/@randombytes/event-emitter) [![codecov](https://codecov.io/github/parfeon/event-emitter/branch/main/graph/badge.svg?token=frSpSxJL7a)](https://codecov.io/github/parfeon/event-emitter)\n\n\nSmall and easy to use event listener / emitter with strongly-typed functions.\n\n## Install\n\n#### NPM\n```sh\nnpm install @randombytes/event-emitter\n```\n\n#### Yarn\n```shell\nyarn add @randombytes/event-emitter\n```\n\n## Import\n\n```typescript\nimport { EventEmitter } from '@randombytes/event-emitter'\n```\n\n## Usage\n\n```typescript\n// Prepare events map for emitter.\nimport {EventEmitter} from \"./emitter\";\n\n// Events map type which will be used by EventEmitter to assist \n// with functions usage.\ntype TestEvents = {\n  'case-one': (title: string) =\u003e void\n  'case-two': (title: string, subtitle: string) =\u003e void\n  'case-three': (title: string, flag: boolean) =\u003e void\n}\n\n// Create event emitter instance.\nconst emitter = new EventEmitter\u003cTestEvents\u003e()\n\n// Add listener which will be called for each emitted target events.\nconst listenerToken = emitter.on('case-two', (title) =\u003e {\n  // Handle `case-two` event with passed title.\n})\n\n// Add listener which will be called only once for emitted \n// target event.\nemitter.once('case-three', (title, flags) =\u003e {\n  // Handle `case-three` event with passed title and flags.\n})\n\n// Emit events assisted by IDE for list of expected arguments.\nemitter.emit('case-two', 'Event title')\nemitter.emit('case-three', 'One time event title', true)\n\n// Unregister listener when it will be required\nlistenerToken.invalidate()\n\n// or remove all listeners at once.\nemitter.removeAllListeners()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparfeon%2Fevent-emitter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparfeon%2Fevent-emitter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparfeon%2Fevent-emitter/lists"}