es-next-tools
Version:
A comprehensive utility library for JavaScript and TypeScript that provides a wide range of functions for common programming tasks, including mathematical operations, date manipulations, array and object handling, string utilities, and more.
12 lines (11 loc) • 533 B
TypeScript
/**
* Delays the resolution of a promise or value by a specified number of milliseconds.
* @param {T | Promise<T>} value - The value or promise to delay.
* @param {number} ms - The number of milliseconds to delay.
* @returns {Promise<T>} A promise that resolves with the value after the specified delay.
* @template T
* @example
* const delayedValue = await delay('Hello', 1000);
* console.log(delayedValue); // Logs 'Hello' after 1 second
*/
export declare function delay<T>(value: T | Promise<T>, ms: number): Promise<T>;