# @chocolatemilkdev/emitter

> a basic event emitter.

Latest version **1.0.7** (published 2024-02-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install @chocolatemilkdev/emitter
pnpm add @chocolatemilkdev/emitter
yarn add @chocolatemilkdev/emitter
bun add @chocolatemilkdev/emitter
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2024-02-03 |
| First published | 2023-11-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 38.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Davut Özgür Süküti |
| Maintainers | rexardev |
| Keywords | Emitter, Event, EventEmitter |

## Links

- npm: https://www.npmjs.com/package/@chocolatemilkdev/emitter
- Repository: https://github.com/Volgite/emitter
- Homepage: https://github.com/Volgite/emitter#readme
- Issues: https://github.com/Volgite/emitter/issues
- npm.io page: https://npm.io/package/@chocolatemilkdev/emitter

## 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

- 1.0.7 (latest) — 2024-02-03
- 1.0.6 — 2024-02-02
- 1.0.5 — 2024-02-02
- 1.0.4 — 2024-02-02
- 1.0.3 — 2024-01-25
- 1.0.2 — 2023-12-16
- 1.0.1 — 2023-11-18
- 1.0.0 — 2023-11-12

## README

# @chocolatemilkdev/emitter

a basic event emitter.

![Image](https://img.shields.io/npm/dt/@chocolatemilkdev/emitter.svg?color=%2351FC0&maxAge=3600)
![Image](https://img.shields.io/npm/v/@chocolatemilkdev/emitter?color=red&label=djs-extended-collectors)

### Features

- Builded on ESM, CJS and UMD.
- Type-Safe.
- Optimized.
- Basic Usage.

#### Note:

- ES6/ES2015 or newer required.

### 1.0.1

- bug fix

## Usage

```js
import ChocolateMilkEmitter from "@chocolatemilkdev/emitter";//ESM and TS
/**
 * const ChocolateMilkEmitter = require("@chocolatemilkdev/emitter").default
*/
const emitter = new ChocolateMilkEmitter()

emitter.on("a", (number) => {
    console.log(number)
})
emitter.once("b", (str) => {
    console.log(str)
})
emitter.onceAsync("b").then(([bool]) => {
    console.log(bool)
})

emitter.emit("a", 1)
emitter.emit("b", "b")
emitter.emit("c", true)

emitter.hasListener("a", (number) => {
    console.log(number)
})//true
emitter.isEmitted("a")//true
```

### Note: Typing Events
```ts
interface MyEvents{
    eat(food: string): any;
    drink(drink: string): string;
}

const emitter = new ChocolateMilkEmitter<MyEvents>()

emitter.on("eat", (food) => {
    console.log(food)
})
emitter.on("drink", (drink) => {
    return "a"
})

emitter.emit("eat", "kebap")//undefined
emitter.emit("drink", "water")//"a"
```

## Contact/Support

<a href="https://discord.com/users/586995957695119477">Discord</a>

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