{"id":24698438,"url":"https://github.com/zero-dependency/emitter","last_synced_at":"2025-03-22T03:41:33.510Z","repository":{"id":109547501,"uuid":"547782897","full_name":"zero-dependency/emitter","owner":"zero-dependency","description":"✍️ Event Emitter","archived":false,"fork":false,"pushed_at":"2024-02-09T06:47:00.000Z","size":69,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-27T04:18:30.365Z","etag":null,"topics":["emitter","event-emitter","events","javascript","package","typescript","zero-dependency"],"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/zero-dependency.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}},"created_at":"2022-10-08T09:28:46.000Z","updated_at":"2023-06-04T13:11:39.000Z","dependencies_parsed_at":"2023-04-06T10:20:55.239Z","dependency_job_id":"e048f409-4447-471b-b357-8a7f4ba05f0b","html_url":"https://github.com/zero-dependency/emitter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"zero-dependency/template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zero-dependency%2Femitter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zero-dependency%2Femitter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zero-dependency%2Femitter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zero-dependency%2Femitter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zero-dependency","download_url":"https://codeload.github.com/zero-dependency/emitter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244902929,"owners_count":20529114,"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":["emitter","event-emitter","events","javascript","package","typescript","zero-dependency"],"created_at":"2025-01-27T04:18:34.676Z","updated_at":"2025-03-22T03:41:33.487Z","avatar_url":"https://github.com/zero-dependency.png","language":"TypeScript","readme":"# @zero-dependency/emitter\n\n[![npm version](https://img.shields.io/npm/v/@zero-dependency/emitter)](https://npm.im/@zero-dependency/emitter)\n[![npm bundle size (scoped)](https://img.shields.io/bundlephobia/minzip/@zero-dependency/emitter)](https://bundlephobia.com/package/@zero-dependency/emitter@latest)\n![npm license](https://img.shields.io/npm/l/@zero-dependency/emitter)\n\n## Installation\n\n```sh\nnpm install @zero-dependency/emitter\n```\n\n```sh\nyarn add @zero-dependency/emitter\n```\n\n```sh\npnpm add @zero-dependency/emitter\n```\n\n## Usage\n\n```ts\nimport { Emitter } from '@zero-dependency/emitter'\n\ntype Events = {\n  message: (msg: string) =\u003e void\n}\n\nconst events = new Emitter\u003cEvents\u003e()\n\nfunction onMessage(msg: string): void {}\n\n// Adds the listener function for the event named message.\nevents.on('message', onMessage)\n\n// Adds a one-time listener function for the event named message.\n// The next time message is triggered, this listener is removed and then invoked.\nevents.once('message', onMessage)\n\n// Synchronously calls each of the listeners registered for the event named message,\n// in the order they were registered, passing the supplied arguments to each.\n// Returns true if the event had listeners, false otherwise.\nevents.emit('message', 'hello world')\n\n// Removes the specified listener from the listener array for the event named message.\nevents.off('message', onMessage)\n\n// Removes all listeners, or those of the specified message.\nevents.removeAllListeners('message')\n\n// Removes all listeners for events.\nevents.removeAllListeners()\n\n// Returns an array listing the events for which the emitter has registered listeners.\n// The values in the array are strings or Symbols.\nevents.eventNames()\n\n// Returns an array of listeners for an event named message.\nevents.listeners('message')\n\n// Returns the number of listeners listening to the event named message.\nevents.listenerCount('message')\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzero-dependency%2Femitter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzero-dependency%2Femitter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzero-dependency%2Femitter/lists"}