s
s
snc
Search…
times
snc.times(number_times, callback_loop(index, next, end), callback_end(data))
Iterates function "number" times.
1
snc.times(5, (index, next, end) => {
2
console.log(`iterator: ${index}`)
3
setTimeout(() => {
4
if (index === 3) end()
5
else next()
6
}, index*1000);
7
},
8
() => {
9
console.log(`End!`)
10
})
Copied!
1
-> Iterator 0
2
-> Iterator 1
3
-> Iterator 2
4
-> Iterator 3
5
-> End!
Copied!
1
snc.times(5, (index, next, end) => {
2
console.log(`iterator: ${index}`)
3
setTimeout(() => {
4
next()
5
}, 1000);
6
},
7
() => {
8
console.log(`End!`)
9
})
Copied!
1
-> Iterator 0
2
-> Iterator 1
3
-> Iterator 2
4
-> Iterator 3
5
-> Iterator 4
6
-> End!
Copied!
Copy link