UNPKG

hd-utils

Version:

A handy utils for modern JS developers

26 lines (25 loc) 682 B
/** * @see https://stackoverflow.com/questions/29971898/how-to-create-an-accurate-timer-in-javascript * @class Timer * @description Creates a timer so it calculates the time between start and end, so you can * check time in ms. * @example ` * const timer = new Timer(initialStartTimer (optional)); * timer.start(); * //after 1 second * timer.stop(); * console.log(timer.getTime()) // 1000 * * ` */ export default class Timer { isRunning: boolean; private startTime; private overallTime; constructor(initialStartTime?: number); _getTimeElapsedSinceLastStart(): number; start(): void; stop(): void; reset(): void; getTime(): number; }