Medium
You need to implement a promise queue that limits concurrent operations. What's the correct implementation of the missing methods?
1class PromiseQueue {2 constructor(concurrency = 3) {3 this.concurrency = concurrency;4 this.running = 0;5 this.queue = [];6 }78 // Missing implementation9 ____________________10 ____________________11 ____________________12 ____________________13}1415// Usage:16const queue = new PromiseQueue(2);17const urls = ['url1', 'url2', 'url3', 'url4', 'url5'];1819urls.forEach(url => {20 queue.add(() => fetch(url))21 .then(response => console.log(`Completed: ${url}`));22});