import { asyncPool } from "https://esm.town/v/harryhood/asyncPool";
export async function rateLimitedAsyncPool<T, V>(
items: T[],
poolLimit: number,
fn: (item: T) => Promise<V>,
waitTime: number,
): Promise<V[]> {
return asyncPool(items, poolLimit, async (item) => {
const result = await fn(item);
await new Promise((resolve) => setTimeout(resolve, waitTime));
return result;
});
}