ee
is an experimental event emitter. It's not event published to npm. Don't use it.
const emitter = new EE();
// Use the emitter and be happy
#on(type, listener)
: Runlistener
whentype
event is emitted. Alias:#addListener
#off(type, listener)
: Stoplistener
to listeningtype
events. Alias:#removeListener
#once(type, listener)
: Runlistener
the first timetype
event is emitted then stop listening#onAny(listener)
: Runlistener
whenever an event is emitted#offAny(listener)
: Stoplistener
to whatever events#onceAny(listener)
: Runlistener
the first time some event is emitted then stop listening#offAll([type])
: Remove all listeners totype
events. If notype
is passed, remove alllisteners. Alias:
#removeAllListeners`#emit(type, payload)
: Emit atype
event withpayload
#emitAsync(type, payload, series = false)
: Emit atype
event withpayload
asyncly and return the promise. If series isfalse
, will run listeners withPromise.all
, otherwise will run the listeners in series creating a prototype chain and return it#listeners(type)
: Return all listeners directly listening totype
events. Listeners added with#onAny
or#onceAny
wil not be included#listenersAny()
: Return all listeners added with#onAny
or#onceAny
#pipe(otherEmitter[, namespace])
: Pipe all events tootherEmitter
. Ifnamespace
is passed,'<namespace>:'
will be prepended to event name emitted onotherEmitter
#unpipe(otherEmitter)
: Stop piping events tootherEmitter
.setPromise(promiseLibrary = Promise)
: Set internal promise library used on async operations. If nopromiseLibrary
is passed, will use default NodeJS promise implementation. This method should be called onEE
, not in an instance
EventEmitter (core) x 758,245 ops/sec ±2.46% (77 runs sampled)
EventEmitter2 x 723,897 ops/sec ±2.80% (78 runs sampled)
EventEmitter2 (wild-cards) x 734,017 ops/sec ±2.50% (72 runs sampled)
EventEmitter3 x 417,032 ops/sec ±1.63% (78 runs sampled)
EE x 378,016 ops/sec ±1.64% (76 runs sampled)
Fastest is EventEmitter (core)
* I'm gonna use that as a goal to improve my knowledge about V8 performance 😄
First of all install all dependencies with npm install
.
Just run npm test
.
Just run npm run benchmark
.