Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/backend/conat/test/util.ts
1450 views
1
import { until } from "@cocalc/util/async-utils";
2
3
export async function wait({
4
until: f,
5
start = 5,
6
decay = 1.2,
7
max = 300,
8
}: {
9
until: Function;
10
start?: number;
11
decay?: number;
12
max?: number;
13
}) {
14
await until(
15
async () => {
16
try {
17
return !!(await f());
18
} catch {
19
return false;
20
}
21
},
22
{
23
start,
24
decay,
25
max,
26
min: 5,
27
timeout: 10000,
28
},
29
);
30
}
31
32