MCPcopy Index your code
hub / github.com/QLHazyCoder/FlowPilot / sleep

Function sleep

content/utils.js:383–401  ·  view source on GitHub ↗

* Wait a specified number of milliseconds. * @param {number} ms * @returns {Promise }

(ms)

Source from the content-addressed store, hash-verified

381 * @returns {Promise<void>}
382 */
383function sleep(ms) {
384 return new Promise((resolve, reject) => {
385 const start = Date.now();
386
387 function tick() {
388 if (flowStopped) {
389 reject(new Error(STOP_ERROR_MESSAGE));
390 return;
391 }
392 if (Date.now() - start >= ms) {
393 resolve();
394 return;
395 }
396 setTimeout(tick, Math.min(100, Math.max(25, ms - (Date.now() - start))));
397 }
398
399 tick();
400 });
401}
402
403async function humanPause(min = 250, max = 850) {
404 const duration = Math.floor(Math.random() * (max - min + 1)) + min;

Calls 1

tickFunction · 0.85

Tested by

no test coverage detected