UNPKG

nhb-toolbox

Version:

A versatile collection of smart, efficient, and reusable utility functions, classes and types for everyday development needs.

15 lines (14 loc) 861 B
import type { Numeric } from '../types/index'; import type { TimeWithUnit } from './types'; /** * * Parse the given value to milliseconds or optionally to seconds. * * @param value - The string (with unit) or number (or numeric string) to convert. * @param sec - Whether to return the value in seconds. Defaults to `false`. * @returns The given value parsed in milliseconds (or seconds if specified). * * @remarks * - A numeric value (number or numeric string ({@link Numeric})) is interpreted as seconds count, e.g., `120` or `'120'` will be treated as `'120 seconds'`. * - If you use time value with unit ({@link TimeWithUnit}) be sure you provide the time units (days, hours, etc.), otherwise it will return `NaN`, e.g., `'120 unknown'` will return `NaN`. */ export declare function parseMSec(value: TimeWithUnit | Numeric, sec?: boolean): number;