Skip to content

Commit 2ae2195

Browse files
committed
update readme to add ideal api
1 parent 998bf71 commit 2ae2195

File tree

4 files changed

+2411
-70
lines changed

4 files changed

+2411
-70
lines changed

README.md

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,42 @@
11
# Parallel.js
22

3+
[![Build Status](https://travis-ci.org/parallel-js/parallel.js.svg?branch=master)](https://travis-ci.org/parallel-js/parallel.js)
4+
5+
## Idea
6+
7+
```js
8+
import { Jobs, ParallelArray } from 'paralleljs';
9+
10+
// Execute multiple jobs in parallel and asynchrnously
11+
const jobs = new Jobs();
12+
const [job1, job2, job3] = await jobs.all([
13+
() => fibonacci(1),
14+
gaussianSumm,
15+
foobar
16+
]);
17+
console.log(job1, job2, job3);
18+
19+
// An array with all methods parallelized
20+
const array = new ParallelArray([1, 2, 3]);
21+
array.push(1);
22+
array.map(e => e + 1);
23+
array.filter(e => !!e);
24+
```
25+
26+
## Local Development
27+
28+
```bash
29+
git clone https://github.com/parallel-js/parallel.js
30+
cd parallel.js
31+
yarn
32+
yarn test
33+
```
34+
335
## Contributors
436

537
Parallel.js is made up of four contributors:
638

7-
[Adam Savitzky (Adam)](https://github.com/adambom)
8-
[Mathias Rangel Wulff (Mathias)](https://github.com/mathiasrw)
9-
[Amila Welihinda (amilajack)](https://github.com/amilajack)
10-
[MaXwell Falstein (MaX)](https://github.com/MaXwellFalstein)
39+
* [Adam Savitzky (Adam)](https://github.com/adambom)
40+
* [Mathias Rangel Wulff (Mathias)](https://github.com/mathiasrw)
41+
* [Amila Welihinda (amilajack)](https://github.com/amilajack)
42+
* [MaXwell Falstein (MaX)](https://github.com/MaXwellFalstein)

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"babel-core": "^7.0.0-0",
4040
"babel-jest": "^23.6.0",
4141
"eslint": "^5.9.0",
42-
"eslint-config-bliss": "^3.1.1"
42+
"eslint-config-bliss": "^3.1.1",
43+
"jest": "^23.6.0"
4344
},
4445
"eslintConfig": {
4546
"extends": [

test/basic.spec.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,34 @@
1-
const Parallel = require('..');
1+
const { ParallelArray, Jobs } = require('..');
2+
3+
const fibonacci = () => {};
4+
const gaussianSumm = () => {};
5+
const foobar = () => {};
26

37
describe('basic', () => {
48
it('should construct object', () => {
5-
new Parallel([]);
6-
new Parallel();
9+
new ParallelArray([]);
10+
new ParallelArray();
711
});
812

913
it('should take expected arguments', () => {
10-
const array = new Parallel();
14+
const array = new ParallelArray();
1115
array.push(1);
1216
array.push(2);
1317
});
1418

1519
it('should call parallel methods', () => {
16-
const array = new Parallel();
20+
const array = new ParallelArray();
1721
array.map(e => e + 1);
1822
array.filter(e => !!e);
1923
});
24+
25+
it('should call execute jobs in parallel', async () => {
26+
const jobs = new Jobs();
27+
const [job1, job2, job3] = await jobs.all([
28+
() => fibonacci(1),
29+
gaussianSumm,
30+
foobar
31+
]);
32+
console.log(job1, job2, job3);
33+
});
2034
});

0 commit comments

Comments
 (0)