{"id":20114604,"url":"https://github.com/alienzhou/temitter","last_synced_at":"2026-06-08T00:32:13.629Z","repository":{"id":107436216,"uuid":"457644077","full_name":"alienzhou/temitter","owner":"alienzhou","description":"a type-safe \u0026 tiny event emitter","archived":false,"fork":false,"pushed_at":"2022-02-10T06:17:02.000Z","size":55,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-04-25T17:21:32.572Z","etag":null,"topics":[],"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/alienzhou.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}},"created_at":"2022-02-10T05:33:21.000Z","updated_at":"2022-02-10T06:17:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"a8314d3c-d38f-49b7-9373-09eeb67111f3","html_url":"https://github.com/alienzhou/temitter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alienzhou%2Ftemitter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alienzhou%2Ftemitter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alienzhou%2Ftemitter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alienzhou%2Ftemitter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alienzhou","download_url":"https://codeload.github.com/alienzhou/temitter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241557193,"owners_count":19981881,"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":[],"created_at":"2024-11-13T18:30:44.782Z","updated_at":"2026-06-08T00:32:13.582Z","avatar_url":"https://github.com/alienzhou.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# temitter\n\n\u003e a **T**ype-safe \u0026 **T**iny Event **Emitter**\n\n[![Build Status](https://app.travis-ci.com/alienzhou/temitter.svg?branch=main)](https://app.travis-ci.com/alienzhou/temitter)   [![NPM version](https://img.shields.io/npm/v/temitter.svg)](https://www.npmjs.com/package/temitter)  [![Coverage Status](https://coveralls.io/repos/github/alienzhou/temitter/badge.svg?branch=main)](https://coveralls.io/github/alienzhou/temitter?branch=main)   [![codebeat badge](https://codebeat.co/badges/cfd98455-1e33-4d87-b3a1-582780f5eda0)](https://codebeat.co/projects/github-com-alienzhou-temitter-main)   [![MIT License](https://img.shields.io/github/license/alienzhou/temitter)](https://opensource.org/licenses/mit-license.php)\n\n## Features\n\n- 🔐 Fully type safe for typescript\n- 💕 Support both browsers and nodejs\n- 🍃 Tiny size (~300 Byte after minified \u0026 gzip)\n- 🔎 Synchronous nature\n\n## Quick Start\n\n```\nnpm i temitter\n```\n\n```typescript\nimport { EventEmitter } from 'temitter';\ntype MyEventHandler = {\n    greeter: (s: string) =\u003e void;\n};\nconst ee = new EventEmitter\u003cMyEventHandler\u003e();\n\nee.on('greeter', s =\u003e console.log(s));\nee.emit('greeter', 'hi');\n```\n\n## How to use\n\nIt has most the same APIs as other event emitter libraries:\n\n- `.on`: add event listeners\n- `.off`: remove event listeners\n- `.emit`: emit an event with data\n\nYou can provide a specific type for `EventMap` to make fully type-safe:\n\n```typescript\nimport { EventEmitter } from 'temitter';\n\ntype MyEventHandler = {\n    greeter: (s: string) =\u003e void;\n    // ...some other listeners\n};\n\nconst ee = new EventEmitter\u003cMyEventHandler\u003e();\n\n// then event name 'greeter' and its listener will have the correct type\nee.on('greeter', s =\u003e console.log(s));\n\n// can only emit 'greeter' with a string\nee.emit('greeter', 'hi');\n\n// ❌ ee.emit('greeter', 100);\n// typescript compile error: should pass a string but got a number (100)\n```\n\n## APIs\n\n### `.on(event, listener)`\n\nListen on an event.\n\nIt will return the same `EventEmitter` instance.\n\n### `.off(event, listener?)`\n\nRemove the listener of an event. If it's called without the listener parameter, it will remove all listeners of the given event.\n\nIt will return the same `EventEmitter` instance.\n\n### `.emit(event, ...data)`\n\nEmit the event with some data. `.emit` is a synchronous call.\n\nIt will return the same `EventEmitter` instance.\n\n### `.once(event, listener)`\n\nListen on an event and promise to be called only once.\n\nIt will return the same `EventEmitter` instance.\n\n### `.offAll()`\n\nRemove all listeners of all events.\n\nIt will return the same `EventEmitter` instance.\n\n### `.eventNames`\n\nThe `EventEmitter` instance contains a `.eventNames` property. You can use this property get all valid events. A valid event is a event that has at least one listener on itself.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falienzhou%2Ftemitter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falienzhou%2Ftemitter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falienzhou%2Ftemitter/lists"}