Or do I have to use something along the lines of Web Workers or NodeJS Worker Threads? I would prefer it if I had an API similar to Python’s concurrent.futures. What I really want is apply a function to an array in parallel (i.e. some parallel version of .map)
Some ground info, Node has worker_threads for this purpose. <a href="https://nodejs.org/api/worker_threads.html" rel="nofollow">https://nodejs.org/api/worker_threads.html</a><p>I haven't had cause to use it yet, but I very much trust/respect the team behind: <a href="https://www.npmjs.com/package/piscina" rel="nofollow">https://www.npmjs.com/package/piscina</a> . It's so popular it has well maintained forks, such as tinypool, <a href="https://www.npmjs.com/package/tinypool" rel="nofollow">https://www.npmjs.com/package/tinypool</a> .<p>Also seeing good npm popularity metrics around: <a href="https://www.npmjs.com/package/synckit" rel="nofollow">https://www.npmjs.com/package/synckit</a>
We used piscina at it was quite good: <a href="https://github.com/piscinajs/piscina">https://github.com/piscinajs/piscina</a><p>While it may not provide parallel map out of the box it will help to implement it a little bit easier than using nodes api.
It is a single threaded runtime so to parallelize a map you will need to serialize the items and ship them to another node process. A bit like dask in Python.