Waits for given number of milliseconds before timing out. If provided code block does not complete within the given time, the promise will be rejected with new Error('TIMEOUT') error.
new Error('TIMEOUT')
const result = await timeout(1000, async () => { return 123;}); Copy
const result = await timeout(1000, async () => { return 123;});
Number of milliseconds to wait before timing out.
Code block or promise to execute.
The result of the code block or promise.
Waits for given number of milliseconds before timing out. If provided code block does not complete within the given time, the promise will be rejected with
new Error('TIMEOUT')
error.