Registry / devops / typescript-blocking-queue

typescript-blocking-queue

JSON →
library1.2.3jsnpmunverified

A TypeScript library providing prioritized blocking queues with whenReady support, designed to handle bottlenecks like authentication refresh. Version 1.2.3 is the current stable release; the library is actively maintained on GitHub. It offers multiple priority levels, deadlock warnings, and full TypeScript support. Unlike many queue libraries, it includes a whenReady queue that executes only after prioritized jobs finish, making it ideal for token refresh patterns.

npm install typescript-blocking-queue
INSTALL
IMPORT
SIG · TYPESCRIPT-BLOCKIN
T
typescript-blocking-queue
devopsjavascriptv1.2.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

newPrioritizedBlockingQueue
import { newPrioritizedBlockingQueue } from 'typescript-blocking-queue'
const queue = require('typescript-blocking-queue').newPrioritizedBlockingQueue()
ESM only; named export. The package is TypeScript-native.
PriorityQueue
import type { PriorityQueue } from 'typescript-blocking-queue'
import { PriorityQueue } from 'typescript-blocking-queue'
PriorityQueue is a type, not a runtime export. Use with import type for TypeScript.
WhenReadyQueue
import type { WhenReadyQueue } from 'typescript-blocking-queue'
import { WhenReadyQueue } from 'typescript-blocking-queue'
WhenReadyQueue is also a type only. The correct runtime usage is via the returned object from newPrioritizedBlockingQueue.

Creates a blocking queue with 2 priority levels, enqueues a prioritized job, and demonstrates whenReady execution.

import { newPrioritizedBlockingQueue } from 'typescript-blocking-queue'; async function example() { const queue = newPrioritizedBlockingQueue(2); const result = await queue.prioritized(0).enqueue(async () => { // Simulate auth refresh return 'authenticated'; }); // When prioritized queues are empty, whenReady jobs run queue.whenReady().enqueue(async () => { console.log('When ready: all prioritized jobs done'); }); console.log(result); // 'authenticated' } example().catch(console.error);
Debug
Known issues
gotchaDo not await enqueue inside a queue's execution callback – it will cause a deadlock.
fix
Use queue.prioritized(0).enqueue(() => { /* no await */ }) instead of awaiting the returned promise inside the callback.
affects: >=0.0.0
gotchaWhen queue.prioritized() index is omitted, it defaults to 0; ensure you specify the index if multiple priority levels exist.
fix
Always pass an index: queue.prioritized(1).enqueue(...) for lower priority.
affects: <=1.2.3
gotchawhenReady() jobs may run concurrently if the queue is empty; they are not serialized.
fix
Use separate prioritzed queues if you need serial execution.
affects: >=0.0.0
deprecatedNo deprecated features reported; library is stable.
fix
No fix needed.
affects: >=0.0.0
Errors
Common errors & fixes
Error: You are already signed in!
Enqueuing a job that throws when a condition isn't met, but the queue doesn't catch it.
fix
Wrap enqueue calls in try/catch or handle errors within the callback.
TypeError: queue.prioritized is not a function
Using require() CommonJS syntax instead of ESM import.
fix
Change to import { newPrioritizedBlockingQueue } from 'typescript-blocking-queue'.
Deadlock: queue never resolves
Awaiting a promise returned by enqueue inside the same queue's callback.
fix
Do not await the enqueue promise; use queue.prioritized(0).enqueue(() => { ... }) without await.
Upgrade
Version history
1.2.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
typescript-blocking-queue — npm install typescript-blocking-queue · libregistry