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(); // unsets 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