{"id":16893932,"url":"https://github.com/coolreader18/events-async-methods","last_synced_at":"2026-05-19T15:37:07.431Z","repository":{"id":57231354,"uuid":"134304735","full_name":"coolreader18/events-async-methods","owner":"coolreader18","description":"EventEmitter methods that make them easier to use in async code.","archived":false,"fork":false,"pushed_at":"2018-05-28T21:10:17.000Z","size":54,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-25T21:38:24.214Z","etag":null,"topics":["eventemitter","events","javascript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/coolreader18.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":"2018-05-21T17:50:48.000Z","updated_at":"2018-05-28T21:10:19.000Z","dependencies_parsed_at":"2022-09-26T16:40:47.541Z","dependency_job_id":null,"html_url":"https://github.com/coolreader18/events-async-methods","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coolreader18%2Fevents-async-methods","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coolreader18%2Fevents-async-methods/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coolreader18%2Fevents-async-methods/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coolreader18%2Fevents-async-methods/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coolreader18","download_url":"https://codeload.github.com/coolreader18/events-async-methods/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244591502,"owners_count":20477708,"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":["eventemitter","events","javascript"],"created_at":"2024-10-13T17:17:00.970Z","updated_at":"2026-05-19T15:37:02.410Z","avatar_url":"https://github.com/coolreader18.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# events-async-methods\n\nEventEmitter methods that make them easier to use in async code.\n\n## Usage\n\n```js\nconst evtAsync = require(\"events-async-methods\");\nconst child_process = require(\"child_process\");\n\n(async () =\u003e {\n  const fork = child_process.fork(\"./forked.js\");\n  const [forkMessage] = await evtAsync.promise(fork, \"message\");\n  console.log(forkMessage);\n})();\n\n(async () =\u003e {\n  const server = http.createServer().listen(3000);\n  for await (let [req, res] of evtAsync.asyncIterator(server, \"request\")) {\n    res.end(\n      req.pathname\n        .split(\"\")\n        .reverse(\"\")\n        .join(\"\")\n    );\n  }\n})();\n```\n\nNote that all methods return an array, to account for the fact that event emitters can pass multiple arguments to listeners.\n\n### Different versions\n\nThere are 3 different versions of this module.\n\n* Default - `require(\"events-async-methods\")`: exports an object whose methods accepts an EventEmitter as the first argument,\n  and other arguments relevant to the function after it\n* Bound - `require(\"events-async-methods/bound\")`: exports an object whose methods need an EventEmitter as their `this`\n  argument, and you pass relevant arguments to the function. This is good for if you're using the esnext bind syntax,\n  e.g. `await process::evtAsync.promise(\"message\")`.\n* Prototype - `require(\"events-async-methods/proto\")`: modifies the prototype of EventEmitter to have the bound methods.\n  Not recommended for a project where other modules are using EventEmitters. This only returns a function,\n  which you call to modify the prototype. If you pass an argument, it modifies that class/prototype\n  instead of the `require(\"events\")` one, for if you'd like to use it on another implemenation of EventEmitters.\n\n## Installation\n\n```shell\nyarn add events-async-methods\n# or\nnpm install --save events-async-methods\n```\n\n## License\n\nThis project is licensed under the MIT license. Please see the [LICENSE](LICENSE) file for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoolreader18%2Fevents-async-methods","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoolreader18%2Fevents-async-methods","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoolreader18%2Fevents-async-methods/lists"}