# yaeti

> Yet Another EventTarget Implementation

Latest version **1.0.3** (published 2022-01-10) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install yaeti
pnpm add yaeti
yarn add yaeti
bun add yaeti
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2022-01-10 |
| First published | 2015-07-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/yaeti) |
| Module format | CommonJS |
| Node | >=4.0.0 |
| Dependencies | 0 |
| Unpacked size | 8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Iñaki Baz Castillo |
| Maintainers | ibc |

## Links

- npm: https://www.npmjs.com/package/yaeti
- Repository: https://github.com/ibc/yaeti
- Homepage: https://github.com/ibc/yaeti#readme
- Issues: https://github.com/ibc/yaeti/issues
- npm.io page: https://npm.io/package/yaeti

## Recent versions

- 1.0.3 (latest) — 2022-01-10
- 1.0.2 — 2018-02-23
- 1.0.1 — 2017-04-25
- 1.0.0 — 2017-04-20
- 0.0.6 — 2016-03-17
- 0.0.5 — 2016-01-28
- 0.0.4 — 2015-07-22
- 0.0.3 — 2015-07-22
- 0.0.2 — 2015-07-22
- 0.0.1 — 2015-07-20

## README

# yaeti

Yet Another [EventTarget](https://developer.mozilla.org/es/docs/Web/API/EventTarget) Implementation.

The library exposes both the [EventTarget](https://developer.mozilla.org/es/docs/Web/API/EventTarget) interface and the [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event) interface.


## Installation

```bash
$ npm install yaeti --save
```


## Usage

```javascript
var yaeti = require('yaeti');

// Custom class we want to make an EventTarget.
function Foo() {
    // Call EventTarget constructor
    yaeti.EventTarget.call(this);
}
// Inherit EventTarget prototype
Foo.prototype = Object.create(yaeti.EventTarget.prototype);
Foo.prototype.constructor = Foo;

// Create an instance.
var foo = new Foo();

function listener1() {
    console.log('listener1');
}

function listener2() {
    console.log('listener2');
}
 
foo.addEventListener('bar', listener1);
foo.addEventListener('bar', listener2);
foo.removeEventListener('bar', listener1);

var event = new yaeti.Event('bar');

foo.dispatchEvent(event);

// Output:
// => "listener2"
```


## API


### `yaeti.EventTarget` interface

Implementation of the [EventTarget](https://developer.mozilla.org/es/docs/Web/API/EventTarget) interface.

#### ES5
```javascript
function Foo() {
    yaeti.EventTarget.call(this);
}
Foo.prototype = Object.create(yaeti.EventTarget.prototype);
Foo.prototype.constructor = Foo;
```

#### ES6
```javascript
class Foo extends EventTarget () {
    constructor () {
        super();
    }
}
```

The interface implements the `addEventListener`, `removeEventListener` and `dispatchEvent` methods as defined by the W3C.


##### `listeners` read-only property

Returns an object whose keys are configured event types (String) and whose values are an array of listeners (functions) for those event types.


### `yaeti.Event` interface

Implementation of the [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event) interface.

*NOTE:* Just useful in Node (the browser already exposes the native `Event` interface).

```javascript
var event = new yaeti.Event('bar');
```


## Author

[Iñaki Baz Castillo](https://inakibaz.me)


## License

[MIT](./LICENSE)

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