1.2.3 • Published 4 years ago
utilizes.interval v1.2.3
interval
This function is like native setInterval, except its stopped when the given handler returns true or an error is accrue
Usage: interval(handler: (...args) => boolean, timeout?: number, ...args): number
import { interval } from 'utilizes.interval'
let counter = 0
interval(()=> ++counter === 5)
// stopped when the counter incremented to 5
// or you can stop it manually like you stop native setInterval function ->
const handle = interval(()=> {
++counter
if(counter === 5) clearInterval(handle)
})
// note: the interval is stopped when error is accrue ->
interval(()=>{
throw new Error()
})
// log error to the console once and the interval no longer exist
// you can stop this behavior by using trycatch ->
interval(()=>{
try{
throw new Error()
}catch(e){
console.error(e)
}
})
// this will not stop the interval process
This module exported from utilizes project.
1.2.3
4 years ago
1.2.2
6 years ago
1.2.1
6 years ago
1.2.0
6 years ago
1.1.10
6 years ago
1.1.9
6 years ago
1.1.8
6 years ago
1.1.6
6 years ago
1.1.4
6 years ago
1.1.3
6 years ago
1.1.2
6 years ago
1.1.1
6 years ago
1.1.0
6 years ago
1.0.11
6 years ago
1.0.6
6 years ago
1.0.4
7 years ago
1.0.3
7 years ago
1.0.2
7 years ago
1.0.1
7 years ago