MCPcopy Create free account
hub / github.com/chieapp/chie / gcUntil

Function gcUntil

test-ui/util.ts:6–25  ·  view source on GitHub ↗
(condition, seconds = 30)

Source from the content-addressed store, hash-verified

4export const addFinalizer: (obj: object, finalizer: () => void) => void = (gui as any).addFinalizer;
5
6export function gcUntil(condition, seconds = 30) {
7 return new Promise<void>((resolve, reject) => {
8 let count = 0;
9 function gcAndCheck() {
10 setTimeout(() => {
11 count++;
12 gc();
13 if (condition()) {
14 resolve();
15 } else if (count < seconds) {
16 gcAndCheck();
17 } else {
18 reject('GC failure');
19 }
20 }, 1000);
21 }
22 gc();
23 gcAndCheck();
24 });
25}

Calls 1

gcAndCheckFunction · 0.85

Tested by

no test coverage detected