Socket
Socket
Sign inDemoInstall

@fundwave/fetchq

Package Overview
Dependencies
12
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @fundwave/fetchq

Queue for fetch requests


Version published
Maintainers
2
Created

Readme

Source

@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 });
// returns custom fetch function with queueing enabled.
const fetch = MyFetchQueue.getFetchMethod();

Options

PropertyDescriptionDefault Value
concurrentnumber of concurrent fetch requests3
debugset debug modefalse

Usage

import { FetchQueue } from "@fundwave/fetchq";

const fetchQueue = new FetchQueue(); // concurent defaults to 3
const customFetch = fetchQueue.getFetchMethod();

const urls = [...]
const options = {...}

const promises = urls.map(async (url) => await customFetch(url, options))
const responses = await Promise.all(promises);
// get queue length at real time
console.log(fetchQueue.getQueueLength());
// getters and setters
fetchQueue.setConcurrent(5);
console.log(fetchedQueue.getConcurrent()); // output: 5

fetchQueue.setDebug(true);
console.log(fetchedQueue.getDebug()); // output: true
// start and pause queue
const fetchQueue = new FetchQueue(concurrent: 3, pauseQueueOnInit: true);
const customFetch = fetchQueue.getFetchMethod();

// ...some calls
fetchQueue.emptyQueue();
fetchQueue.startQueue();

// ...some calls
fetchQueue.pauseQueue();

Note: See DOCUMENTATION.md for more information on methods.

Keywords

FAQs

Last updated on 08 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc