http-range-fetcher
Advanced tools
Comparing version
@@ -362,3 +362,3 @@ "use strict"; | ||
if (!cachedPromise) { | ||
_context3.next = 20; | ||
_context3.next = 21; | ||
break; | ||
@@ -404,5 +404,8 @@ } | ||
case 19: | ||
// gather the stats for the file from the headers | ||
this._recordStatsIfNecessary(key, chunk); | ||
return _context3.abrupt("return", chunk); | ||
case 20: | ||
case 21: | ||
fetchStart = chunkNumber * this.chunkSize; | ||
@@ -414,3 +417,3 @@ fetchEnd = fetchStart + this.chunkSize; // clamp the end of the fetch to the size if we have a cached size for the file | ||
if (!(stat && stat.size)) { | ||
_context3.next = 27; | ||
_context3.next = 28; | ||
break; | ||
@@ -420,3 +423,3 @@ } | ||
if (!(fetchStart >= stat.size)) { | ||
_context3.next = 26; | ||
_context3.next = 27; | ||
break; | ||
@@ -427,6 +430,6 @@ } | ||
case 26: | ||
case 27: | ||
if (fetchEnd >= stat.size) fetchEnd = stat.size; | ||
case 27: | ||
case 28: | ||
alreadyRejected = false; | ||
@@ -443,9 +446,10 @@ freshPromise = this.aggregator.fetch(key, fetchStart, fetchEnd, requestOptions).catch(function (err) { | ||
if (!alreadyRejected) this.chunkCache.set(chunkKey, freshPromise); | ||
_context3.next = 32; | ||
_context3.next = 33; | ||
return freshPromise; | ||
case 32: | ||
case 33: | ||
freshChunk = _context3.sent; | ||
// gather the stats for the file from the headers | ||
this.stats.set(key, this._headersToStats(freshChunk)); // remove the promise from the cache | ||
this._recordStatsIfNecessary(key, freshChunk); // remove the promise from the cache | ||
// if it turns out not to be cacheable. this is | ||
@@ -455,2 +459,3 @@ // done after the fact because we want multiple requests | ||
if (!this.cacheSemantics.chunkIsCacheable(freshChunk)) { | ||
@@ -462,3 +467,3 @@ this._uncacheIfSame(chunkKey, freshPromise); | ||
case 36: | ||
case 37: | ||
case "end": | ||
@@ -476,3 +481,9 @@ return _context3.stop(); | ||
return _getChunk; | ||
}() // delete a promise from the cache if it is still in there. | ||
}() // if the stats for a resource haven't been recorded yet, record them | ||
}, { | ||
key: "_recordStatsIfNecessary", | ||
value: function _recordStatsIfNecessary(key, chunk) { | ||
if (!this.stats.has(key)) this.stats.set(key, this._headersToStats(chunk)); | ||
} // delete a promise from the cache if it is still in there. | ||
// need to check if it is still the same because it might | ||
@@ -479,0 +490,0 @@ // have been overwritten sometime while the promise was in flight |
{ | ||
"name": "http-range-fetcher", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "caching, aggregating fetch manager for doing lots of HTTP range requests", | ||
@@ -30,3 +30,4 @@ "license": "MIT", | ||
"prepublishOnly": "npm run lint && npm test && npm run build", | ||
"postpublish": "git push origin master --follow-tags" | ||
"postpublish": "git push origin master --follow-tags", | ||
"version": "standard-changelog && git add CHANGELOG.md" | ||
}, | ||
@@ -47,3 +48,4 @@ "watch": { | ||
"object.entries-ponyfill": "^1.0.1", | ||
"quick-lru": "^2.0.0" | ||
"quick-lru": "^2.0.0", | ||
"standard-changelog": "^1.0.0" | ||
}, | ||
@@ -50,0 +52,0 @@ "devDependencies": { |
40820
3.73%10
11.11%763
0.93%6
20%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added