A Promise that resolves after the specified time has elapsed.
// using async/await
async function main() {
console.log('Before timeout.')
await timeout(1000, () => console.log('A second has passed!'))
console.log('After timeout.')
}
main()
// Before timeout.
// A second has passed!
// After timeout.
// using Promise.then()
console.log('Before timeout.')
timeout(
1000,
() => console.log('A second has passed!')
).then(
() => console.log('Then...')
)
console.log('After timeout.')
// Before timeout.
// After timeout.
// A second has passed!
// Then...
Generated using TypeDoc
Stop execution for a specified amount of time.