MCPcopy Create free account
hub / github.com/EvoMap/evolver / runOneScheduledTick

Function runOneScheduledTick

test/syncEngineLoopResilience.test.js:112–138  ·  view source on GitHub ↗
(schedule)

Source from the content-addressed store, hash-verified

110}
111
112async function runOneScheduledTick(schedule) {
113 const realSetTimeout = global.setTimeout;
114 const delays = [];
115 let resolveDone;
116 const done = new Promise((resolve) => { resolveDone = resolve; });
117 global.setTimeout = (fn, delay) => {
118 delays.push(delay);
119 const timer = { unref: () => {} };
120 if (delays.length === 1) {
121 realSetTimeout(async () => {
122 try {
123 await fn();
124 } finally {
125 resolveDone();
126 }
127 }, 0);
128 }
129 return timer;
130 };
131 try {
132 schedule();
133 await done;
134 } finally {
135 global.setTimeout = realSetTimeout;
136 }
137 return delays;
138}
139
140async function waitFor(predicate, { timeoutMs = 2000, intervalMs = 25 } = {}) {
141 const deadline = Date.now() + timeoutMs;

Calls 1

fnFunction · 0.70

Tested by

no test coverage detected