constmitt=require('mitt');constemitter=mitt()// listen to an eventemitter.on('foo',e=>console.log('foo',e))// listen to all eventsemitter.on('*',(type,e)=>console.log(type,e))// fire an eventemitter.emit('foo',{a:'b'})// working with handler references:functiononFoo(){}emitter.on('foo',onFoo)// listenemitter.off('foo',onFoo)// unlisten