//#region src/index.d.ts type Unit = 'years' | 'year' | 'yrs' | 'yr' | 'y' | 'months' | 'month' | 'mo' | 'weeks' | 'week' | 'w' | 'days' | 'day' | 'd' | 'hours' | 'hour' | 'hrs' | 'hr' | 'h' | 'minutes' | 'minute' | 'mins' | 'min' | 'm' | 'seconds' | 'second' | 'secs' | 'sec' | 's' | 'milliseconds' | 'millisecond' | 'msecs' | 'msec' | 'ms'; type UnitAnyCase = Unit | Uppercase | Capitalize; type StringValue = `${number}` | `${number}${UnitAnyCase}` | `${number} ${UnitAnyCase}`; type Options = { /** * Use verbose formatting (e.g., "1 second" instead of "1s"). * @default false */ long?: boolean; }; /** * Parse a human-readable time string into milliseconds. * * @param str - A time string such as "1s", "5m", "2h", "3d", etc. * @returns The number of milliseconds, or NaN if the string cannot be parsed. * @throws If the string is empty, not a string, or longer than 100 characters. * * @example * parse('1s'); // 1000 * parse('5m'); // 300000 * parse('2h'); // 7200000 * parse('3d'); // 259200000 * parse('1w'); // 604800000 * parse('1y'); // 31557600000 */ declare const parse: (str: StringValue) => number; /** * Format milliseconds into a human-readable time string. * * @param msValue - The number of milliseconds. * @param options - Formatting options. * @returns A formatted string like "1s", "5m", or "1 second" (if long format). * @throws If the value is not a finite number. * * @example * format(1000); // "1s" * format(60000); // "1m" * format(3600000); // "1h" * format(1000, { long: true }); // "1 second" * format(60000, { long: true }); // "1 minute" * format(120000, { long: true }); // "2 minutes" */ declare const format: (msValue: number, options?: Options) => string; /** * Convert between time durations and human-readable strings. * * - If a **string** is provided, it parses it into milliseconds. * - If a **number** is provided, it formats milliseconds into a string. * * @param value - A time string (e.g., "1s", "5m") or milliseconds number. * @param options - Formatting options (only used when value is a number). * @returns Milliseconds (if string input) or formatted string (if number input). * * @example * ms('1s'); // 1000 * ms('5m'); // 300000 * ms('2h'); // 7200000 * ms('1d'); // 86400000 * * @example * ms(1000); // "1s" * ms(60000); // "1m" * ms(3600000); // "1h" * ms(1000, { long: true }); // "1 second" * ms(60000, { long: true }); // "1 minute" */ declare function ms(value: StringValue, options?: Options): number; declare function ms(value: number, options?: Options): string; //#endregion export { StringValue, ms as default, format, parse };