Simple parallelization for EcmaScript
npm install parallel-esA JavaScript library to perform parallel JavaScript computations with ease (and other environments soon).
``sh`
npm install --save parallel-es
or yarn:
`sh`
yarn add parallel-es
Performing a single computation in a background thread is as simple as calling a normal method:
`js
import parallel from "parallel-es";
parallel.run(function () {
//… compute
return [1, 2, 3];
}).then(result => console.log(result));
`
Or use the reactive API to parallelize data stream based operations. The reactive API automatically splits the input array into sub-arrays, computes the sub-results in a web worker, and joins the resulting arrays:
`js`
parallel.range(0, 100000)
.map(value => value * value)
.then(result => console.log(result));
To show a progress update, use the subscribe method to register a callback that is invoked whenever a sub-result has been computed:
`jsThe result of the task ${taskIndex} is
parallel.range(0, 100000)
.map(value => value * value)
.subscribe((subresult, taskIndex) => console.log(, subresult);)`
.then(result => console.log(result));
For more detail, take a look at the API Documentation.
|
IE / Edge |
Firefox |
Chrome |
Safari |
Opera |
iOS Safari |
Android |
| --------- | --------- | --------- | --------- | --------- | --------- | --------- |
| IE10, IE11, Edge| last 2 versions| last 2 versions| last 2 versions| last 2 versions| iOS 5.1, iOS 6, iOS 7, iOS 8, iOS 9| Chrome, Android 4.4
Automated browser testing is performed using BrowserStack's open source offer.
