MCPcopy Index your code
hub / github.com/MALSync/MALSync / getAsyncWaitUntilTrue

Function getAsyncWaitUntilTrue

src/utils/general.ts:164–182  ·  view source on GitHub ↗
(condition: Function, interval = 100)

Source from the content-addressed store, hash-verified

162}
163
164export function getAsyncWaitUntilTrue(condition: Function, interval = 100) {
165 let intervalId;
166 let rejectThis;
167 const reset = () => {
168 clearTimeout(intervalId);
169 if (rejectThis) rejectThis('AsyncWait stopped');
170 };
171
172 return {
173 asyncWaitUntilTrue: () => {
174 reset();
175 return new Promise<void>((resolve, reject) => {
176 rejectThis = reject;
177 intervalId = waitUntilTrue(condition, () => resolve(), interval);
178 });
179 },
180 reset,
181 };
182}
183
184const doubleId = Math.random();
185export function checkDoubleExecution() {

Callers 1

waitForPageToBeVisibleFunction · 0.85

Calls 2

waitUntilTrueFunction · 0.85
resetFunction · 0.70

Tested by

no test coverage detected