@fundwave/fetchq
A client-side library that allows you to queue fetch requests.
- Supports ES modules
- Supports CommonJS
Installation
npm install @fundwave/fetchq
Initialization
import { FetchQueue } from "@fundwave/fetchq";
const MyFetchQueue = new FetchQueue({ concurrent: 2 });
const fetch = MyFetchQueue.getFetchMethod();
Options
Property | Description | Default Value |
---|
concurrent | number of concurrent fetch requests | 3 |
debug | set debug mode | false |
Usage
import { FetchQueue } from "@fundwave/fetchq";
const fetchQueue = new FetchQueue();
const customFetch = fetchQueue.getFetchMethod();
const urls = [...]
const options = {...}
const promises = urls.map(async (url) => await customFetch(url, options))
const responses = await Promise.all(promises);
console.log(fetchQueue.getQueueLength());
fetchQueue.setConcurrent(5);
console.log(fetchedQueue.getConcurrent());
fetchQueue.setDebug(true);
console.log(fetchedQueue.getDebug());
const fetchQueue = new FetchQueue(concurrent: 3, pauseQueueOnInit: true);
const customFetch = fetchQueue.getFetchMethod();
fetchQueue.emptyQueue();
fetchQueue.startQueue();
fetchQueue.pauseQueue();
Note: See DOCUMENTATION.md for more information on methods.