mirror of
https://github.com/zhigang1992/now-deployment.git
synced 2026-06-16 11:49:51 +08:00
14 lines
280 B
TypeScript
14 lines
280 B
TypeScript
import sleep from './sleep';
|
|
|
|
export default function createPollingFn<R>(
|
|
future: (...args: any[]) => Promise<R>,
|
|
sleepTime: number
|
|
) {
|
|
return async function*(...args: any[]) {
|
|
while (true) {
|
|
yield await future(...args);
|
|
await sleep(sleepTime);
|
|
}
|
|
};
|
|
}
|