{"id":16197826,"url":"https://github.com/mysticatea/event-target-shim","last_synced_at":"2025-05-16T04:06:03.358Z","repository":{"id":27652209,"uuid":"31137469","full_name":"mysticatea/event-target-shim","owner":"mysticatea","description":"An implementation of WHATWG EventTarget interface, plus few extensions.","archived":false,"fork":false,"pushed_at":"2023-01-06T17:18:58.000Z","size":1375,"stargazers_count":126,"open_issues_count":29,"forks_count":25,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-08T14:45:50.471Z","etag":null,"topics":["events","eventtarget","javascript","npm","npm-module","npm-package","w3c","web"],"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/mysticatea.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":"2015-02-21T19:20:04.000Z","updated_at":"2025-03-22T16:45:47.000Z","dependencies_parsed_at":"2023-01-14T07:12:39.555Z","dependency_job_id":null,"html_url":"https://github.com/mysticatea/event-target-shim","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mysticatea%2Fevent-target-shim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mysticatea%2Fevent-target-shim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mysticatea%2Fevent-target-shim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mysticatea%2Fevent-target-shim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mysticatea","download_url":"https://codeload.github.com/mysticatea/event-target-shim/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254022477,"owners_count":22001137,"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":["events","eventtarget","javascript","npm","npm-module","npm-package","w3c","web"],"created_at":"2024-10-10T09:09:43.217Z","updated_at":"2025-05-16T04:06:03.338Z","avatar_url":"https://github.com/mysticatea.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# event-target-shim\n\n[![npm version](https://img.shields.io/npm/v/event-target-shim.svg)](https://www.npmjs.com/package/event-target-shim)\n[![Downloads/month](https://img.shields.io/npm/dm/event-target-shim.svg)](http://www.npmtrends.com/event-target-shim)\n[![Build Status](https://github.com/mysticatea/event-target-shim/workflows/CI/badge.svg)](https://github.com/mysticatea/event-target-shim/actions)\n[![Coverage Status](https://codecov.io/gh/mysticatea/event-target-shim/branch/master/graph/badge.svg)](https://codecov.io/gh/mysticatea/event-target-shim)\n[![Dependency Status](https://david-dm.org/mysticatea/event-target-shim.svg)](https://david-dm.org/mysticatea/event-target-shim)\n\nAn implementation of [WHATWG `EventTarget` interface](https://dom.spec.whatwg.org/#interface-eventtarget) and [WHATWG `Event` interface](https://dom.spec.whatwg.org/#interface-event). This implementation supports constructor, `passive`, `once`, and `signal`.\n\nThis implementation is designed ...\n\n- Working fine on both browsers and Node.js.\n- TypeScript friendly.\n\n**Native Support Information:**\n\n| Feature                   | IE  | Edge | Firefox | Chrome | Safari | Node.js |\n| :------------------------ | :-- | :--- | :------ | :----- | :----- | :------ |\n| `Event` constructor       | ❌  | 12   | 11      | 15     | 6      | 15.4.0  |\n| `EventTarget` constructor | ❌  | 87   | 84      | 87     | 14     | 15.4.0  |\n| `passive` option          | ❌  | 16   | 49      | 51     | 10     | 15.4.0  |\n| `once` option             | ❌  | 16   | 50      | 55     | 10     | 15.4.0  |\n| `signal` option           | ❌  | ❌   | ❌      | ❌     | ❌     | ❌      |\n\n---\n\n## 💿 Installation\n\nUse [npm](https://www.npmjs.com/) or a compatible tool.\n\n```\nnpm install event-target-shim\n```\n\n## 📖 Getting started\n\n```js\nimport { EventTarget, Event } from \"event-target-shim\";\n\n// constructor (was added to the standard on 8 Jul 2017)\nconst myNode = new EventTarget();\n\n// passive flag (was added to the standard on 6 Jan 2016)\nmyNode.addEventListener(\n  \"hello\",\n  (e) =\u003e {\n    e.preventDefault(); // ignored and print warning on console.\n  },\n  { passive: true }\n);\n\n// once flag (was added to the standard on 15 Apr 2016)\nmyNode.addEventListener(\"hello\", listener, { once: true });\nmyNode.dispatchEvent(new Event(\"hello\")); // remove the listener after call.\n\n// signal (was added to the standard on 4 Dec 2020)\nconst ac = new AbortController();\nmyNode.addEventListener(\"hello\", listener, { signal: ac.signal });\nac.abort(); // remove the listener.\n```\n\n- For browsers, there are two ways:\n  - use a bundler such as [Webpack](https://webpack.js.org/) to bundle. If you want to support IE11, use `import {} from \"event-target-shim/es5\"` instead. It's a transpiled code by babel. It depends on `@baebl/runtime` (`^7.12.0`) package.\n  - use CDN such as `unpkg.com`. For example, `\u003cscript src=\"https://unpkg.com/event-target-shim@6.0.2\"\u003e\u003c/script\u003e` will define `EventTargetShim` global variable.\n- The `AbortController` class was added to the standard on 14 Jul 2017. If you want the shim of that, use [abort-controller](https://www.npmjs.com/package/abort-controller) package.\n\n### Runnable Examples\n\n- [Basic Example](https://jsbin.com/dapuwomamo/1/edit?html,console)\n- [Basic Example (IE11)](https://jsbin.com/xigeyetipe/1/edit?html,console)\n\n## 📚 API Reference\n\nSee [docs/reference.md](docs/reference.md).\n\n## 💥 Migrating to v6\n\nSee [docs/migrating-to-v6.md](docs/migrating-to-v6.md).\n\n## 📰 Changelog\n\nSee [GitHub releases](https://github.com/mysticatea/event-target-shim/releases).\n\n## 🍻 Contributing\n\nContributing is welcome ❤️\n\nPlease use GitHub issues/PRs.\n\n### Development tools\n\n- `npm install` installs dependencies for development.\n- `npm test` runs tests and measures code coverage.\n- `npm run watch:mocha` runs tests on each file change.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmysticatea%2Fevent-target-shim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmysticatea%2Fevent-target-shim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmysticatea%2Fevent-target-shim/lists"}