batching tasks
I'm calling an api and get an array of 2000+ items. I want to chunk these into batches of 100 and then process them all concurrently.
I've tried
BatchQueue
but it looks like it stops after processing only the first batch.
What's the best way to do this preferably without third party modules?10 Replies
Something like this (untested):
I wrote a library to do this kind of thing because I wasn't a fan of the ones I found.
https://jsr.io/@nfnitloop/better-iterators
https://jsr.io/@nfnitloop/better-iterators
JSR
@nfnitloop/better-iterators - JSR
@nfnitloop/better-iterators on JSR: Chainable iterators (sync and async) for TypeScript, with support for opt-in, bounded parallelism
So that would be something like:
this is awesome
Thanks! If you end up using it, let me know! Feel free to add issues to request new features you mind find helpful.
I migrated the project to bun due to Deno’s comparibility issues with Convex. I will probably end up using it sometime down the road though
Oh. Did you open an issue about convex compatibility? The Deno team seems keen to make sure node compatibility works so it’s not a blocker to adopting Deno.
Many things don't work, including SvelteKit. Which is why almost every project I tried to build with Deno was inevitably migrated to Bun at one point or another.
Community and adoption are also severely lagging. Deno is great but it's still a litte early. Give it another year or two.
Ah. Yeah I wasn’t happy with sveltekit support either. But I decided to abandon it rather than deno. 😆
I struggle to see how sticking with Deno over Bun or even Node would bring you any tangible benefits—at least not on the same level as choosing Svelte over React, for example. I can’t quite get behind that decision, but to each their own.