mirror of
https://github.com/socketio/socket.io.git
synced 2026-01-09 15:08:12 -05:00
20 lines
430 B
TypeScript
20 lines
430 B
TypeScript
export function times(count: number, fn: () => void) {
|
|
let i = 0;
|
|
return () => {
|
|
i++;
|
|
if (i === count) {
|
|
fn();
|
|
} else if (i > count) {
|
|
throw new Error(`too many calls: ${i} instead of ${count}`);
|
|
}
|
|
};
|
|
}
|
|
|
|
export function shouldNotHappen(done) {
|
|
return () => done(new Error("should not happen"));
|
|
}
|
|
|
|
export function sleep() {
|
|
return new Promise<void>((resolve) => process.nextTick(resolve));
|
|
}
|