Added onboarding and exe output.

This commit is contained in:
2026-07-17 09:57:49 +01:00
parent 12edaa054d
commit a598abe1e6
9 changed files with 2193 additions and 47 deletions
+18 -3
View File
@@ -1,10 +1,25 @@
const pThrottleModule = require('p-throttle');
const pThrottle = pThrottleModule.default || pThrottleModule;
function sleep(milliseconds) {
return new Promise(resolve => setTimeout(resolve, milliseconds));
}
function buildThrottle(maxRequestsPerMinute) {
const limit = Math.max(1, Math.floor(maxRequestsPerMinute));
const interval = Math.ceil(60000 / limit);
return pThrottle({limit: 1, interval});
let nextAvailable = 0;
return function throttle(fn) {
return async function throttledFunction(...args) {
const now = Date.now();
const waitMs = Math.max(0, nextAvailable - now);
nextAvailable = Math.max(nextAvailable, now) + interval;
if (waitMs > 0) {
await sleep(waitMs);
}
return fn(...args);
};
};
}
function applyRateLimitBuffer(rateLimitPerMinute) {