-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
example.js
40 lines (33 loc) · 883 Bytes
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var parallel = require('./')({
// this is a function that will be called
// when a parallel completes
released: completed,
// we want results and errors
// passing false will make it faster!
results: true
})
parallel(
{}, // what will be this in the functions
[something, something, something], // functions to call
42, // the first argument of the functions
next // the function to be called when the parallel ends
)
function something (arg, cb) {
setImmediate(cb, null, 'myresult')
}
function next (err, results) {
if (err) {
// do something here!
}
console.log('parallel completed, results:', results)
parallel({}, something, [1, 2, 3], done)
}
function done (err, results) {
if (err) {
// do something here!
}
console.log('parallel completed, results:', results)
}
function completed () {
console.log('parallel completed!')
}