Skip to content

Commit 2c0d963

Browse files
committed
Formatting
1 parent 546849f commit 2c0d963

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ var p = new Parallel([1, 2, 3, 4, 5]);
4242
console.log(p.data); // prints [1, 2, 3, 4, 5]
4343
```
4444

45+
*******
46+
4547
#### `spawn(fn)`
4648
This function will spawn a new process on a worker thread. Pass it the function you want to call. Your
4749
function will receive one argument, which is the current data. The value returned from your spawned function will
@@ -66,6 +68,8 @@ p.spawn(function (data) {
6668
});
6769
```
6870

71+
*******
72+
6973
#### `map(fn)`
7074
Map will apply the supplied function to every element in the wrapped data. Parallel will spawn one worker for
7175
each array element in the data, or the supplied maxWorkers argument. The values returned will be stored for
@@ -91,6 +95,8 @@ p.map(fib).then(log)
9195
// Logs the first 7 Fibonnaci numbers, woot!
9296
```
9397

98+
*******
99+
94100
#### `reduce(fn)`
95101
Reduce applies an operation to every member of the wrapped data, and returns a scalar value produced by the operation.
96102
Use it for combining the results of a map operation, by summing numbers for example. This takes a reducing function,
@@ -113,6 +119,8 @@ p.require(factorial)
113119
p.map(function (n) { return Math.pow(10, n); }).reduce(add).then(log);
114120
```
115121

122+
*******
123+
116124
#### `then(success, fail)`
117125
The functions given to `then` are called after the last requested operation has finished.
118126
`success` receives the resulting data object, while `fail` will receive an error object.
@@ -135,6 +143,8 @@ p.map(dbl).map(dbl).map(dbl).then(function (data) {
135143
p.map(function (n) { return Math.pow(10, n); }).reduce(add).then(log);
136144
```
137145

146+
*******
147+
138148
#### `require(state)`
139149
If you have state that you want to share between your main thread and the worker threads, this is how. Require
140150
takes either a string or a function. A string should point to a file name.

0 commit comments

Comments
 (0)