UNPKG

@dbpiper/timer

Version:

Simple module to time your code JavaScript or TypeScript code, to see how long it took to run.

50 lines (49 loc) 1.78 kB
import moment from 'moment'; export declare type Duration = number | moment.Duration; /** * Represents a duration, however each unit is treated as the remainder * starting from the largest possible one. In other words, it is setup * just like how a person would say how much time has passed. * * Rounds all numbers to two decimal places as the main intended purpose is for * printing output rather than internal programmatic use. * * @class FormattedDuration */ declare class FormattedDuration { /** * Gets the amount of milliseconds in the duration rounded to the number * of digits provided by precision. */ readonly milliseconds: number; private static getUnitAndAmount; private static nonMsUnitAndAmounts; /** * Gets the amount of seconds in the duration rounded to the number * of digits provided by precision. */ readonly seconds: number; /** * Gets the amount of minutes in the duration rounded to the number * of digits provided by precision. */ readonly minutes: number; /** * Gets the amount of hours in the duration rounded to the number * of digits provided by precision. Since hours is the largest unit * that FormattedDuration supports, anything larger than an hour will * simply be in this function. For example: the information that * the duration is 5 days long would be found here as: 120 hours. */ readonly hours: number; private static _pluralizeIfNeeded; private static _isNumber; private static _roundNumber; private _duration; constructor(duration: Duration); toString(): string; private getNonEmptyUnitAndAmounts; private stringifyUnits; private _stringifyAmounts; } export default FormattedDuration;