Constructor
new Timer(timeLeftopt)
Create a timer object set time passed in
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
timeLeft | number | <optional> | How much time left before the timer elapses in seconds |
- Source
Example
let a = new Timer; // creates a timer that is not set
a.set(3); // sets the timer to 3 seconds
let b = new Timer(1); // creates a timer with 1 second left
b.unset(); // unset the timer
Methods
active() → {boolean}
Returns true if set and has not elapsed
- Source
Returns:
- Type:
- boolean
elapsed() → {boolean}
Returns true if set and elapsed
- Source
Returns:
- Type:
- boolean
get() → {number}
Get how long since elapsed, returns 0 if not set (returns negative if currently active)
- Source
Returns:
- Type:
- number
getPercent() → {number}
Get percentage elapsed based on time it was set to, returns 0 if not set
- Source
Returns:
- Type:
- number
isSet() → {boolean}
Returns true if set
- Source
Returns:
- Type:
- boolean
set(timeLeftopt)
Set the timer with seconds passed in
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
timeLeft | number | <optional> | 0 | How much time left before the timer is elapsed in seconds |
- Source
toString() → {string}
Returns this timer expressed as a string
- Source
Returns:
- Type:
- string
unset()
Unset the timer
- Source
valueOf() → {number}
Get how long since elapsed, returns 0 if not set (returns negative if currently active)
- Source
Returns:
- Type:
- number