index.ts 225 B

123456789
  1. /** 延时器 */
  2. export const delayer = (timeout?: number) =>
  3. new Promise<any>((resolve) => {
  4. let cd = 500
  5. if (typeof timeout === "number" && timeout > 0) {
  6. cd = timeout
  7. }
  8. setTimeout(resolve, cd)
  9. })