/** * Time-related helpers shared across packages. * * @module */ export type TimedOptions = { /** Receives the success/failure timing line. Defaults to the shared Enbox logger. */ log?: (message: string) => void; }; /** * Returns a high-resolution monotonic timestamp in milliseconds. * * Uses `performance.now()` when available so elapsed durations are not * affected by wall-clock changes. Falls back to `Date.now()` in runtimes * that do not expose `performance`. */ export declare function nowMs(): number; /** * Parses a human-readable duration string into milliseconds. * * Accepted units: milliseconds (`ms`), seconds (`s`), minutes (`m`), hours (`h`), * days (`d`), weeks (`w`), and years (`y`), including their common long-form * aliases such as `minutes` and `hours`. A bare numeric string is treated as * milliseconds. * * @throws Error if the input is empty, negative, non-finite, or uses an unknown unit. */ export declare function parseDurationInMilliseconds(duration: string): number; /** * Times an async operation and logs a single success/failure duration line. * * The label is intentionally caller-defined so packages can include their own * log namespace, e.g. `[connect.perf] response.sign`. */ export declare function timed(label: string, fn: () => Promise, { log }?: TimedOptions): Promise; /** Largest delay accepted by the native timer APIs without overflow coercion. */ export declare const MAX_TIMER_DELAY_MS = 2147483647; /** * Returns a promise that resolves after the given duration or rejects when * `signal` aborts. Long waits are split into native-timer-sized chunks so an * oversized delay cannot be coerced by the runtime into an immediate timer. * * Use this anywhere you would otherwise inline * `new Promise(resolve => setTimeout(resolve, ms))` — retry backoff, * polling intervals, throttled tests, etc. Centralizing the idiom keeps * call sites readable and ensures every retry/poll path has one obvious * primitive to reach for. * * Negative or zero durations resolve on the next macrotask via * `setTimeout(_, 0)`; they do not throw. * * @param durationInMilliseconds - How long to wait, in milliseconds. * @param signal - Optional cancellation signal for the wait. * @returns A promise that resolves after the duration elapses. * * @example * ```ts * import { sleep } from '@enbox/common'; * * await sleep(250); // pause for 250ms * ``` */ export declare function sleep(durationInMilliseconds: number, signal?: AbortSignal): Promise; //# sourceMappingURL=time.d.ts.map