Skip to content

Commit 1347327

Browse files
committed
🔖 6.0.2 (built with 035736c)
0 parents  commit 1347327

12 files changed

+6639
-0
lines changed

LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Toru Nagashima
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

README.md

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# event-target-shim
2+
3+
[![npm version](https://img.shields.io/npm/v/event-target-shim.svg)](https://www.npmjs.com/package/event-target-shim)
4+
[![Downloads/month](https://img.shields.io/npm/dm/event-target-shim.svg)](http://www.npmtrends.com/event-target-shim)
5+
[![Build Status](https://github.com/mysticatea/event-target-shim/workflows/CI/badge.svg)](https://github.com/mysticatea/event-target-shim/actions)
6+
[![Coverage Status](https://codecov.io/gh/mysticatea/event-target-shim/branch/master/graph/badge.svg)](https://codecov.io/gh/mysticatea/event-target-shim)
7+
[![Dependency Status](https://david-dm.org/mysticatea/event-target-shim.svg)](https://david-dm.org/mysticatea/event-target-shim)
8+
9+
An 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`.
10+
11+
This implementation is designed ...
12+
13+
- Working fine on both browsers and Node.js.
14+
- TypeScript friendly.
15+
16+
## 💿 Installation
17+
18+
Use [npm](https://www.npmjs.com/) or a compatible tool.
19+
20+
```
21+
npm install event-target-shim
22+
```
23+
24+
## 📖 Getting started
25+
26+
```js
27+
import { EventTarget, Event } from "event-target-shim";
28+
29+
// constructor (was added to the standard on 8 Jul 2017)
30+
const myNode = new EventTarget();
31+
32+
// passive flag (was added to the standard on 6 Jan 2016)
33+
myNode.addEventListener(
34+
"hello",
35+
(e) => {
36+
e.preventDefault(); // ignored and print warning on console.
37+
},
38+
{ passive: true }
39+
);
40+
41+
// once flag (was added to the standard on 15 Apr 2016)
42+
myNode.addEventListener("hello", listener, { once: true });
43+
myNode.dispatchEvent(new Event("hello")); // remove the listener after call.
44+
45+
// signal (was added to the standard on 4 Dec 2020)
46+
const ac = new AbortController();
47+
myNode.addEventListener("hello", listener, { signal: ac.signal });
48+
ac.abort(); // remove the listener.
49+
```
50+
51+
- For browsers, use a bundler such as [Webpack](https://webpack.js.org/) to bundle.
52+
- 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.
53+
- 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.
54+
55+
## 📚 API Reference
56+
57+
See [docs/reference.md](docs/reference.md).
58+
59+
## 💥 Migrating to v6
60+
61+
See [docs/migrating-to-v6.md](docs/migrating-to-v6.md).
62+
63+
## 📰 Changelog
64+
65+
See [GitHub releases](https://github.com/mysticatea/event-target-shim/releases).
66+
67+
## 🍻 Contributing
68+
69+
Contributing is welcome ❤️
70+
71+
Please use GitHub issues/PRs.
72+
73+
### Development tools
74+
75+
- `npm install` installs dependencies for development.
76+
- `npm test` runs tests and measures code coverage.
77+
- `npm run watch:mocha` runs tests on each file change.

0 commit comments

Comments
 (0)