{"id":13486768,"url":"https://github.com/open-draft/strict-event-emitter","last_synced_at":"2026-01-22T19:43:17.724Z","repository":{"id":54252037,"uuid":"322278894","full_name":"open-draft/strict-event-emitter","owner":"open-draft","description":"Type-safe EventEmitter for browser and Node.js.","archived":false,"fork":false,"pushed_at":"2024-08-06T09:37:48.000Z","size":243,"stargazers_count":65,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-17T22:50:32.300Z","etag":null,"topics":["emitter","events","typed"],"latest_commit_sha":null,"homepage":"https://npm.im/strict-event-emitter","language":"TypeScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/open-draft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-12-17T11:49:25.000Z","updated_at":"2025-03-20T06:38:08.000Z","dependencies_parsed_at":"2024-10-02T13:33:34.050Z","dependency_job_id":"4d0ddad6-bee0-4303-a439-a6d6e2b07c57","html_url":"https://github.com/open-draft/strict-event-emitter","commit_stats":{"total_commits":64,"total_committers":6,"mean_commits":"10.666666666666666","dds":0.109375,"last_synced_commit":"56e004cf2793053ea9ece4330fd52cace96acbff"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/open-draft/strict-event-emitter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-draft%2Fstrict-event-emitter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-draft%2Fstrict-event-emitter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-draft%2Fstrict-event-emitter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-draft%2Fstrict-event-emitter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/open-draft","download_url":"https://codeload.github.com/open-draft/strict-event-emitter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-draft%2Fstrict-event-emitter/sbom","scorecard":{"id":708306,"data":{"date":"2025-08-11","repo":{"name":"github.com/open-draft/strict-event-emitter","commit":"c0c3d5a1f942da9e1fa16f0d36565a75839dae78"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.5,"checks":[{"name":"Code-Review","score":1,"reason":"Found 5/30 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/open-draft/strict-event-emitter/main.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/open-draft/strict-event-emitter/main.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/open-draft/strict-event-emitter/main.yml/main?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/main.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 12 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"11 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-67mh-4wv8-2f99","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-3mv9-4h5g-vhg3"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T07:24:05.819Z","repository_id":54252037,"created_at":"2025-08-22T07:24:05.819Z","updated_at":"2025-08-22T07:24:05.819Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28669542,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T19:36:09.361Z","status":"ssl_error","status_checked_at":"2026-01-22T19:36:05.567Z","response_time":144,"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":["emitter","events","typed"],"created_at":"2024-07-31T18:00:50.875Z","updated_at":"2026-01-22T19:43:17.706Z","avatar_url":"https://github.com/open-draft.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Strict Event Emitter\n\nA type-safe implementation of `EventEmitter` for browser and Node.js.\n\n## Motivation\n\nDespite event emitters potentially accepting any runtime value, defining a strict event contract is crucial when developing complex event-driven architectures. Unfortunately, the native type definitions for Node's `EventEmitter` annotate event names as `string`, which forbids any stricter type validation.\n\n```js\n// index.js\nconst emitter = new EventEmitter()\n\n// Let's say our application expects a \"ping\"\n// event with the number payload.\nemitter.on('ping', (n: number) =\u003e {})\n\n// We can, however, emit a different event by mistake.\nemitter.emit('pong', 1)\n\n// Or even the correct event with the wrong data.\nemitter.emit('ping', 'wait, not a number')\n```\n\nThe purpose of this library is to provide an `EventEmitter` instance that can accept a generic describing the expected events contract.\n\n```ts\nimport { Emitter } from 'strict-event-emitter'\n\n// Define a strict events contract where keys\n// represent event names and values represent\n// the list of arguments expected in \".emit()\".\ntype Events = {\n  ping: [number]\n}\n\nconst emitter = new Emitter\u003cEvents\u003e()\nemitter.addListener('ping', (n) =\u003e {\n  // \"n\" argument type is inferred as \"number'.\n})\n\nemitter.emit('ping', 10) // OK\nemitter.emit('unknown', 10) // TypeError (invalid event name)\nemitter.emit('ping', 'wait, not a number') // TypeError (invalid data)\n```\n\nThis library is also a custom `EventEmitter` implementation, which makes it compatible with other environments, like browsers or React Native.\n\n## Getting started\n\n### Install\n\n```bash\nnpm install strict-event-emitter\n```\n\n### Use\n\n```ts\nimport { Emitter } from 'strict-event-emitter'\n\n// 1. Define a type that describes your events.\n// Set event names as the keys, and their expected payloads as values.\ntype Events = {\n  connect: [id: string]\n  disconnect: [id: string]\n}\n\n// 2. Create a strict emitter and pass the previously defined \"Events\"\n// as its first generic argument.\nconst emitter = new Emitter\u003cEvents\u003e()\n\n// 3. Use the \"emitter\" the same way you'd use the regular \"EventEmitter\" instance.\nemitter.addListener('connect', (id) =\u003e {})\nemitter.emit('connect', 'abc-123')\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-draft%2Fstrict-event-emitter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopen-draft%2Fstrict-event-emitter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-draft%2Fstrict-event-emitter/lists"}