@types/tocktimer
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

Installation

npm install --save @types/tocktimer

Summary

This package contains type definitions for tocktimer (https://github.com/mrchimp/tock).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/tocktimer.

index.d.ts

declare function t(opts?: t.TockOptions): t.Tock;

declare namespace t {
    interface TockOptions {
        /**
         * Defaults to 10 milliseconds. How often, in milliseconds, that the clock will tick.
         */
        interval?: number | undefined;

        /**
         * Defaults to false. If true, the clock will count down from a given time, otherwise it will count up from 0:00.
         */
        countdown?: boolean | undefined;

        /**
         * Callback function executed on each tick
         */
        callback(): void;

        /**
         * Callback function executed when the timer is complete
         */
        complete(): void;
    }

    class Tock {
        /**
         * Create a Tock instance
         */
        constructor(opts?: TockOptions);

        /**
         * Start the timer
         * @param time Can be either a countdown value or a starting value.
         * If a countdown timer then set time to count down from.
         * If a starting value then set time to the desired start time to count up from.
         */
        start: (time?: number) => void;

        /**
         * Stop the clock and clear the timeout
         */
        stop: () => void;

        /**
         * Stop the clock if it's running, continue clock if paused
         */
        pause: () => void;

        /**
         * Reset times to zero. Countdown clocks need a duration to be passed to start() after reset() is called.
         */
        reset: () => void;

        /**
         * Returns the elapsed time in milliseconds
         */
        lap: () => number;

        /**
         * Convert number of milliseconds to a MM:SS time string. Won't handle times greater than 1 hour
         */
        msToTime: (ms: number) => string;

        /**
         * Convert number of milliseconds to timecode string
         */
        msToTimecode: (ms: number, showMs?: boolean) => string;

        /**
         * Convert a time string to a number of milliseconds. Should be a duration as a string of form MM:SS, MM:SS:ms, MM:SS.ms, HH:MM:SS
         * Alternatively a time in the future can be provided using the form yyyy-mm-dd HH:MM:SS.ms. The difference between this time and present will be returned.
         * If the input cannot be recognized as one of the above then 0 is returned
         */
        timeToMS: (time: string) => number;
    }
}

export = t;

Additional Details

  • Last updated: Tue, 07 Nov 2023 15:11:36 GMT
  • Dependencies: none

Credits

These definitions were written by Evan Shortiss.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/tocktimer

Weekly Downloads

204

Version

1.0.5

License

MIT

Unpacked Size

7.34 kB

Total Files

5

Last publish

Collaborators

  • types