Creates a priority-based async task queue. Tasks with higher priority values are processed before lower priority tasks.
Input task payload type.
Worker result type.
Async worker function used to process each task.
Optional
Optional queue configuration.
A PriorityTaskQueue instance.
const q = priorityQueue( async (task: string, token) => { await token.sleep(100); return `processed: ${task}`; }, { concurrency: 1 },);q.push("low", 1);q.push("high", 10);q.push("medium", 5);// Processes in order: high (10), medium (5), low (1) Copy
const q = priorityQueue( async (task: string, token) => { await token.sleep(100); return `processed: ${task}`; }, { concurrency: 1 },);q.push("low", 1);q.push("high", 10);q.push("medium", 5);// Processes in order: high (10), medium (5), low (1)
Creates a priority-based async task queue. Tasks with higher priority values are processed before lower priority tasks.