@vgerbot/async
    Preparing search index...

    Function priorityQueue

    • Creates a priority-based async task queue. Tasks with higher priority values are processed before lower priority tasks.

      Type Parameters

      • T

        Input task payload type.

      • R

        Worker result type.

      Parameters

      • worker: QueueWorker<T, R>

        Async worker function used to process each task.

      • Optionaloptions: QueueOptions

        Optional queue configuration.

      Returns PriorityTaskQueue<T, R>

      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)