typedtimer
v1.0.7
Published
Wrapper for setTimeout and setInterval
Downloads
71
Maintainers
Readme
typedtimer
EN: Typescript wrapper for setTimeout, setInterval, setImmediate, requestAnimationFrame
RU: Typescript обертка над setTimeout, setInterval, setImmediate, requestAnimationFrame
Installation
npm i typedtimer
Usage
import TypedTimer from 'typedtimer';
const timer = new TypedTimer();
// use as timeout
timer.setTimeout(()=>{
console.log('timeout!');
}, 5000);
// or as interval
timer.setInterval(()=>{
console.log('interval!');
}, 1000);
// or as immediate
timer.setImmediate(()=>{
console.log('immediate!');
});
timer.setAnimation(()=>{
console.log('animation!');
});
...
console.log('isActive:', timer.isActive());
...
// stop all
timer.clear();