Show HN: Qew – a tiny queueing library written in TypeScript
github.com
github.com
Countless times I have wanted endpoints to send data at certain intervals via ws/http/etc and the have the node app upload them somewhere else in an orderly queue but that doesn’t really seem possible. But with this library or similar you can.
It just seems like a common use case that isn’t implemented natively.
[1]: https://github.com/tc39/proposals/blob/master/stage-1-propos...
[2]: https://github.com/tc39/proposal-iterator-helpers
[3]: https://github.com/tc39/notes/blob/master/meetings/2019-06/j...
I've spent a lot of time trying to add tests but ran into a ton of problems trying to get Jest's useFakeTimers and promises to play well together. I will take another crack at to see if I can work around the problems this time.
Not sure I understand what you mean by returning the promise directly?
Could you explain a bit more why using sets or linked lists would help with efficiency here?
Thanks I'll check out your playlist!
Qew on the other hand has a much simpler API: you instantiate a queue with the max concurrency and delay set right in the constructor and then all you need to do is push async functions onto it and forget about them.
The queue will take care of limiting concurrency and executing the next function when the first one has completed.
You can use the same queue for your entire application or instantiate different queues for different REST API endpoints for example; setting the max concurrency and required delay between requests for each API depending on their individual rate limits.
FYI that SO answer is outdated and does a superset of what’s involved in OPs lib. All you need is defer and mergeMap really at least with rxJs v6+