(count: number, fn: () => void)
| 1 | export function times(count: number, fn: () => void) { |
| 2 | let i = 0; |
| 3 | return () => { |
| 4 | i++; |
| 5 | if (i === count) { |
| 6 | fn(); |
| 7 | } else if (i > count) { |
| 8 | throw new Error(`too many calls: ${i} instead of ${count}`); |
| 9 | } |
| 10 | }; |
| 11 | } |
| 12 | |
| 13 | export function shouldNotHappen(done) { |
| 14 | return () => done(new Error("should not happen")); |