-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
051ccf9
commit 0dad0c0
Showing
6 changed files
with
103 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
let timer: NodeJS.Timeout | ||
|
||
let sec = 0 | ||
let active = false | ||
|
||
function startTimer(callback?: () => void) { | ||
active = true | ||
|
||
timer = setInterval(() => { | ||
sec++ | ||
callback?.() | ||
}, 1000) | ||
} | ||
|
||
function stopTimer() { | ||
clearInterval(timer) | ||
sec = 0 | ||
active = false | ||
} | ||
|
||
function getTime() { | ||
return sec | ||
} | ||
|
||
function isTimerActive() { | ||
return active | ||
} | ||
|
||
export { getTime, isTimerActive, startTimer, stopTimer } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters