You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're currently relying on @algolia/events (a fork of events to ensure the node version isn't taken), but it's a little large (8kb uncompressed) due to its large api surface and it not being builtin. I can see a couple ideas:
no longer inherit from EventEmitter (breaking change)
simplify largely what's inside EventEmitter (breaking change, not if it's not inherited)
what could be inside
functionEventEmitter(){this._events=this._events||{};}module.exports=EventEmitter;EventEmitter.prototype._events={};EventEmitter.prototype.emit=function(type){varer,handler,len,args,i,listeners;// If there is no 'error' event listener then throw.if(type==='error'){if(!this._events.error||(this._events.error&&!this._events.error.length)){er=arguments[1];if(erinstanceofError){thrower;// Unhandled 'error' event}else{// At least give some kind of context to the uservarerr=newError('Uncaught, unspecified "error" event. ('+er+')');err.context=er;throwerr;}}}handler=this._events[type];if(!handler)returnfalse;args=Array.prototype.slice.call(arguments,1);listeners=handler.slice();len=listeners.length;for(i=0;i<len;i++)listeners[i].apply(this,args);returntrue;};EventEmitter.prototype.addListener=function(type,listener){if(!this._events[type])this._events[type]=[listener];// If we've already got an array, just append.elsethis._events[type].push(listener);returnthis;};EventEmitter.prototype.on=EventEmitter.prototype.addListener;EventEmitter.prototype.removeListener=function(type,listener){this._events[type]=this._events[type].filter(function(l){returnl!==listener;});returnthis;};EventEmitter.prototype.removeAllListeners=function(){this._events={};returnthis;};
use the builtin EventTarget (breaking change)
node now also supports EventTarget, meaning we wouldn't need a dependency for this anymore? needs to be investigated!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
We're currently relying on
@algolia/events
(a fork ofevents
to ensure the node version isn't taken), but it's a little large (8kb uncompressed) due to its large api surface and it not being builtin. I can see a couple ideas:what could be inside
Beta Was this translation helpful? Give feedback.
All reactions