mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
15 lines
345 B
TypeScript
15 lines
345 B
TypeScript
import { API_RATE } from "./constants";
|
|
|
|
const MAX_COMPUTE_TIME = (5 * 60 + 55) * 60 * 1000; // 5hr 55min
|
|
|
|
const t0 = performance.now();
|
|
const t1 = t0 + MAX_COMPUTE_TIME;
|
|
|
|
export function withinTimeLimit() {
|
|
return performance.now() < t1;
|
|
}
|
|
|
|
export function sleep() {
|
|
return new Promise((resolve) => setTimeout(resolve, 1000 / API_RATE));
|
|
}
|