- Only 152 bytes (minified and gzipped). It uses Size Limit to control size.
- The
on
method returns theunbind
function. You don’t need to save a callback to a variable forremoveListener
. - TypeScript and ES modules support.
- No aliases, just
emit
andon
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