wait
Returns a Promise that transitions to the fulfilled state after a delay of delay ms.
Added in v0.1.0
Usage
ts
import { wait } from 'parsnip-kit'
wait(5000).then(() => {
console.log('Delay end') // after 5000ms
})
wait(5000, () => 'data').then((res) => {
console.log(res) // 'data' after 5000ms
})API
Type Parameter
| Arg | Type | Description |
|---|---|---|
T | extends (...args: any) => any | Typeof callback |
Arguments
| Arg | Type | Optional | Default | Description |
|---|---|---|---|---|
delay | number | false | undefined | Delay time |
callback | T | false | undefined | Callback After Delay |
Returns
| Type |
|---|
Promise<ReturnType<T>> |