# event-target-shim

> An implementation of WHATWG EventTarget interface.

Latest version **6.0.2** (published 2021-01-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install event-target-shim
pnpm add event-target-shim
yarn add event-target-shim
bun add event-target-shim
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 6.0.2 |
| Published | 2021-01-07 |
| First published | 2015-02-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=10.13.0 |
| Dependencies | 0 |
| Unpacked size | 381.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 130 |
| Author | Toru Nagashima |
| Maintainers | mysticatea |
| Keywords | w3c, whatwg, eventtarget, event, events, shim |

## Links

- npm: https://www.npmjs.com/package/event-target-shim
- Repository: https://github.com/mysticatea/event-target-shim
- Issues: https://github.com/mysticatea/event-target-shim/issues
- Funding: https://github.com/sponsors/mysticatea
- npm.io page: https://npm.io/package/event-target-shim

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 6.0.2 (latest) — 2021-01-07
- 6.0.1 — 2021-01-07
- 6.0.0 — 2021-01-06
- 5.0.1 — 2019-02-19
- 5.0.0 — 2019-01-21
- 5.0.0-beta.0 — 2019-01-18
- 4.0.3 — 2018-12-05
- 4.0.2 — 2018-12-04
- 4.0.1 — 2018-12-01
- 4.0.0 — 2018-12-01
- 3.0.2 — 2018-06-26
- 3.0.1 — 2018-01-23
- 3.0.0 — 2017-10-02
- 2.0.0 — 2016-11-26
- 1.1.1 — 2015-12-17
- … 12 more at https://npm.io/package/event-target-shim/versions

## README

# event-target-shim

[![npm version](https://img.shields.io/npm/v/event-target-shim.svg)](https://www.npmjs.com/package/event-target-shim)
[![Downloads/month](https://img.shields.io/npm/dm/event-target-shim.svg)](http://www.npmtrends.com/event-target-shim)
[![Build Status](https://github.com/mysticatea/event-target-shim/workflows/CI/badge.svg)](https://github.com/mysticatea/event-target-shim/actions)
[![Coverage Status](https://codecov.io/gh/mysticatea/event-target-shim/branch/master/graph/badge.svg)](https://codecov.io/gh/mysticatea/event-target-shim)
[![Dependency Status](https://david-dm.org/mysticatea/event-target-shim.svg)](https://david-dm.org/mysticatea/event-target-shim)

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`.

This implementation is designed ...

- Working fine on both browsers and Node.js.
- TypeScript friendly.

## 💿 Installation

Use [npm](https://www.npmjs.com/) or a compatible tool.

```
npm install event-target-shim
```

## 📖 Getting started

```js
import { EventTarget, Event } from "event-target-shim";

// constructor (was added to the standard on 8 Jul 2017)
const myNode = new EventTarget();

// passive flag (was added to the standard on 6 Jan 2016)
myNode.addEventListener(
  "hello",
  (e) => {
    e.preventDefault(); // ignored and print warning on console.
  },
  { passive: true }
);

// once flag (was added to the standard on 15 Apr 2016)
myNode.addEventListener("hello", listener, { once: true });
myNode.dispatchEvent(new Event("hello")); // remove the listener after call.

// signal (was added to the standard on 4 Dec 2020)
const ac = new AbortController();
myNode.addEventListener("hello", listener, { signal: ac.signal });
ac.abort(); // remove the listener.
```

- For browsers, 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.
- 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.

## 📚 API Reference

See [docs/reference.md](docs/reference.md).

## 💥 Migrating to v6

See [docs/migrating-to-v6.md](docs/migrating-to-v6.md).

## 📰 Changelog

See [GitHub releases](https://github.com/mysticatea/event-target-shim/releases).

## 🍻 Contributing

Contributing is welcome ❤️

Please use GitHub issues/PRs.

### Development tools

- `npm install` installs dependencies for development.
- `npm test` runs tests and measures code coverage.
- `npm run watch:mocha` runs tests on each file change.

---
_Source: https://npm.io/package/event-target-shim · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
