()
| 12133 | } |
| 12134 | |
| 12135 | _processQueue() { |
| 12136 | if (this.activeCount >= this.concurrency || this.queue.length === 0) { |
| 12137 | return; |
| 12138 | } |
| 12139 | |
| 12140 | this.activeCount++; |
| 12141 | const { url, resolve, reject } = this.queue.shift(); |
| 12142 | |
| 12143 | this._fetchByHead(url) |
| 12144 | .then(size => { |
| 12145 | if (size !== null) this.cache.set(url, size); |
| 12146 | resolve(size); |
| 12147 | }) |
| 12148 | .catch(err => { |
| 12149 | console.warn(`Fetch size failed for ${url}`, err); |
| 12150 | resolve(null); |
| 12151 | }) |
| 12152 | .finally(() => { |
| 12153 | this.activeCount--; |
| 12154 | this._processQueue(); |
| 12155 | }); |
| 12156 | } |
| 12157 | |
| 12158 | _fetchByHead(url) { |
| 12159 | return new Promise((resolve, reject) => { |
no test coverage detected