decord/source/lib/rateLimit.tsx

46 lines
1.1 KiB
TypeScript
Raw Normal View History

2026-07-28 08:39:19 +00:00
// Module ID: 12710
// Function ID: 98190
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-07-28 08:39:19 +00:00
// Module 12710 (rateLimit)
2026-07-23 10:11:24 +00:00
const result = require("set").fileFinishedImporting("lib/rateLimit.tsx");
2026-07-20 16:05:17 +00:00
export default function rateLimit(arg0, arg1, arg2) {
2026-07-23 10:11:24 +00:00
let closure_0 = arg0;
let closure_1 = arg1;
let closure_2 = arg2;
2026-07-20 16:05:17 +00:00
let closure_4 = [];
function wrapper(arg0) {
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
}
if (arr.length > 0) {
if (arr[0] <= timestamp) {
2026-07-23 10:11:24 +00:00
arr = arr.shift();
2026-07-20 16:05:17 +00:00
while (arr.length > 0) {
let tmp7 = arr;
if (arr[0] > timestamp) {
break;
}
}
}
}
2026-07-23 10:11:24 +00:00
if (arr.length < items) {
arr = arr.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;
2026-07-23 10:11:24 +00:00
timeout = setTimeout(() => outer1_5(...items), arr[0] - timestamp);
2026-07-20 16:05:17 +00:00
}
}
return wrapper;
};