setTimeout() with native promises
npm install x-time --save
const xTime = require('x-time')
xTime(1000, 'one').then(value => {
console.log(`waited ${value} second`)
})
You can also await
the x-time promise:
await xTime(1000)
The default import syntax of TypeScript does not work with this module because it exports a function directly. You need to use the following syntax in order to get completions:
import xTime = require('x-time')
- time
<Number>
duration of timeout in ms - value
<any>
value to resolve the promise with
Returns a promise that gets resolved to the value when the time has passed.