jessetane / queue

Asynchronous function queue with adjustable concurrency
MIT License
764 stars 66 forks source link

How to get the index of a success job? #108

Open wxfred opened 6 months ago

wxfred commented 6 months ago

I want to re-run a job by getting the index of the job in the queue and insert it behind itself, so i did this below, but the index is -1

taskQueue.addEventListener('success', event => {
  const { result, job } = event.detail
  const index = taskQueue.indexOf(job)
  console.log(index) // always return -1

  if (result[0] === 'repeat job') taskQueue.splice(index, 0, job)
})