Constructor
new Timer(clockopt, global)
Returns a new Timer
.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
clock |
Clock |
<optional> |
The clock to use. |
global |
globalThis | The global object. |
Members
_queue :Array.<TimerTask>
Type:
- Array.<TimerTask>
Methods
cancel()
Cancels all scheduled tasks.
purge() → {number}
Removes all cancelled tasks from the task queue.
Returns:
The number of tasks removed from the task queue.
- Type
- number
schedule(task, delayOrTime, periodopt)
Schedules a task for repeated execution at regular intervals.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
task |
TimerTask | The task to execute. |
||
delayOrTime |
number | Date | The delay before the first execution, in milliseconds or the time of the first execution. |
||
period |
number |
<optional> |
0 | The interval between executions, in milliseconds; 0 means single execution. |
scheduleAtFixedRate(task, delayOrTime, period)
Schedule a task for repeated fixed-rate execution.
Parameters:
Name | Type | Description |
---|---|---|
task |
TimerTask | The task to execute. |
delayOrTime |
number | Date | The delay before the first execution, in milliseconds or the time of the first. |
period |
number | The interval between executions, in milliseconds. |
simulateTaskExecution(options)
Simulates the execution of a task.
Parameters:
Name | Type | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | The simulation options. Properties
|
(static) create()
Returns a new Timer
.
(static) createNull()
Returns a new Timer
for testing without side effects.