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