{"id":20827263,"url":"https://github.com/ccnokes/dom-event-utils","last_synced_at":"2025-05-07T21:03:31.494Z","repository":{"id":88144023,"uuid":"123863854","full_name":"ccnokes/dom-event-utils","owner":"ccnokes","description":"Very small library that makes working with the DOM event emitters API (and others) a little easier to work with.","archived":false,"fork":false,"pushed_at":"2018-03-08T03:24:31.000Z","size":90,"stargazers_count":28,"open_issues_count":0,"forks_count":18,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-07T21:03:17.587Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ccnokes.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":"2018-03-05T04:17:37.000Z","updated_at":"2023-10-13T11:08:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"aca52aef-51ab-4747-845f-1ca43f896671","html_url":"https://github.com/ccnokes/dom-event-utils","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/ccnokes%2Fdom-event-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccnokes%2Fdom-event-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccnokes%2Fdom-event-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccnokes%2Fdom-event-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ccnokes","download_url":"https://codeload.github.com/ccnokes/dom-event-utils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252954409,"owners_count":21830902,"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-17T23:11:36.645Z","updated_at":"2025-05-07T21:03:31.481Z","avatar_url":"https://github.com/ccnokes.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dom-event-utils\n\nVery small library that makes working with DOM event emitters API a little easier to work with. These are all common utilities that I find myself reaching for, regardless of the framework I'm in.\n\n### Methods\n\n`eventToPromise` - convert an event to a promise that resolves once it's called.\nFor example:\n\n```javascript\nimport { eventToPromise } from 'dom-event-utils';\n\nfunction createPopup() {\n  const popup = window.open('/my-popup');\n  return eventToPromise(popup, 'load', () =\u003e {\n    // do stuff here\n    return popup;\n  }, 10000); //timeout is optional. If reached, it'll reject the promise\n}\n```\n\n`on` - just like `addEventListener`, but returns an unsubscribe function.\n```javascript\nimport { on } from 'dom-event-utils';\n\nconst off = on(document.querySelector('.btn'), 'click', () =\u003e { /* click handler */ });\n//...later, somewhere else...\noff();\n```\n\n`once` - only called once and then unsubscribed from the event source\n```javascript\nimport { once } from 'event-utils';\n\nonce(document, 'DOMContentLoaded', () =\u003e {\n  //...do things here\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fccnokes%2Fdom-event-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fccnokes%2Fdom-event-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fccnokes%2Fdom-event-utils/lists"}