Parawait is a JavaScript library for achieving concurrency and parallelism using promises. On single-core processors, the processes are run concurrently. On multi-core processors, the processes are run in parallel.
JavaScript provides native ways of running multiple processes at once. These include Promise.all
, Promise.race
, Promise.any
and Promise.allSettled
. The similarity between Parawait and the aforementioned methods is that they all use promises. However, there are a few significant differences between these methods and Parawait in terms of how they differ in terms of how they run the processes. Let us look at the features of Parawait.
All of the JavaScript native methods take an array of promises as the parameter. However, Parawait does not use an array of promises. This makes it more memory efficient.
The functions you want to run at once do not have to be asynchronous. Parawait wraps all functions in promises on your behalf.
Parawait gives you the choice to choose how errors should be handled. You can choose whether or not the promise should be rejected. You can also choose whether or not the promised should resolve with an output.
Running so many processes at once uses a lot of memory. This might also stand in the way of other processes. Sometimes, this results into errors as there is a limit to the call stack. Parawait allows you to run processes in chunks.
Refer to our Quick Start Guide for a quick introduction to how Parawait works.
Refer to our Documentation for an in-depth look at Parawait.
This library is under the MIT Licence.
Copyright (c) 2021, Mishieck Mwale.