UNPKG

@jingoz/await-timer

Version:

@jingoz/await-timer 是一个 npm 包,提供了实现轮询功能的能力,用于替代 setInterval,并且可以确保传入的回调函数执行完毕后再开始下一次的循环。

14 lines (13 loc) 394 B
export type AsyncFunction = (...args: any[]) => Promise<any>; export type SyncFunction = (...args: any[]) => any; export type LoopCallback = AsyncFunction | SyncFunction; export interface IAwaitTimer { isStopped: boolean; start: () => Promise<void>; stop: () => void; destroy: () => void; } export type AwaitTimerOptions = { immediate?: boolean; autoStart?: boolean; };