# eventmit

> One event per one event.

Latest version **3.0.6** (published 2025-09-06) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 65/100 (B)** — status: stable.

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.0.6 |
| Published | 2025-09-06 |
| First published | 2020-05-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 61 |
| Author | azu |
| Maintainers | azu |
| Keywords | events, eventemitter |

## Links

- npm: https://www.npmjs.com/package/eventmit
- Repository: https://github.com/azu/eventmit
- Issues: https://github.com/azu/eventmit/issues
- npm.io page: https://npm.io/package/eventmit

## Recent versions

- 3.0.6 (latest) — 2025-09-06
- 3.0.5 — 2025-08-16
- 3.0.4 — 2025-08-16
- 3.0.3 — 2025-08-03
- 3.0.2 — 2025-08-03
- 3.0.1 — 2025-08-03
- 3.0.0 — 2025-05-25
- 2.0.4 — 2023-01-15
- 2.0.3 — 2023-01-14
- 2.0.2 — 2023-01-14
- 2.0.1 — 2023-01-14
- 2.0.0 — 2023-01-14
- 1.1.0 — 2020-08-19
- 1.0.2 — 2020-05-30
- 1.0.1 — 2020-05-29
- … 1 more at https://npm.io/package/eventmit/versions

## README

# eventmit [![Actions Status](https://github.com/azu/eventmit/workflows/test/badge.svg)](https://github.com/azu/eventmit/actions?query=workflow%3A"test")

A single event object per an event.

## Feature

- A single event object per an event
- Tiny code base - less 1kb
- Written by TypeScript

## Install

Install with [npm](https://www.npmjs.com/):

    npm install eventmit

Requirement: ECMAScript 2015 because this library use [`Set`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set).

## Usage

Create an eventmit object and register handler and invoke handlers.

```ts
import { eventmit } from "eventmit";
const event = eventmit<{ key: string }>();
// Register handler
event.on((value) => {
    console.log(1, value);
});
event.on((value) => {
    console.log(2, value);
});
// Invoke handler
event.emit({
    key: "value"
});
// Unregister handler
event.offAll();
```

## API

```ts
export declare type EventmitHandler<T> = (value: T) => any;
export declare type Eventmitter<T> = {
    /**
     * Register an event handler
     */
    on: (handler: EventmitHandler<T>) => void;
    /**
     * Remove an event handler
     */
    off: (handler: EventmitHandler<T>) => void;
    /**
     * Remove all event handlers
     */
    offAll: () => void;
    /**
     * Invoke all handlers
     */
    emit: (value: T) => void;
};
export declare const eventmit: <T>() => Eventmitter<T>;
```

## ECMAScript Modules

You can import `eventmit` as ES Modules.

```js
import { eventmit } from "https://unpkg.com/eventmit?module";
const event = eventmit();
// Register handler
event.on((value) => {
    console.log(value);
});
// Invoke handler
event.emit("value");
```

It means that eventmit work on Browser and [Deno](https://deno.land/).

### Import at Deno
If you are using Deno, import `eventmit` from a URL.  
For example, using a CDN:

```typescript
import { eventmit } from "https://cdn.skypack.dev/eventmit?dts";
```

## Changelog

See [Releases page](https://github.com/azu/eventmit/releases).

## Running tests

Install devDependencies and Run `npm test`:

    npm test

## Contributing

Pull requests and stars are always welcome.

For bugs and feature requests, [please create an issue](https://github.com/azu/eventmit/issues).

1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D

## Author

- [github/azu](https://github.com/azu)
- [twitter/azu_re](https://twitter.com/azu_re)

## License

MIT © azu

## Related

- [developit/mitt: 🥊 Tiny 200 byte functional event emitter / pubsub.](https://github.com/developit/mitt)
    - Support multiple event type

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