@rashedmakkouk/dev-utils
Version:
Utility library.
29 lines (28 loc) • 700 B
TypeScript
/** Typings */
import { MsOptions, TimeSpans } from '../types';
/**
* Time spans in seconds.
*/
export declare const TIME_SPANS: {
[timePeriod in TimeSpans]: number;
};
/**
* Parses a number representation or a string time period (e.g. 1h, 2d) to Unix
* Timestamp.
*
* - ms: millisecond.
* - s: second.
* - h: hour.
* - d: day.
* - w: week.
* - m: month.
* - y: year.
*
* @remarks
* If supplied 'span' is a number or a string representation of a number, value
* is returned as is bypassing conversion.
*
* @returns Time representation in milliseconds, else parses value as integer.
*/
declare function ms(span: string | number, options?: MsOptions): number;
export default ms;