Closed hanumanjiblog closed 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}); });
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));
error- Property 'on' does not exist on type 'PQueue<PriorityQueue, DefaultAddOptions>'.ts(2339) any
Interesting - this actually works for me (using version 6.6.2). However, using event type error as described in the README does not work:
6.6.2
error
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));
error- Property 'on' does not exist on type 'PQueue<PriorityQueue, DefaultAddOptions>'.ts(2339) any