You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
export async function *getGenerator<T>( |
|
duration: number, |
|
func: (...args: any[]) => Promise<T>, |
|
...args |
|
): AsyncIterableIterator<T> { |
|
|
|
let timeout = async () => new Promise( |
|
resolve => setTimeout(resolve, duration) |
|
); |
|
|
|
while(true) { |
|
yield await func(...args); |
|
await timeout(); |
|
} |
|
} |