{"id":21691496,"url":"https://github.com/scientific-dev/evtmanager","last_synced_at":"2026-04-13T16:02:27.350Z","repository":{"id":62422088,"uuid":"354542458","full_name":"scientific-dev/evtmanager","owner":"scientific-dev","description":"Simple and easy to use eventemitter to manage your events synchronously and asynchronously too for Deno, node and for the browser with a typesafe environment!","archived":false,"fork":false,"pushed_at":"2021-04-04T13:09:09.000Z","size":7,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-14T05:43:56.692Z","etag":null,"topics":["browser","deno","eventemitter","events","javascript","nodejs"],"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/scientific-dev.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}},"created_at":"2021-04-04T12:51:07.000Z","updated_at":"2021-09-05T09:29:35.000Z","dependencies_parsed_at":"2022-11-01T17:31:49.000Z","dependency_job_id":null,"html_url":"https://github.com/scientific-dev/evtmanager","commit_stats":null,"previous_names":["scientific-guy/evtmanager"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/scientific-dev/evtmanager","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scientific-dev%2Fevtmanager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scientific-dev%2Fevtmanager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scientific-dev%2Fevtmanager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scientific-dev%2Fevtmanager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scientific-dev","download_url":"https://codeload.github.com/scientific-dev/evtmanager/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scientific-dev%2Fevtmanager/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31759540,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T15:25:13.801Z","status":"ssl_error","status_checked_at":"2026-04-13T15:25:09.162Z","response_time":93,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["browser","deno","eventemitter","events","javascript","nodejs"],"created_at":"2024-11-25T17:38:52.578Z","updated_at":"2026-04-13T16:02:27.309Z","avatar_url":"https://github.com/scientific-dev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EvtManager\n\nSimple and easy to use eventemitter to manage your events synchronously and asynchronously too for Deno, node and for the browser with a typesafe environment!\n\n[![](https://www.codefactor.io/repository/github/scientific-guy/evtmanager/badge?style=for-the-badge)](https://www.codefactor.io/repository/github/scientific-guy/evtmanager)\n[![](https://img.shields.io/badge/VIEW-GITHUB-white?style=for-the-badge)](https://github.com/Scientific-Guy/evtmanager)\n[![](https://img.shields.io/github/v/tag/Scientific-Guy/evtmanager?style=for-the-badge\u0026label=version)](https://github.com/Scientific-Guy/evtmanager)\n\n## Installation\n\n### For deno\n\n```ts\nimport { EventEmitter } from \"https://raw.githubusercontent.com/Scientific-Guy/evtmanager/master/mod.ts\";\n```\n\n### For node and browser\n\n```sh\n\u003e npm i evtmanager\n```\n\n## Example\n\nEvtmanager is same as the basic `events` package but with some additional utilities and typesafe environment!\n\n```ts\nimport { EventEmitter } from \"evtmanager\";\n\ninterface EventMap{\n    ready: () =\u003e void;\n    start: () =\u003e void;\n    destory: (reason?: string) =\u003e void;\n    error: (reason?: string) =\u003e void;\n}\n\nconst system = new EventEmitter\u003cEventMap\u003e();\n\nsystem.on(\"ready\", () =\u003e {\n    console.log('System is ready!');\n});\n\nsystem.emit('ready');\n```\n\nNow here is an example of a typesafe environment\n\n```ts\nsystem.on(\"ready\", () =\u003e {\n    console.log('System is ready!');\n}); // Will compile\n\nsystem.on(\"ready\", (ctx) =\u003e {\n    console.log('System is ready!');\n}); // Will not compile as it has a parameter ctx additional which is not supplied in the event map!\n```\n\nHere are some methods which you already might know!\n\n```ts\nconst listener = () =\u003e console.log(\"System is ready\");\n\nsystem.addListener(\"ready\", listener); // Adds an listener\nsystem.on(\"ready\", () =\u003e console.log(\"System is ready\")); // Same as addListener method\nsystem.once(\"ready\", () =\u003e console.log(\"System is ready\")); // Adds an listener which listens only one event\n\nsystem.removeListener(\"ready\", listener); // Removes a listener\nsystem.removeListeners(\"ready\"); // Removes all listeners registered on event \"ready\"\nsystem.clear(); // Clears all event listeners\n\nconst listeners = system.getListeners(\"ready\"); // Returns an array of listeners listening to the event\nconst count = system.listenerCount(\"ready\"); // Returns number of listeners listening to the \"ready\" event\n\nconst responses = await system.emit(\"ready\"); // Dispatches a event and runs all the listeners one by one awaiting it\nconst syncResponses = system.emitSync(\"ready\"); // Dispatches a event and does not waits for listeners to return a value\n\nsystem.maxListeners.set(\"ready\", 5); // Set maximum listeners to 5 so only about 5 listeners can listen to the event!\nsystem.maxListeners.delete(\"ready\"); // Remove the limit\nsystem.maxListeners.get(\"ready\"); // Get limit\n```\n\n### Awaiting responses\n\nWaiting events means it waits for the emitter for the event to be emitted and returns the args received!\n\n```ts\nconst response = await system.wait(\"destroy\");\nconsole.log(`System finally destoryed with the reason as: ${response}`);\n```\n\nThis is used for the once method. You can even set a timeout for it!\n\n```ts\ntry{\n    const response = await system.wait(\"destroy\", 2000);\n    console.log(`System finally destoryed with the reason as: ${response}`);\n} catch {\n    console.log(`Could not catch the event within 2 seconds!`);\n}\n```\n\n### Iterating \n\nYou can iterate asynchronously over an event like this\n\u003e This method is made as for some utility!\n\n```ts\nfor await (const [reason] of system.iterator(\"error\")) {\n    console.log(`Found an error: ${reason}`);\n}\n```\n\n## MonoEmitter\n\nMonoEmitter is nothing but the same eventemitter but does not needs any event name to register! For example, view the code block given below:\n\n```ts\nimport { MonoEmitter } from \"evtmanager\";\n\nconst system = new MonoEmitter();\n\nsystem.on(() =\u003e {\n    console.log('System is ready!');\n});\n\nsystem.emit();\n```\n\nIt has almost the same methods \n\n```ts\nconst listener = () =\u003e console.log(\"I am emitted\");\n\nevent.addListener(listener); // Adds an listener\nevent.on(() =\u003e console.log(\"I am emitted\")); // Same as addListener method\nevent.once(() =\u003e console.log(\"I am emitted\")); // Adds an listener which listens only one event\n\nevent.removeListener(listener); // Removes a listener\nevent.clear(); // Clears all event listeners\n\nevent.listeners; // Returns an array of listeners listening to the event\nevent.listenerCount; // Returns number of listeners listening to the \"ready\" event\n\nconst responses = await event.emit(); // Dispatches a event and runs all the listeners one by one awaiting it\nconst syncResponses = event.emitSync(); // Dispatches a event and does not waits for listeners to return a value\n\nevent.maxListenersCount = 5; // Set maximum listeners to 5 so only about 5 listeners can listen to the event!\ndelete event.maxListenersCount; // Remove the limit\n```\n\nAnd you can use the same utility methods to the `MonoEmitter` too!\n\n```ts\ntry{\n    const args = await event.wait(2000);\n    console.log(args);\n} catch {\n    console.log(`Could not catch the event within 2 seconds!`);\n}\n```\n\n```ts\nfor await (const args of event.iterator(\"error\")) {\n    console.log(`Caught a new event: `, args);\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscientific-dev%2Fevtmanager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscientific-dev%2Fevtmanager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscientific-dev%2Fevtmanager/lists"}