decord/alpha/source/lib/rateLimit.tsx

53 lines
1.3 KiB
TypeScript
Raw Normal View History

2026-10-05 08:00:40 +00:00
// Module ID: 13483
// Function ID: 13484
2026-07-20 16:05:17 +00:00
// Name: rateLimit
2026-07-23 10:11:24 +00:00
// Dependencies: [2]
2026-07-20 16:05:17 +00:00
// Exports: default
2026-10-05 08:00:40 +00:00
// Module 13483 (rateLimit)
import size from "module_2" /* 2 */;
2026-08-24 06:08:38 +00:00
const result = size.fileFinishedImporting("lib/rateLimit.tsx");
2026-07-20 16:05:17 +00:00
export default function rateLimit(arg0, arg1, arg2) {
2026-10-03 08:58:59 +00:00
let closure_0 = arg0;
let closure_1 = arg1;
let closure_2 = arg2;
let closure_4 = [];
2026-07-29 08:29:29 +00:00
function wrapper() {
2026-10-03 08:58:59 +00:00
let closure_3;
let timeout;
2026-07-20 16:05:17 +00:00
const items = [...arguments];
const timestamp = Date.now();
if (null != timeout) {
const _clearTimeout = clearTimeout;
clearTimeout(timeout);
2026-07-23 10:11:24 +00:00
timeout = null;
2026-07-20 16:05:17 +00:00
}
let arr2 = closure_4;
if (closure_4.length > 0) {
2026-10-03 08:58:59 +00:00
arr2 = tmp5;
if (closure_4[0] <= timestamp) {
closure_4.shift();
arr2 = closure_4;
while (closure_4.length > 0) {
2026-10-03 08:58:59 +00:00
arr2 = tmp6;
if (tmp6[0] > timestamp) {
2026-07-20 16:05:17 +00:00
break;
}
}
}
}
2026-07-29 08:29:29 +00:00
if (arr2.length < items) {
arr2.push(timestamp + closure_1);
2026-07-20 16:05:17 +00:00
const items1 = [];
2026-10-03 08:58:59 +00:00
HermesBuiltin.arraySpread(items1, items, 0);
HermesBuiltin.apply(closure_2, items1, undefined);
2026-07-20 16:05:17 +00:00
} else {
const _setTimeout = setTimeout;
timeout = setTimeout(() => wrapper(...items), arr2[0] - timestamp);
2026-07-20 16:05:17 +00:00
}
}
return wrapper;
};