Postman - a JavaScript message bus (github.com)
Postman is a JavaScript library & npm package which allows for cross-component messaging like traditional pub/ sub libraries but without the reqiurement on a message to be published after all the listeners are attached.
7 comments
[ 3.0 ms ] story [ 20.5 ms ] threadIt looks inefficient (uses arrays instead of linked lists/queues, so every cleanup requires full array rebuild), lacks any sort of message ordering guarantees (or notifications of lack thereof), lacks queue length limits (only time-based expiry and custom cleanup functions seeing only the value of message are provided) and so on.
Moreover, I don't get the following:
I believe msgs is an array (cache[name].history), but IIRC Array.reduce does not work like this, it's Array.filter that does.As for linked lists vs arrays I'm not convinced that a linked list would be a better performer than an array for iterative access (which is a rather crucial part of the library).
The reduce thing is a bug (I've chucked it on the issue register) as well as a feature request for only keeping a finite message limit.