Resolve a promise with specified data after an amount of time
Useful if you want to return data after some time, for example, if you want to sequence data at varying rates.
const after = require('p-after')
(async () => {
const result = await after(1000, 'OK')
// After one second, the promise resolves with 'OK'.
})
Type: number
The amount of time to delay returning the data.
Type: any
The data to return after delay.
- delay - Delay a promise a specified amount of time
- p-min-delay - Delay an existing promise a minimum amount of time
- p-immediate - Returns a promise resolved in the next event loop - think
setImmediate()
- p-timeout - Timeout a promise after a specified amount of time
- More…