fortimer
Manage your JavaScript timer.
Install
npm i fortimer //or yarn add fortimer
Usage
import Timer from 'fortimer'
let timer = new Timer()
timer.add({
name: 'test',
repeat: true,
func: () => {
console.log(new Date())
}
})
-
add(obj = {})
- {Object} config
- {String} name: timer name
- {Boolean} repeat: default
false
,true
for setInterval(),false
for setTimeout() - {Number} duration: timer duraion,default
1000
ms
timer.add({ name: 'test', repeat: true, duration: 10e3, func: ()=>{ console.log(new Date()) } }); // return timer
- {Object} config
-
getAll()
timer.getAll();
-
remove(name)
- {String} name: timer name
timer.remove('test');
-
removeAll()
timer.removeAll();