Timer#

Timer object tracks how long has passed since it was set

Constructor#

new Timer(timeLeftopt)#

Create a timer object set time passed in

Parameters:
NameTypeAttributesDescription
timeLeftNumber<optional>

How much time left before the timer elapses in seconds

Example
CODE
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

Returns:
Type: 
Boolean

elapsed() → {Boolean}#

Returns true if set and elapsed

Returns:
Type: 
Boolean

get() → {Number}#

Get how long since elapsed, returns 0 if not set (returns negative if currently active)

Returns:
Type: 
Number

getPercent() → {Number}#

Get percentage elapsed based on time it was set to, returns 0 if not set

Returns:
Type: 
Number

isSet() → {Boolean}#

Returns true if set

Returns:
Type: 
Boolean

set(timeLeftopt)#

Set the timer with seconds passed in

Parameters:
NameTypeAttributesDefaultDescription
timeLeftNumber<optional>
0

How much time left before the timer is elapsed in seconds

toString() → {String}#

Returns this timer expressed as a string

Returns:
Type: 
String

unset()#

Unset the timer

valueOf() → {Number}#

Get how long since elapsed, returns 0 if not set (returns negative if currently active)

Returns:
Type: 
Number