Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nextgis/queue

Package Overview
Dependencies
Maintainers
0
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nextgis/queue

Manage concurrent asynchronous tasks with abort capabilities

  • 3.0.0-alpha.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-96.15%
Maintainers
0
Weekly downloads
 
Created
Source

Cache

size version

An advanced promise queue management library for JavaScript. This library is designed to handle the concurrency of any asynchronous tasks encapsulated in promises, providing optional debouncing to manage the flow of promise execution.

  • Limit the number of concurrent promises.
  • Optional debouncing to manage the timing of promise execution.
  • Ability to abort queued promises.
  • Efficient and orderly management of asynchronous operations.

Installation

In Browser

Include assets

Simply download and include with a script tag, Queue will be registered as a global variable.

<script src="../lib/queue.global.js"></script>

<script>
const queue = new Queue({ concurrency: 3, delay: 200 });

const asyncTask = function () {
  return new Promise((resolve) => setTimeout(() => resolve("Task Complete"), 1000));
};

queue.add(asyncTask);


const asyncWithAbort = () => {
  let timer;
  const promise = new Promise((resolve) => {
    timer = setTimeout(() => resolve("Another Task Complete"), 500);
  });
  const abortFunc = () => {
    clearTimeout(timer);
    console.log('Task was aborted');
  };
  return [promise, abortFunc]
}

queue.add(asyncWithAbort);
</script>
CDN

unpkg

<script src="https://unpkg.com/@nextgis/queue"></script>

jsdelivr

<script src="https://cdn.jsdelivr.net/npm/@nextgis/queue"></script>

We recommend linking to a specific version number /queue@[version]

In Node.js

npm install @nextgis/queue

Usage

import Queue from '@nextgis/queue';

const queue = new Queue({ concurrency: 2, delay: 100 });

const abortController = new AbortController();

queue.add(
  () =>
    fetch('https://api.example.com/data', {
      signal: abortController.signal,
    }),
  abortController.abort,
);

// Demonstrating the abort function
setTimeout(() => {
  queue.abort();
}, 100);

Check out the API Documentation

Commercial support

Need to fix a bug or add a feature to @nextgis/cache? We provide custom development and support for this software. Contact us to discuss options!

http://nextgis.com

Keywords

FAQs

Package last updated on 12 Sep 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc