-
Notifications
You must be signed in to change notification settings - Fork 1
/
cache-polyfill.js
1 lines (1 loc) · 1000 Bytes
/
cache-polyfill.js
1
Cache.prototype.add||(Cache.prototype.add=function(t){return this.addAll([t])}),Cache.prototype.addAll||(Cache.prototype.addAll=function(t){var e=this;function r(t){this.name="NetworkError",this.code=19,this.message=t}return r.prototype=Object.create(Error.prototype),Promise.resolve().then(function(){if(arguments.length<1)throw new TypeError;return t=t.map(function(t){return t instanceof Request?t:String(t)}),Promise.all(t.map(function(t){"string"==typeof t&&(t=new Request(t));var e=new URL(t.url).protocol;if("http:"!==e&&"https:"!==e)throw new r("Invalid scheme");return fetch(t.clone())}))}).then(function(r){return Promise.all(r.map(function(r,n){return e.put(t[n],r)}))}).then(function(){})}),CacheStorage.prototype.match||(CacheStorage.prototype.match=function(t,e){var r=this;return this.keys().then(function(n){var o;return n.reduce(function(n,c){return n.then(function(){return o||r.open(c).then(function(r){return r.match(t,e)}).then(function(t){return o=t})})},Promise.resolve())})});