Home Reference Source Repository
import {Timer} from 'wyst/es6/utils/Time.js'
public class | source

Timer

used for making sure a code block runs within a certain amount of time

Static Method Summary

Static Public Methods
public static

create(config: Object): *

creates a new Timer

Constructor Summary

Public Constructor
public

constructor(config: Object)

constructor

Member Summary

Public Members
public

name: *

public

onEnd: *

public

runtime: *

public

Method Summary

Public Methods
public

begin(): *

convenience method to begin a Timer

public

cancel(): *

cancels a Timer so it will not throw

public

error(msg: <type>)

Throws a Timer Error

public

touch(): *

Restarts a Timer's clock

Static Public Methods

public static create(config: Object): * source

creates a new Timer

Params:

NameTypeAttributeDescription
config Object

The config object

config.name String

[__filename where Timer is created] The name of the Timer (for errors)

config.max_run_time Integer

[1 minute] The max run time in milliseconds

config.after Function

[Timer.prototype.error] The function to run after a Timer ends

Return:

*

Public Constructors

public constructor(config: Object) source

constructor

Params:

NameTypeAttributeDescription
config Object

The config

Public Members

public name: * source

public onEnd: * source

public runtime: * source

public touches: number source

Public Methods

public begin(): * source

convenience method to begin a Timer

Return:

*

this

public cancel(): * source

cancels a Timer so it will not throw

Return:

*

public error(msg: <type>) source

Throws a Timer Error

Params:

NameTypeAttributeDescription
msg <type>

The error message

public touch(): * source

Restarts a Timer's clock

Return:

*

this