Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/backend/conat/test/util.ts
1711 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
timeout = 10000,
9
}: {
10
until: Function;
11
start?: number;
12
decay?: number;
13
max?: number;
14
timeout?: number;
15
}) {
16
await until(
17
async () => {
18
try {
19
return !!(await f());
20
} catch {
21
return false;
22
}
23
},
24
{
25
start,
26
decay,
27
max,
28
min: 5,
29
timeout,
30
},
31
);
32
}
33
34