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

client-run-queue

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

client-run-queue - npm Package Compare versions

Comparing version 1.1.3 to 1.1.4

lib/run-queue/internal/DoubleLinkedList/index.d.ts

8

lib/run-queue/queue.d.ts

@@ -13,2 +13,5 @@ import type { RunQueueEntry } from './types/entry';

private processingCount;
/** The delayed entries that haven't been scheduled yet */
private readonly delayedEntries;
/** The priority queue of scheduled entries, not including delayed entries */
private readonly heap;

@@ -22,3 +25,6 @@ /**

readonly cancelAll: () => void;
/** Gets the total queue length, which may include canceled entries that haven't been purged yet */
/**
* Gets the total queue length, which may include canceled entries that haven't been purged yet and delayed entries that aren't yet
* ready for execution
*/
readonly getQueueLength: () => number;

@@ -25,0 +31,0 @@ /**

@@ -21,2 +21,3 @@ "use strict";

const consts_2 = require("./internal/consts");
const DoubleLinkedList_1 = require("./internal/DoubleLinkedList");
class RunQueue {

@@ -33,2 +34,5 @@ // Constructor

this.processingCount = 0;
/** The delayed entries that haven't been scheduled yet */
this.delayedEntries = new DoubleLinkedList_1.DoubleLinkedList();
/** The priority queue of scheduled entries, not including delayed entries */
this.heap = new heap_1.default((a, b) => a.priority - b.priority);

@@ -40,2 +44,8 @@ // Public Methods

let numEntriesCanceled = 0;
// Canceling delayed entries
for (const entry of this.delayedEntries.toArray()) {
entry.cancel();
numEntriesCanceled += 1;
}
// Canceling scheduled entries
for (const entry of this.heap.toArray()) {

@@ -48,5 +58,8 @@ if (entry.cancel()) {

};
/** Gets the total queue length, which may include canceled entries that haven't been purged yet */
this.getQueueLength = () => this.heap.size();
/**
* Gets the total queue length, which may include canceled entries that haven't been purged yet and delayed entries that aren't yet
* ready for execution
*/
this.getQueueLength = () => this.heap.size() + this.delayedEntries.getLength();
/**
* Schedules a new entry to be run.

@@ -118,3 +131,8 @@ *

let resolver;
let delayedEntryNode = undefined;
const timeout = setTimeout(() => __awaiter(this, void 0, void 0, function* () {
if (delayedEntryNode !== undefined) {
this.delayedEntries.remove(delayedEntryNode);
delayedEntryNode = undefined;
}
runQueueEntry = this.scheduleImmediately(priority, id, run, options);

@@ -139,3 +157,3 @@ try {

}), options.delayMSec);
return {
const entry = {
cancel: () => {

@@ -152,2 +170,6 @@ if (wasResolved) {

}
if (delayedEntryNode !== undefined) {
this.delayedEntries.remove(delayedEntryNode);
delayedEntryNode = undefined;
}
resolver({ ok: false, details: consts_1.CANCELED });

@@ -162,2 +184,4 @@ },

};
delayedEntryNode = this.delayedEntries.append(entry);
return entry;
};

@@ -164,0 +188,0 @@ this.scheduleImmediately = (priority, id, run, options) => {

2

package.json
{
"name": "client-run-queue",
"version": "1.1.3",
"version": "1.1.4",
"description": "A client-friendly run queue",

@@ -5,0 +5,0 @@ "keywords": ["promise", "concurrency", "limit", "throttle", "queue", "priority", "typescript", "client"],

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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