s
s
snc
Search…
parallelLimit
snc.parallelLimit(number, Array_functions(done), callback_end(data))
Run limit of functions in parallel and then execute "callback_end". Alternative name : pl
1
snc.pl(2,
2
[
3
done => {
4
setTimeout(() => {
5
console.log(`go 1!`)
6
done(`a`)
7
}, 1000)
8
},
9
done => {
10
setTimeout(() => {
11
console.log(`go 2!`)
12
done(`b`)
13
}, 3000)
14
},
15
done => {
16
setTimeout(() => {
17
console.log(`go 3!`)
18
done(`c`)
19
}, 1000)
20
},
21
done => {
22
setTimeout(() => {
23
console.log(`go 4!`)
24
done(`a2`)
25
}, 3000)
26
},
27
done => {
28
setTimeout(() => {
29
console.log(`go 5!`)
30
done(`b2`)
31
}, 1000)
32
},
33
done => {
34
setTimeout(() => {
35
console.log(`go 6!`)
36
done(`c2`)
37
}, 3000)
38
},
39
done => {
40
setTimeout(() => {
41
console.log(`go 7!`)
42
done(`a3`)
43
}, 1000)
44
},
45
done => {
46
setTimeout(() => {
47
console.log(`go 8!`)
48
done(`b3`)
49
}, 3000)
50
},
51
done => {
52
setTimeout(() => {
53
console.log(`go 9!`)
54
done(`c3`)
55
}, 1000)
56
}
57
],
58
data => {
59
console.log(`we: ${JSON.stringify(data)}`)
60
})
Copied!
1
-> go 1!
2
-> go 3!
3
-> go 2!
4
-> go 5!
5
-> go 4!
6
-> go 7!
7
-> go 6!
8
-> go 9!
9
-> go 8!
10
-> we: ["a","b","c","a2","b2","c2","a3","b3","c3"]
Copied!
Copy link