If I'm not mistaken, you are looking for something like multithreading and / or computing several things at once.
Multiple execution at once
SIMD begins to search its way in browsers, and the Node implementation is not far behind. Take a look at node-simd or MDN SIMD (browsers) . SIMD is still experimental and only works on supported processors at the moment (obviously, since not all processors have this functionality). It performs several actions at once, an example of comparing regular JS with SIMD JS is:
Multithreading
As for multithreading, webworkers already exist in the browser environment. This has been ported to Node in full compliance with the HTML specification, as shown in this repository .
Here's a good explanation as to why webworkers were even ported to Node, primarily because you can already run child processes on other threads and other processors with the child_process module. node-webworker is a great module, as each process runs inside its context and in its own node process, so it is really multithreaded with node.
So, in order to start different processes on different processors, you must either accept node-webworker or use child_process to create other threads to simultaneously perform separate actions with different CPU cores. node-webworker can listen for events using the familiar postMessage API, and child_process will communicate through stdin / stdout / stderr .
Hope that answers your question :)
source share