# emitter-tiny

> a tiny event libary

Latest version **1.0.0** (published 2021-12-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install emitter-tiny
pnpm add emitter-tiny
yarn add emitter-tiny
bun add emitter-tiny
```

## Health

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

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2021-12-26 |
| First published | 2021-12-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 10.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | zhao-huo-long |
| Keywords | event, emitter, emit, emitter-tiny, tiny, 事件总线, 事件, 触发器 |

## Links

- npm: https://www.npmjs.com/package/emitter-tiny
- Repository: https://github.com/zhao-huo-long/emitter-tiny
- Homepage: https://github.com/zhao-huo-long/emitter-tiny#readme
- Issues: https://github.com/zhao-huo-long/emitter-tiny/issues
- npm.io page: https://npm.io/package/emitter-tiny

## Dependencies (1)

- [assert-tiny](https://npm.io/package/assert-tiny.md) ^1.0.0

## 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.0 (latest) — 2021-12-26

## README

# emitter-tiny
a event emitter, very tiny. 一个非常轻量的事件触发器

#### install
npm or yarn
```shell
npm install emitter-tiny

yarn add emitter-tiny
```

#### on & emit
```ts
import event from 'emitter-tiny'
const e = new event()
e.on('event-name', (v) => {
  console.log(v)
})
e.emit('event-name', { eventVal: 'hello' })
```

#### once
event handler only emit once. 事件处理函数只会触发一次.
```ts
import event from 'emitter-tiny'
const e = new event()
e.once('event-name', (v) => {
  console.log(v)
})
e.emit('event-name', { eventVal: 'hello' }) /*  will emit handler  */
e.emit('event-name', { eventVal: 'hello' }) /*  don't emit handler  */
e.emit('event-name', { eventVal: 'hello' }) /*  don't emit handler  */
```

#### off
cancel event handler. 取消事件处理函数
```ts
import event from 'emitter-tiny'
const e = new event()
const cb = (v) => {
  console.log(v)
}
e.on('event-name', cb)
e.off('event-name', cb)
e.emit('event-name', { eventVal: 'hello' }) /* dont emit handler  */
```

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