decord/source/lib/rateLimit.tsx

51 lines
1.2 KiB
TypeScript
Raw Normal View History

// Module ID: 13748
// Function ID: 13749
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
// Module 13748 (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-08-24 06:08:38 +00:00
closure_0 = arg0;
closure_1 = arg1;
closure_2 = arg2;
closure_4 = [];
2026-07-29 08:29:29 +00:00
function wrapper() {
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-07-29 08:29:29 +00:00
arr2 = tmp4;
if (tmp4[0] <= timestamp) {
closure_4.shift();
arr2 = closure_4;
while (closure_4.length > 0) {
2026-07-29 08:29:29 +00:00
arr2 = tmp5;
if (tmp5[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 = [];
HermesBuiltin.arraySpread(items, 0);
HermesBuiltin.apply(items1, undefined);
} else {
const _setTimeout = setTimeout;
timeout = setTimeout(() => wrapper(...items), arr2[0] - timestamp);
2026-07-20 16:05:17 +00:00
}
}
return wrapper;
};