decord/source/lib/rateLimit.tsx
2026-08-08 06:10:11 +00:00

48 lines
1.2 KiB
TypeScript

// Module ID: 12942
// Function ID: 12943
// Name: rateLimit
// Dependencies: [2]
// Exports: default
// Module 12942 (rateLimit)
const result = require("set").fileFinishedImporting("lib/rateLimit.tsx");
export default function rateLimit(arg0, arg1, arg2) {
let closure_0 = arg0;
let closure_1 = arg1;
let closure_2 = arg2;
let closure_4 = [];
function wrapper() {
const items = [...arguments];
const timestamp = Date.now();
if (null != timeout) {
const _clearTimeout = clearTimeout;
clearTimeout(timeout);
timeout = null;
}
let arr2 = arr;
if (arr.length > 0) {
arr2 = tmp4;
if (tmp4[0] <= timestamp) {
arr = arr.shift();
arr2 = arr;
while (arr.length > 0) {
arr2 = tmp5;
if (tmp5[0] > timestamp) {
break;
}
}
}
}
if (arr2.length < items) {
arr = arr2.push(timestamp + closure_1);
const items1 = [];
HermesBuiltin.arraySpread(items, 0);
HermesBuiltin.apply(items1, undefined);
} else {
const _setTimeout = setTimeout;
timeout = setTimeout(() => outer1_5(...items), arr2[0] - timestamp);
}
}
return wrapper;
};