Options
All
  • Public
  • Public/Protected
  • All
Menu

Stopwatch

Hierarchy

  • default

Index

Constructors

  • description

    Stopwatch constructor

    example
    // create instance
    const stopwatch = new Stopwatch();

    Returns default

Properties

AlarmType: typeof default = AlarmType
description

Stopwatch alarm type.

Degree: typeof default = Degree
description

A utility object associated with degree.

Event: any = StopwatchEvent
description

Stopwath event type.

Methods

  • clearAlarm(): boolean
  • description

    All set alarms are cleared.

    example
    // All set alarms are cleared.
    stopwatch.clearAlarm();

    Returns boolean

    Whether to run

  • destroy(): boolean
  • description

    Destroys the stopwatch object. This means exempt from management, removing references to internal data that we manage internally. t loses its function as a stopwatch.

    example
    // object destruction
    stopwatch.destroy();

    Returns boolean

    Whether to run

  • get(): number
  • description

    Get the elapsed time.

    example
    // Get the elapsed time.
    const time = stopwatch.get();

    Returns number

    elapsed time

  • getAlarms(): number[]
  • description

    Get the set alarm list.

    example
    // Get the set alarm list.
    const alarms = stopwatch.getAlarms();

    Returns number[]

    alarm list

  • off(eventName?: string, callback?: Function): boolean
  • description

    Remove the event callback.

    example
    // Remove all callbacks for a specific event
    stopwatch.off( "alarm" );
    example
    // Remove specific callbacks for specific events
    stopwatch.off( "alarm", alarmListener );

    Parameters

    • Optional eventName: string

      Event to delete callback

    • Optional callback: Function

      callback to delete

    Returns boolean

    Whether to run

  • on(eventName: string, callback: Function): boolean
  • description

    Register event callbacks.

    example
    // It is executed when the time is updated.
    stopwatch.on( "update", ( ms ) => {

    const seconds = ms / 1000;
    console.log( seconds.toFixed( 3 ) );

    } );

    Parameters

    • eventName: string

      Events to register for callbacks

    • callback: Function

      A callback to be executed when an event occurs

    Returns boolean

    Whether to run

  • pause(): boolean
  • description

    Pause the stopwatch.

    example
    // Pause the stopwatch.
    stopwatch.pause();

    Returns boolean

    Whether to run

  • reset(): boolean
  • description

    Reset the stopwatch.

    example
    // Reset the stopwatch.
    stopwatch.reset();

    Returns boolean

    Whether to run

  • setAlarm(alarmTime: number, alarmType?: default): boolean
  • description

    Set an alarm. When the alarm time comes, the stopwatch triggers an alarm event.

    example
    // Set an alarm. ( Default alarm type: Stopwatch.AlarmType.ABSOLUTE )
    stopwatch.setAlarm( 3000 );
    example
    // Set an alarm.
    stopwatch.setAlarm( 3000, Stopwatch.AlarmType.RELATIVE );

    Parameters

    • alarmTime: number

      Alarm time ( unit: ms )

    • alarmType: default = Stopwatch.AlarmType.ABSOLUTE

    Returns boolean

    Whether to run

  • start(): boolean
  • description

    Start the stopwatch.

    example
    // Start the stopwatch.
    stopwatch.start();

    Returns boolean

    Whether to run

  • stop(): boolean
  • description

    Stop the stopwatch.

    example
    // Stop the stopwatch.
    stopwatch.stop();

    Returns boolean

    Whether to run

Generated using TypeDoc