[ Mini Kiebo ]
Server: Windows NT AKFAR_SERVER 10.0 build 26200 (Windows 10) AMD64
Path:
D:
/
xampp
/
htdocs
/
sisurat
/
public
/
library
/
sweetalert2
/
src
/
utils
/
[
Home
]
File: Timer.js
export default class Timer { constructor (callback, delay) { this.callback = callback this.remaining = delay this.running = false this.start() } start () { if (!this.running) { this.running = true this.started = new Date() this.id = setTimeout(this.callback, this.remaining) } return this.remaining } stop () { if (this.running) { this.running = false clearTimeout(this.id) this.remaining -= new Date() - this.started } return this.remaining } increase (n) { const running = this.running if (running) { this.stop() } this.remaining += n if (running) { this.start() } return this.remaining } getTimerLeft () { if (this.running) { this.stop() this.start() } return this.remaining } isRunning () { return this.running } }