UNPKG

opnet

Version:

The perfect library for building Bitcoin-based applications.

13 lines (12 loc) 397 B
import pLimit from 'p-limit'; import { Agent, fetch as undiciFetch, setGlobalDispatcher } from 'undici'; export function getFetcher(configs) { const agent = new Agent(configs); setGlobalDispatcher(agent); const limit = pLimit(500); async function limitedFetch(...args) { return limit(() => undiciFetch(...args)); } return limitedFetch; } export default getFetcher;