# @yandeu/events

> ⚡ Simplified and TypeScripted version of EventEmitter3@4.0.7

Latest version **0.0.7** (published 2024-12-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install @yandeu/events
pnpm add @yandeu/events
yarn add @yandeu/events
bun add @yandeu/events
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2024-12-20 |
| First published | 2021-02-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18.2 |
| Dependencies | 0 |
| Unpacked size | 21.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Yannick Deubel |
| Maintainers | yandeu |
| Keywords | events, typescript |

## Links

- npm: https://www.npmjs.com/package/@yandeu/events
- Repository: https://github.com/yandeu/events
- Homepage: https://github.com/yandeu/events#readme
- Issues: https://github.com/yandeu/events/issues
- Funding: https://github.com/sponsors/yandeu
- npm.io page: https://npm.io/package/@yandeu/events

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.0.7 (latest) — 2024-12-20
- 0.0.6 — 2022-11-04
- 0.0.5 — 2021-03-02
- 0.0.4 — 2021-03-01
- 0.0.3 — 2021-03-01
- 0.0.2 — 2021-02-27
- 0.0.1 — 2021-02-27

## README

# Events

Simplified and TypeScripted version of EventEmitter3@4.0.7  
(_no support for Symbols_)

## Installation

```console
npm install @yandeu/events
```

## Examples

See [examples](/examples/).

## CDN

```console
// ES2015+
https://unpkg.com/@yandeu/events/umd/events.min.js

// ES5
https://unpkg.com/@yandeu/events/umd/events.es5.min.js
```

## Usage

```ts
const { Events } = require('@yandeu/events')

// or
// import { Events } from '@yandeu/events'

const events = new Events()

events.on('message', msg => {
  console.log(`Message: ${msg}`)
})

events.emit('message', 'Hello there!')

// will print: Message: Hello there!
```

```ts
// print the current version
console.log('Events VERSION: ', Events.VERSION)
```

## TypeScript

```ts
import { Events } from '@yandeu/events'

interface EventMap {
  signal: () => void
  error: (err: string) => void
  something: (a: number, b: { color?: string }, c: [number, number, string]) => void
}

const events = new Events<EventMap>()

events.on('something', (a, b, c) => {
  console.log(a, b.color, c)
})

events.emit('something', 1, { color: 'blue' }, [2, 2, 'k'])
```

```ts
import type { EventListener } from '@yandeu/events'

// typed listener
const listener: EventListener<EventMap, 'error'> = err => {
  console.log('err:', err)
}

// add listener
events.on('error', listener)

// remove listener
// (once you don't need it anymore)
events.removeListener('error', listener)
```

## License

[MIT](LICENSE)

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