sindresorhus / p-queue

Promise queue with concurrency control
MIT License
3.45k stars 185 forks source link

queue.on on not working #153

Closed hanumanjiblog closed 3 years ago

hanumanjiblog commented 3 years ago

import delay from 'delay'; import PQueue from 'p-queue';

const queue = new PQueue({ concurrency: 2 });

let count = 0; queue.on('active', () => { console.log(Working on item #${++count}. Size: ${queue.size} Pending: ${queue.pending}); });

queue.add(() => Promise.resolve()); queue.add(() => delay(2000)); queue.add(() => Promise.resolve()); queue.add(() => Promise.resolve()); queue.add(() => delay(500));

Screenshot_3

error- Property 'on' does not exist on type 'PQueue<PriorityQueue, DefaultAddOptions>'.ts(2339) any

hilleer commented 3 years ago

Interesting - this actually works for me (using version 6.6.2). However, using event type error as described in the README does not work:

Screenshot 2021-10-11 at 14 51 35

Screenshot 2021-10-11 at 14 50 43

Screenshot 2021-10-11 at 14 50 46