Closed broofa closed 1 year ago
Hi @broofa,
this was quite intentional. In this project, I don't use polymorphism (if an argument can either be undefined or type X, then it is polymorphism). There are a few exceptions, but this is not likely to become one of them.
I don't use polymorphism
Any particular reason for that?
I ask because the signature for emit()
here is noticeably different from the defacto standard set by node
. It creates a rather unpleasant trap for unsuspecting developers.
JavaScript engines deoptimize polymorphic functions. I linked some articles in the README.
Obviously, this doesn't matter for .emit
. But I do regularly log deoptimized functions to find performance bottlenecks. Making more functions polymorphic (just for convenience) will make it harder for me to debug.
Fixes bug where calling
myObservable.emit('some-event')
(with no 2nd argument) throws a "TypeError: args is not iterable (cannot read property undefined)" error.