Function
times
(count: number, fn: () => void)
Source from the content-addressed store, hash-verified
| 7 | import { createAdapter } from "@socket.io/redis-streams-adapter"; |
| 8 | |
| 9 | export function times(count: number, fn: () => void) { |
| 10 | let i = 0; |
| 11 | return () => { |
| 12 | i++; |
| 13 | if (i === count) { |
| 14 | fn(); |
| 15 | } else if (i > count) { |
| 16 | throw new Error(`too many calls: ${i} instead of ${count}`); |
| 17 | } |
| 18 | }; |
| 19 | } |
| 20 | |
| 21 | export function sleep(duration: number) { |
| 22 | return new Promise((resolve) => setTimeout(resolve, duration)); |
Tested by
no test coverage detected