nanoevents

Simple and tiny (107 bytes) event emitter library

MIT 44 个版本
安装
npm install nanoevents
yarn add nanoevents
pnpm add nanoevents
bun add nanoevents
README

Nano Events

Simple and tiny event emitter library for JavaScript.

  • Only 108 bytes (minified and brotlied). It uses Size Limit to control size.
  • The on method returns unbind function. You don’t need to save callback to variable for removeListener.
  • TypeScript and ES modules support.
  • No aliases, just emit and on methods. No Node.js EventEmitter compatibility.
import { createNanoEvents } from 'nanoevents'

const emitter = createNanoEvents()

const unbind = emitter.on('tick', volume => {
  summary += volume
})

emitter.emit('tick', 2)
summary //=> 2

unbind()
emitter.emit('tick', 2)
summary //=> 2

  Made at Evil Martians, product consulting for developer tools.


Docs

Read full docs here.

版本列表
9.1.0 2024-10-14
9.0.0 2023-11-23
8.0.0 2023-07-01
7.0.1 2022-06-16
7.0.0 2022-06-16
6.0.2 2021-10-17
6.0.1 2021-09-04
6.0.0 2021-04-24
5.1.13 2021-03-15
5.1.12 2021-03-03
5.1.11 2021-02-16
5.1.10 2020-10-23
5.1.9 2020-10-23
5.1.8 2020-06-13
5.1.7 2020-05-12
5.1.6 2020-05-11
5.1.5 2020-03-23
5.1.4 2020-03-23
5.1.3 2020-03-22
5.1.2 2020-03-21
5.1.1 2020-03-21
5.1.0 2020-03-17
5.0.1 2020-03-08
5.0.0 2020-03-07
4.0.3 2020-02-25
4.0.2 2020-02-24
4.0.1 2020-02-22
4.0.0 2020-02-21
3.0.0 2020-02-20
2.0.0 2019-05-26
1.0.8 2018-10-30
1.0.7 2018-10-25
1.0.6 2018-10-19
1.0.5 2018-07-18
1.0.4 2018-06-22
1.0.3 2018-06-04
1.0.2 2017-09-21
1.0.1 2017-09-20
1.0.0 2017-09-18
0.4.1 2017-09-12
0.4.0 2017-09-10
0.3.0 2016-11-21
0.2.0 2016-09-22
0.1.0 2016-09-22