First off, promises won't help you make code run in parallel. They are a tool for running other code when your task is done or coordinating this task with other tasks. But making your current code run in parallel with other code has nothing to do with promises.
Second off, there's little advantage (and a lot of complication) to taking a synchronous task and trying to make it work more like an asynchronous tasks unless it is so long running that it interferes with the responsiveness of other operations. Computing a set of random numbers is unlikely to be that long a running task.
If you truly want parallel execution in a browser, you would have go use WebWorkers which is the only way to create an truly independent execution thread in browser-based javascript. Other than WebWorkers, javascript in a browser is single threaded so there is no parallel execution. It is possible to execute small chunks of code on successive setTimeout() calls which will interweave your code execution with other things going on in the browser and can allow other browser tasks to remain responsive while running another long running task.
You can see an example of processing a large array in chunks using setTimeout() here Best way to iterate over an array without blocking the UI to allow other things to run in between chunks of processing. Promises could be added to something like this as a method of managing the completion of the task or managing its coordination with other tasks, but promises don't actually help you make it work in chunks.
setTimeout()to schedule consecutive chunks of execution or usewebWorkersto actually set up another thread. You can see the core mechanism here for executing chunks of work withsetTimeout()which could then just return a promise and then resolve that promise when the work was done.setTimeout(fn,0)to force asynchonity.Bluebirdpromises and want to run 30 queries (let's say i have Redis, Postgres and S3 subsystems - and i need to run 10 queries in each). All queries are independent, and instead of waiting forT1 + T2 + .. + T30seconds, i want to wait formax(T1, T2 .., T30) + small_overhead_of_parallelism. So how can I achieve something like this with Bluebird API the most elegant way?