Socket
Socket
Sign inDemoInstall

axios-cache-interceptor

Package Overview
Dependencies
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

axios-cache-interceptor - npm Package Compare versions

Comparing version 0.7.6 to 0.7.7

3

dist/cache/create.d.ts

@@ -5,3 +5,4 @@ import type { AxiosInstance } from 'axios';

export declare type CacheOptions = Partial<CacheInstance> & Partial<CacheProperties>;
export declare function useCache(axios: AxiosInstance, { storage, generateKey, waiting, headerInterpreter, requestInterceptor, responseInterceptor, ...cacheOptions }?: CacheOptions): AxiosCacheInstance;
export declare function createCache(axios: AxiosInstance, { storage, generateKey, waiting, headerInterpreter, requestInterceptor, responseInterceptor, ...cacheOptions }?: CacheOptions): AxiosCacheInstance;
export declare const useCache: typeof createCache;
//# sourceMappingURL=create.d.ts.map

@@ -14,3 +14,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.useCache = void 0;
exports.useCache = exports.createCache = void 0;
const interpreter_1 = require("../header/interpreter");

@@ -21,3 +21,3 @@ const request_1 = require("../interceptors/request");

const key_generator_1 = require("../util/key-generator");
function useCache(axios, _a = {}) {
function createCache(axios, _a = {}) {
var { storage, generateKey, waiting, headerInterpreter, requestInterceptor, responseInterceptor } = _a, cacheOptions = __rest(_a, ["storage", "generateKey", "waiting", "headerInterpreter", "requestInterceptor", "responseInterceptor"]);

@@ -38,2 +38,3 @@ const axiosCache = axios;

}
exports.useCache = useCache;
exports.createCache = createCache;
exports.useCache = createCache;

@@ -36,5 +36,5 @@ "use strict";

}
return maxAge * 1000 - Number(age) * 1000;
return (maxAge - Number(age)) * 1000;
}
return undefined;
};
/*! For license information please see index.min.js.LICENSE.txt */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.AxiosCacheInterceptor=t():e.AxiosCacheInterceptor=t()}(self,(function(){return(()=>{var e={86:(e,t)=>{!function(e){var t=Symbol("cache-parser"),r=Number;function a(e){return("string"==typeof e||"number"==typeof e)&&(e=r(e))>=0&&e<1/0}function n(e){return"number"==typeof e||!0===e||"string"==typeof e&&"false"!==e}e.__internal={isDuration:a,toBoolean:n},e.isCacheControl=function(e){return!!e&&!!e[t]},e.tokenize=function(e){if(!e||"object"!=typeof e)return[];var t=[];return n(e.immutable)&&t.push("immutable"),a(e.maxAge)&&t.push("max-age="+r(e.maxAge)),a(e.maxStale)&&t.push("max-stale="+r(e.maxStale)),a(e.minFresh)&&t.push("min-fresh="+r(e.minFresh)),n(e.mustRevalidate)&&t.push("must-revalidate"),n(e.mustUnderstand)&&t.push("must-understand"),n(e.noCache)&&t.push("no-cache"),n(e.noStore)&&t.push("no-store"),n(e.noTransform)&&t.push("no-transform"),n(e.onlyIfCached)&&t.push("only-if-cached"),n(e.private)&&t.push("private"),n(e.proxyRevalidate)&&t.push("proxy-revalidate"),n(e.public)&&t.push("public"),a(e.sMaxAge)&&t.push("s-maxage="+r(e.sMaxAge)),a(e.staleIfError)&&t.push("stale-if-error="+r(e.staleIfError)),a(e.staleWhileRevalidate)&&t.push("stale-while-revalidate="+r(e.staleWhileRevalidate)),t},e.parse=function(e){var o=Object.defineProperty({},t,{enumerable:!1,value:1});if(!e||"string"!=typeof e)return o;var i={},s=e.toLowerCase().replace(/\s+/g,"").split(",");for(var c in s){var u=s[c].split("=",2);i[u[0]]=1===u.length||u[1]}return n(i.immutable)&&(o.immutable=!0),a(i["max-age"])&&(o.maxAge=r(i["max-age"])),a(i["max-stale"])&&(o.maxStale=r(i["max-stale"])),a(i["min-fresh"])&&(o.minFresh=r(i["min-fresh"])),n(i["must-revalidate"])&&(o.mustRevalidate=!0),n(i["must-understand"])&&(o.mustUnderstand=!0),n(i["no-cache"])&&(o.noCache=!0),n(i["no-store"])&&(o.noStore=!0),n(i["no-transform"])&&(o.noTransform=!0),n(i["only-if-cached"])&&(o.onlyIfCached=!0),n(i.private)&&(o.private=!0),n(i["proxy-revalidate"])&&(o.proxyRevalidate=!0),n(i.public)&&(o.public=!0),a(i["s-maxage"])&&(o.sMaxAge=r(i["s-maxage"])),a(i["stale-if-error"])&&(o.staleIfError=r(i["stale-if-error"])),a(i["stale-while-revalidate"])&&(o.staleWhileRevalidate=r(i["stale-while-revalidate"])),o}}(t)},549:(e,t)=>{var r,a;r=t,a=Symbol("fast-defer"),r.deferred=function(){var e,t,r=new Promise(((r,a)=>{e=r,t=a}));return r.resolve=e,r.reject=t,r[a]=1,r},r.isDeferred=function(e){return!!e&&!!e[a]}},441:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useCache=void 0;var a=r(655),n=r(772),o=r(975),i=r(731),s=r(145),c=r(481);t.useCache=function(e,t){void 0===t&&(t={});var r=t.storage,u=t.generateKey,d=t.waiting,l=t.headerInterpreter,f=t.requestInterceptor,h=t.responseInterceptor,p=(0,a.__rest)(t,["storage","generateKey","waiting","headerInterpreter","requestInterceptor","responseInterceptor"]),v=e;return v.storage=r||new s.MemoryAxiosStorage,v.generateKey=u||c.defaultKeyGenerator,v.waiting=d||{},v.headerInterpreter=l||n.defaultHeaderInterpreter,v.requestInterceptor=f||new o.CacheRequestInterceptor(v),v.responseInterceptor=h||new i.CacheResponseInterceptor(v),v.defaults=(0,a.__assign)((0,a.__assign)({},e.defaults),{cache:(0,a.__assign)({ttl:3e5,interpretHeader:!1,methods:["get"],cachePredicate:{statusCheck:[200,399]},etag:!1,modifiedSince:!1,update:{}},p)}),v.requestInterceptor.use(),v.responseInterceptor.use(),v}},772:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultHeaderInterpreter=void 0;var a=r(86),n=r(750);t.defaultHeaderInterpreter=function(e){return void 0===e&&(e={}),n.Header.CacheControl in e?i(e[n.Header.CacheControl],e):n.Header.Expires in e?o(e[n.Header.Expires],e):void 0};var o=function(e){var t=Date.parse(e)-Date.now();return t>=0&&t},i=function(e,t){var r=(0,a.parse)(e),o=r.noCache,i=r.noStore,s=r.mustRevalidate,c=r.maxAge,u=r.immutable;if(o||i)return!1;if(u)return 31536e6;if(s)return 0;if(c){var d=t[n.Header.Age];return d?1e3*c-1e3*Number(d):1e3*c}}},54:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=r(655);(0,a.__exportStar)(r(441),t),(0,a.__exportStar)(r(931),t),(0,a.__exportStar)(r(145),t),(0,a.__exportStar)(r(499),t)},975:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CacheRequestInterceptor=void 0;var a=r(655),n=r(549),o=r(750),i=function(){function e(t){var r=this;this.axios=t,this.use=function(){r.axios.interceptors.request.use(r.onFulfilled)},this.onFulfilled=function(t){return(0,a.__awaiter)(r,void 0,void 0,(function(){var r,o,i,s,c;return(0,a.__generator)(this,(function(u){switch(u.label){case 0:return!1===t.cache?[2,t]:(t.cache=(0,a.__assign)((0,a.__assign)({},this.axios.defaults.cache),t.cache),e.isMethodAllowed(t.method,t.cache)?(r=this.axios.generateKey(t),[4,this.axios.storage.get(r)]):[2,t]);case 1:return"empty"!=(o=u.sent()).state&&"stale"!==o.state?[3,5]:this.axios.waiting[r]?[4,this.axios.storage.get(r)]:[3,3];case 2:return o=u.sent(),[3,5];case 3:return this.axios.waiting[r]=(0,n.deferred)(),null===(c=this.axios.waiting[r])||void 0===c||c.catch((function(){})),[4,this.axios.storage.set(r,{state:"loading",data:o.data})];case 4:return u.sent(),"stale"===o.state&&e.setRevalidationHeaders(o,t),t.validateStatus=e.createValidateStatus(t.validateStatus),[2,t];case 5:return"loading"!==o.state?[3,11]:(s=this.axios.waiting[r])?[3,7]:[4,this.axios.storage.remove(r)];case 6:return u.sent(),[2,t];case 7:return u.trys.push([7,9,,10]),[4,s];case 8:return i=u.sent(),[3,10];case 9:return u.sent(),[2,t];case 10:return[3,12];case 11:i=o.data,u.label=12;case 12:return t.adapter=function(){return Promise.resolve({config:t,data:i.data,headers:i.headers,status:i.status,statusText:i.statusText,cached:!0,id:r})},[2,t]}}))}))}}return e.isMethodAllowed=function(e,t){var r,n,o=e.toLowerCase();try{for(var i=(0,a.__values)(t.methods||[]),s=i.next();!s.done;s=i.next()){if(s.value.toLowerCase()===o)return!0}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return!1},e.setRevalidationHeaders=function(e,t){var r;t.headers||(t.headers={});var a=t.cache,n=a.etag,i=a.modifiedSince;if(n){var s=!0===n?null===(r=e.data)||void 0===r?void 0:r.headers[o.Header.ETag]:n;s&&(t.headers[o.Header.IfNoneMatch]=s)}i&&(t.headers[o.Header.IfModifiedSince]=!0===i?e.data.headers[o.Header.LastModified]||new Date(e.createdAt).toUTCString():i.toUTCString())},e.createValidateStatus=function(e){return function(t){return e?e(t)||304===t:t>=200&&t<300||304===t}},e}();t.CacheRequestInterceptor=i},731:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CacheResponseInterceptor=void 0;var a=r(655),n=r(916),o=r(750),i=r(786),s=function(){function e(t){var r=this;this.axios=t,this.use=function(){r.axios.interceptors.response.use(r.onFulfilled)},this.onFulfilled=function(t){return(0,a.__awaiter)(r,void 0,void 0,(function(){var r,s,c,u,d,l,f,h;return(0,a.__generator)(this,(function(p){switch(p.label){case 0:return(r=this.cachedResponse(t)).cached?[2,r]:r.config.cache?(s=r.config.cache,[4,this.axios.storage.get(r.id)]):[2,(0,a.__assign)((0,a.__assign)({},r),{cached:!1})];case 1:return"stale"===(c=p.sent()).state||"empty"===c.state||"cached"===c.state?[2,r]:c.data||(0,n.shouldCacheResponse)(r,s)?[3,3]:[4,this.rejectResponse(r.id)];case 2:return p.sent(),[2,r];case 3:return delete r.headers[o.Header.XAxiosCacheEtag],delete r.headers[o.Header.XAxiosCacheLastModified],s.etag&&!0!==s.etag&&(r.headers[o.Header.XAxiosCacheEtag]=s.etag),s.modifiedSince&&(r.headers[o.Header.XAxiosCacheLastModified]=!0===s.modifiedSince?"use-cache-timestamp":s.modifiedSince.toUTCString()),u=s.ttl||-1,(null==s?void 0:s.interpretHeader)?!1!==(d=this.axios.headerInterpreter(r.headers))?[3,5]:[4,this.rejectResponse(r.id)]:[3,6];case 4:return p.sent(),[2,r];case 5:u=d||0===d?d:u,p.label=6;case 6:return l=e.createCacheData(r,c.data),f={state:"cached",ttl:u,createdAt:Date.now(),data:l},(null==s?void 0:s.update)&&(0,i.updateCache)(this.axios.storage,r.data,s.update),[4,null==(h=this.axios.waiting[r.id])?void 0:h.resolve(f.data)];case 7:return p.sent(),delete this.axios.waiting[r.id],[4,this.axios.storage.set(r.id,f)];case 8:return p.sent(),[2,r]}}))}))},this.rejectResponse=function(e){return(0,a.__awaiter)(r,void 0,void 0,(function(){var t;return(0,a.__generator)(this,(function(r){switch(r.label){case 0:return[4,this.axios.storage.remove(e)];case 1:return r.sent(),null===(t=this.axios.waiting[e])||void 0===t||t.reject(null),delete this.axios.waiting[e],[2]}}))}))},this.cachedResponse=function(e){return(0,a.__assign)({id:r.axios.generateKey(e.config),cached:e.cached||!1},e)}}return e.createCacheData=function(e,t){return 304===e.status&&t?(e.cached=!0,e.data=t.data,e.status=t.status,e.statusText=t.statusText,e.headers=(0,a.__assign)((0,a.__assign)({},t.headers),e.headers),t):{data:e.data,status:e.status,statusText:e.statusText,headers:e.headers}},e}();t.CacheResponseInterceptor=s},931:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BrowserAxiosStorage=void 0;var a=r(655),n=function(e){function t(r,n){void 0===n&&(n=t.DEFAULT_KEY_PREFIX);var o=e.call(this)||this;return o.storage=r,o.prefix=n,o.find=function(e){return(0,a.__awaiter)(o,void 0,void 0,(function(){var t;return(0,a.__generator)(this,(function(r){return[2,(t=this.storage.getItem("".concat(this.prefix,":").concat(e)))?JSON.parse(t):{state:"empty"}]}))}))},o.set=function(e,t){return(0,a.__awaiter)(o,void 0,void 0,(function(){return(0,a.__generator)(this,(function(r){return[2,this.storage.setItem("".concat(this.prefix,":").concat(e),JSON.stringify(t))]}))}))},o.remove=function(e){return(0,a.__awaiter)(o,void 0,void 0,(function(){return(0,a.__generator)(this,(function(t){return[2,this.storage.removeItem("".concat(this.prefix,":").concat(e))]}))}))},o}return(0,a.__extends)(t,e),t.DEFAULT_KEY_PREFIX="a-c-i",t}(r(499).AxiosStorage);t.BrowserAxiosStorage=n},145:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MemoryAxiosStorage=void 0;var a=r(655),n=function(e){function t(t){void 0===t&&(t={});var r=e.call(this)||this;return r.storage=t,r.find=function(e){return(0,a.__awaiter)(r,void 0,void 0,(function(){return(0,a.__generator)(this,(function(t){return[2,this.storage[e]||{state:"empty"}]}))}))},r.set=function(e,t){return(0,a.__awaiter)(r,void 0,void 0,(function(){return(0,a.__generator)(this,(function(r){return this.storage[e]=t,[2]}))}))},r.remove=function(e){return(0,a.__awaiter)(r,void 0,void 0,(function(){return(0,a.__generator)(this,(function(t){return delete this.storage[e],[2]}))}))},r}return(0,a.__extends)(t,e),t}(r(499).AxiosStorage);t.MemoryAxiosStorage=n},499:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AxiosStorage=void 0;var a=r(655),n=r(750),o=function(){function e(){var t=this;this.get=function(r){return(0,a.__awaiter)(t,void 0,void 0,(function(){var t,n;return(0,a.__generator)(this,(function(a){switch(a.label){case 0:return[4,this.find(r)];case 1:return"cached"!==(t=a.sent()).state||t.createdAt+t.ttl>Date.now()?[2,t]:e.keepIfStale(t)?(n={data:t.data,state:"stale",createdAt:t.createdAt},[4,this.set(r,n)]):[3,3];case 2:return a.sent(),[2,n];case 3:return[4,this.remove(r)];case 4:return a.sent(),[2,{state:"empty"}]}}))}))}}return e.keepIfStale=function(e){var t=e.data;return!!(null==t?void 0:t.headers)&&(n.Header.ETag in t.headers||n.Header.LastModified in t.headers||n.Header.XAxiosCacheEtag in t.headers||n.Header.XAxiosCacheLastModified in t.headers)},e}();t.AxiosStorage=o},916:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isCachePredicateValid=t.shouldCacheResponse=void 0;var a=r(655);function n(e,t){var r=t.statusCheck,n=t.containsHeaders,o=t.responseMatch;if(r)if("function"==typeof r){if(!r(e.status))return!1}else{var i=(0,a.__read)(r,2),s=i[0],c=i[1];if(e.status<s||e.status>c)return!1}if(n)for(var u in n){var d=n[u],l=e.headers[u];if(!l)return!1;switch(typeof d){case"string":if(l!=d)return!1;break;case"function":if(!d(l))return!1}}return!(o&&!o(e.data))}t.shouldCacheResponse=function(e,t){var r=t.cachePredicate;return"function"==typeof r?r(e):n(e,r)},t.isCachePredicateValid=n},750:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Header=void 0,function(e){e.IfModifiedSince="if-modified-since",e.LastModified="last-modified",e.IfNoneMatch="if-none-match",e.CacheControl="cache-control",e.ETag="etag",e.Expires="expires",e.Age="age",e.ContentType="content-type",e.XAxiosCacheEtag="x-axios-cache-etag",e.XAxiosCacheLastModified="x-axios-cache-last-modified"}(t.Header||(t.Header={}))},481:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultKeyGenerator=void 0;var r=/^\/|\/+$/g;t.defaultKeyGenerator=function(e){var t=e.baseURL,a=void 0===t?"":t,n=e.url,o=void 0===n?"":n,i=e.method,s=e.params,c=e.id;if(c)return String(c);a=a.replace(r,""),o=o.replace(r,"");var u=(null==i?void 0:i.toLowerCase())||"get",d=s?JSON.stringify(s,Object.keys(s).sort()):"{}";return"".concat(u,"::").concat(a+(o&&a?"/":"")+o,"::").concat(d)}},786:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateCache=void 0;var a=r(655);t.updateCache=function(e,t,r){return(0,a.__awaiter)(this,void 0,void 0,(function(){var n,o,i,s,c,u,d;return(0,a.__generator)(this,(function(a){switch(a.label){case 0:for(o in n=[],r)n.push(o);i=0,a.label=1;case 1:return i<n.length?(s=n[i],"delete"!==(c=r[s])?[3,3]:[4,e.remove(s)]):[3,9];case 2:return a.sent(),[3,8];case 3:return[4,e.get(s)];case 4:if("loading"===(u=a.sent()).state)throw new Error("cannot update the cache while loading");return void 0!==(d=c(u,t))?[3,6]:[4,e.remove(s)];case 5:return a.sent(),[3,8];case 6:return[4,e.set(s,d)];case 7:a.sent(),a.label=8;case 8:return i++,[3,1];case 9:return[2]}}))}))}},655:(e,t,r)=>{"use strict";r.r(t),r.d(t,{__extends:()=>n,__assign:()=>o,__rest:()=>i,__decorate:()=>s,__param:()=>c,__metadata:()=>u,__awaiter:()=>d,__generator:()=>l,__createBinding:()=>f,__exportStar:()=>h,__values:()=>p,__read:()=>v,__spread:()=>_,__spreadArrays:()=>y,__spreadArray:()=>g,__await:()=>m,__asyncGenerator:()=>x,__asyncDelegator:()=>b,__asyncValues:()=>w,__makeTemplateObject:()=>S,__importStar:()=>O,__importDefault:()=>j,__classPrivateFieldGet:()=>P,__classPrivateFieldSet:()=>I});var a=function(e,t){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},a(e,t)};function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var o=function(){return o=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},o.apply(this,arguments)};function i(e,t){var r={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(r[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(a=Object.getOwnPropertySymbols(e);n<a.length;n++)t.indexOf(a[n])<0&&Object.prototype.propertyIsEnumerable.call(e,a[n])&&(r[a[n]]=e[a[n]])}return r}function s(e,t,r,a){var n,o=arguments.length,i=o<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,r):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,a);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(i=(o<3?n(i):o>3?n(t,r,i):n(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i}function c(e,t){return function(r,a){t(r,a,e)}}function u(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function d(e,t,r,a){return new(r||(r=Promise))((function(n,o){function i(e){try{c(a.next(e))}catch(e){o(e)}}function s(e){try{c(a.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}c((a=a.apply(e,t||[])).next())}))}function l(e,t){var r,a,n,o,i={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,a&&(n=2&o[0]?a.return:o[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,o[1])).done)return n;switch(a=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,a=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(n=i.trys,(n=n.length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){i.label=o[1];break}if(6===o[0]&&i.label<n[1]){i.label=n[1],n=o;break}if(n&&i.label<n[2]){i.label=n[2],i.ops.push(o);break}n[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],a=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}var f=Object.create?function(e,t,r,a){void 0===a&&(a=r),Object.defineProperty(e,a,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,a){void 0===a&&(a=r),e[a]=t[r]};function h(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||f(t,e,r)}function p(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],a=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function v(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var a,n,o=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(a=o.next()).done;)i.push(a.value)}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i}function _(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(v(arguments[t]));return e}function y(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var a=Array(e),n=0;for(t=0;t<r;t++)for(var o=arguments[t],i=0,s=o.length;i<s;i++,n++)a[n]=o[i];return a}function g(e,t,r){if(r||2===arguments.length)for(var a,n=0,o=t.length;n<o;n++)!a&&n in t||(a||(a=Array.prototype.slice.call(t,0,n)),a[n]=t[n]);return e.concat(a||Array.prototype.slice.call(t))}function m(e){return this instanceof m?(this.v=e,this):new m(e)}function x(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var a,n=r.apply(e,t||[]),o=[];return a={},i("next"),i("throw"),i("return"),a[Symbol.asyncIterator]=function(){return this},a;function i(e){n[e]&&(a[e]=function(t){return new Promise((function(r,a){o.push([e,t,r,a])>1||s(e,t)}))})}function s(e,t){try{(r=n[e](t)).value instanceof m?Promise.resolve(r.value.v).then(c,u):d(o[0][2],r)}catch(e){d(o[0][3],e)}var r}function c(e){s("next",e)}function u(e){s("throw",e)}function d(e,t){e(t),o.shift(),o.length&&s(o[0][0],o[0][1])}}function b(e){var t,r;return t={},a("next"),a("throw",(function(e){throw e})),a("return"),t[Symbol.iterator]=function(){return this},t;function a(a,n){t[a]=e[a]?function(t){return(r=!r)?{value:m(e[a](t)),done:"return"===a}:n?n(t):t}:n}}function w(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=p(e),t={},a("next"),a("throw"),a("return"),t[Symbol.asyncIterator]=function(){return this},t);function a(r){t[r]=e[r]&&function(t){return new Promise((function(a,n){(function(e,t,r,a){Promise.resolve(a).then((function(t){e({value:t,done:r})}),t)})(a,n,(t=e[r](t)).done,t.value)}))}}}function S(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var C=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function O(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&f(t,e,r);return C(t,e),t}function j(e){return e&&e.__esModule?e:{default:e}}function P(e,t,r,a){if("a"===r&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?a:"a"===r?a.call(e):a?a.value:t.get(e)}function I(e,t,r,a,n){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,r):n?n.value=r:t.set(e,r),r}}},t={};function r(a){var n=t[a];if(void 0!==n)return n.exports;var o=t[a]={exports:{}};return e[a](o,o.exports,r),o.exports}return r.d=(e,t)=>{for(var a in t)r.o(t,a)&&!r.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r(54)})()}));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.AxiosCacheInterceptor=t():e.AxiosCacheInterceptor=t()}(self,(function(){return(()=>{var e={86:(e,t)=>{!function(e){var t=Symbol("cache-parser"),r=Number;function a(e){return("string"==typeof e||"number"==typeof e)&&(e=r(e))>=0&&e<1/0}function n(e){return"number"==typeof e||!0===e||"string"==typeof e&&"false"!==e}e.__internal={isDuration:a,toBoolean:n},e.isCacheControl=function(e){return!!e&&!!e[t]},e.tokenize=function(e){if(!e||"object"!=typeof e)return[];var t=[];return n(e.immutable)&&t.push("immutable"),a(e.maxAge)&&t.push("max-age="+r(e.maxAge)),a(e.maxStale)&&t.push("max-stale="+r(e.maxStale)),a(e.minFresh)&&t.push("min-fresh="+r(e.minFresh)),n(e.mustRevalidate)&&t.push("must-revalidate"),n(e.mustUnderstand)&&t.push("must-understand"),n(e.noCache)&&t.push("no-cache"),n(e.noStore)&&t.push("no-store"),n(e.noTransform)&&t.push("no-transform"),n(e.onlyIfCached)&&t.push("only-if-cached"),n(e.private)&&t.push("private"),n(e.proxyRevalidate)&&t.push("proxy-revalidate"),n(e.public)&&t.push("public"),a(e.sMaxAge)&&t.push("s-maxage="+r(e.sMaxAge)),a(e.staleIfError)&&t.push("stale-if-error="+r(e.staleIfError)),a(e.staleWhileRevalidate)&&t.push("stale-while-revalidate="+r(e.staleWhileRevalidate)),t},e.parse=function(e){var o=Object.defineProperty({},t,{enumerable:!1,value:1});if(!e||"string"!=typeof e)return o;var i={},s=e.toLowerCase().replace(/\s+/g,"").split(",");for(var c in s){var u=s[c].split("=",2);i[u[0]]=1===u.length||u[1]}return n(i.immutable)&&(o.immutable=!0),a(i["max-age"])&&(o.maxAge=r(i["max-age"])),a(i["max-stale"])&&(o.maxStale=r(i["max-stale"])),a(i["min-fresh"])&&(o.minFresh=r(i["min-fresh"])),n(i["must-revalidate"])&&(o.mustRevalidate=!0),n(i["must-understand"])&&(o.mustUnderstand=!0),n(i["no-cache"])&&(o.noCache=!0),n(i["no-store"])&&(o.noStore=!0),n(i["no-transform"])&&(o.noTransform=!0),n(i["only-if-cached"])&&(o.onlyIfCached=!0),n(i.private)&&(o.private=!0),n(i["proxy-revalidate"])&&(o.proxyRevalidate=!0),n(i.public)&&(o.public=!0),a(i["s-maxage"])&&(o.sMaxAge=r(i["s-maxage"])),a(i["stale-if-error"])&&(o.staleIfError=r(i["stale-if-error"])),a(i["stale-while-revalidate"])&&(o.staleWhileRevalidate=r(i["stale-while-revalidate"])),o}}(t)},549:(e,t)=>{var r,a;r=t,a=Symbol("fast-defer"),r.deferred=function(){var e,t,r=new Promise(((r,a)=>{e=r,t=a}));return r.resolve=e,r.reject=t,r[a]=1,r},r.isDeferred=function(e){return!!e&&!!e[a]}},441:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useCache=t.createCache=void 0;var a=r(655),n=r(772),o=r(975),i=r(731),s=r(145),c=r(481);function u(e,t){void 0===t&&(t={});var r=t.storage,u=t.generateKey,d=t.waiting,l=t.headerInterpreter,f=t.requestInterceptor,h=t.responseInterceptor,p=(0,a.__rest)(t,["storage","generateKey","waiting","headerInterpreter","requestInterceptor","responseInterceptor"]),v=e;return v.storage=r||new s.MemoryAxiosStorage,v.generateKey=u||c.defaultKeyGenerator,v.waiting=d||{},v.headerInterpreter=l||n.defaultHeaderInterpreter,v.requestInterceptor=f||new o.CacheRequestInterceptor(v),v.responseInterceptor=h||new i.CacheResponseInterceptor(v),v.defaults=(0,a.__assign)((0,a.__assign)({},e.defaults),{cache:(0,a.__assign)({ttl:3e5,interpretHeader:!1,methods:["get"],cachePredicate:{statusCheck:[200,399]},etag:!1,modifiedSince:!1,update:{}},p)}),v.requestInterceptor.use(),v.responseInterceptor.use(),v}t.createCache=u,t.useCache=u},772:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultHeaderInterpreter=void 0;var a=r(86),n=r(750);t.defaultHeaderInterpreter=function(e){return void 0===e&&(e={}),n.Header.CacheControl in e?i(e[n.Header.CacheControl],e):n.Header.Expires in e?o(e[n.Header.Expires],e):void 0};var o=function(e){var t=Date.parse(e)-Date.now();return t>=0&&t},i=function(e,t){var r=(0,a.parse)(e),o=r.noCache,i=r.noStore,s=r.mustRevalidate,c=r.maxAge,u=r.immutable;if(o||i)return!1;if(u)return 31536e6;if(s)return 0;if(c){var d=t[n.Header.Age];return d?1e3*(c-Number(d)):1e3*c}}},54:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=r(655);(0,a.__exportStar)(r(441),t),(0,a.__exportStar)(r(931),t),(0,a.__exportStar)(r(145),t),(0,a.__exportStar)(r(499),t)},975:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CacheRequestInterceptor=void 0;var a=r(655),n=r(549),o=r(750),i=function(){function e(t){var r=this;this.axios=t,this.use=function(){r.axios.interceptors.request.use(r.onFulfilled)},this.onFulfilled=function(t){return(0,a.__awaiter)(r,void 0,void 0,(function(){var r,o,i,s,c;return(0,a.__generator)(this,(function(u){switch(u.label){case 0:return!1===t.cache?[2,t]:(t.cache=(0,a.__assign)((0,a.__assign)({},this.axios.defaults.cache),t.cache),e.isMethodAllowed(t.method,t.cache)?(r=this.axios.generateKey(t),[4,this.axios.storage.get(r)]):[2,t]);case 1:return"empty"!=(o=u.sent()).state&&"stale"!==o.state?[3,5]:this.axios.waiting[r]?[4,this.axios.storage.get(r)]:[3,3];case 2:return o=u.sent(),[3,5];case 3:return this.axios.waiting[r]=(0,n.deferred)(),null===(c=this.axios.waiting[r])||void 0===c||c.catch((function(){})),[4,this.axios.storage.set(r,{state:"loading",data:o.data})];case 4:return u.sent(),"stale"===o.state&&e.setRevalidationHeaders(o,t),t.validateStatus=e.createValidateStatus(t.validateStatus),[2,t];case 5:return"loading"!==o.state?[3,11]:(s=this.axios.waiting[r])?[3,7]:[4,this.axios.storage.remove(r)];case 6:return u.sent(),[2,t];case 7:return u.trys.push([7,9,,10]),[4,s];case 8:return i=u.sent(),[3,10];case 9:return u.sent(),[2,t];case 10:return[3,12];case 11:i=o.data,u.label=12;case 12:return t.adapter=function(){return Promise.resolve({config:t,data:i.data,headers:i.headers,status:i.status,statusText:i.statusText,cached:!0,id:r})},[2,t]}}))}))}}return e.isMethodAllowed=function(e,t){var r,n,o=e.toLowerCase();try{for(var i=(0,a.__values)(t.methods||[]),s=i.next();!s.done;s=i.next()){if(s.value.toLowerCase()===o)return!0}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return!1},e.setRevalidationHeaders=function(e,t){var r;t.headers||(t.headers={});var a=t.cache,n=a.etag,i=a.modifiedSince;if(n){var s=!0===n?null===(r=e.data)||void 0===r?void 0:r.headers[o.Header.ETag]:n;s&&(t.headers[o.Header.IfNoneMatch]=s)}i&&(t.headers[o.Header.IfModifiedSince]=!0===i?e.data.headers[o.Header.LastModified]||new Date(e.createdAt).toUTCString():i.toUTCString())},e.createValidateStatus=function(e){return function(t){return e?e(t)||304===t:t>=200&&t<300||304===t}},e}();t.CacheRequestInterceptor=i},731:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CacheResponseInterceptor=void 0;var a=r(655),n=r(916),o=r(750),i=r(786),s=function(){function e(t){var r=this;this.axios=t,this.use=function(){r.axios.interceptors.response.use(r.onFulfilled)},this.onFulfilled=function(t){return(0,a.__awaiter)(r,void 0,void 0,(function(){var r,s,c,u,d,l,f,h;return(0,a.__generator)(this,(function(p){switch(p.label){case 0:return(r=this.cachedResponse(t)).cached?[2,r]:r.config.cache?(s=r.config.cache,[4,this.axios.storage.get(r.id)]):[2,(0,a.__assign)((0,a.__assign)({},r),{cached:!1})];case 1:return"stale"===(c=p.sent()).state||"empty"===c.state||"cached"===c.state?[2,r]:c.data||(0,n.shouldCacheResponse)(r,s)?[3,3]:[4,this.rejectResponse(r.id)];case 2:return p.sent(),[2,r];case 3:return delete r.headers[o.Header.XAxiosCacheEtag],delete r.headers[o.Header.XAxiosCacheLastModified],s.etag&&!0!==s.etag&&(r.headers[o.Header.XAxiosCacheEtag]=s.etag),s.modifiedSince&&(r.headers[o.Header.XAxiosCacheLastModified]=!0===s.modifiedSince?"use-cache-timestamp":s.modifiedSince.toUTCString()),u=s.ttl||-1,(null==s?void 0:s.interpretHeader)?!1!==(d=this.axios.headerInterpreter(r.headers))?[3,5]:[4,this.rejectResponse(r.id)]:[3,6];case 4:return p.sent(),[2,r];case 5:u=d||0===d?d:u,p.label=6;case 6:return l=e.createCacheData(r,c.data),f={state:"cached",ttl:u,createdAt:Date.now(),data:l},(null==s?void 0:s.update)&&(0,i.updateCache)(this.axios.storage,r.data,s.update),[4,null==(h=this.axios.waiting[r.id])?void 0:h.resolve(f.data)];case 7:return p.sent(),delete this.axios.waiting[r.id],[4,this.axios.storage.set(r.id,f)];case 8:return p.sent(),[2,r]}}))}))},this.rejectResponse=function(e){return(0,a.__awaiter)(r,void 0,void 0,(function(){var t;return(0,a.__generator)(this,(function(r){switch(r.label){case 0:return[4,this.axios.storage.remove(e)];case 1:return r.sent(),null===(t=this.axios.waiting[e])||void 0===t||t.reject(null),delete this.axios.waiting[e],[2]}}))}))},this.cachedResponse=function(e){return(0,a.__assign)({id:r.axios.generateKey(e.config),cached:e.cached||!1},e)}}return e.createCacheData=function(e,t){return 304===e.status&&t?(e.cached=!0,e.data=t.data,e.status=t.status,e.statusText=t.statusText,e.headers=(0,a.__assign)((0,a.__assign)({},t.headers),e.headers),t):{data:e.data,status:e.status,statusText:e.statusText,headers:e.headers}},e}();t.CacheResponseInterceptor=s},931:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BrowserAxiosStorage=void 0;var a=r(655),n=function(e){function t(r,n){void 0===n&&(n=t.DEFAULT_KEY_PREFIX);var o=e.call(this)||this;return o.storage=r,o.prefix=n,o.find=function(e){return(0,a.__awaiter)(o,void 0,void 0,(function(){var t;return(0,a.__generator)(this,(function(r){return[2,(t=this.storage.getItem("".concat(this.prefix,":").concat(e)))?JSON.parse(t):{state:"empty"}]}))}))},o.set=function(e,t){return(0,a.__awaiter)(o,void 0,void 0,(function(){return(0,a.__generator)(this,(function(r){return[2,this.storage.setItem("".concat(this.prefix,":").concat(e),JSON.stringify(t))]}))}))},o.remove=function(e){return(0,a.__awaiter)(o,void 0,void 0,(function(){return(0,a.__generator)(this,(function(t){return[2,this.storage.removeItem("".concat(this.prefix,":").concat(e))]}))}))},o}return(0,a.__extends)(t,e),t.DEFAULT_KEY_PREFIX="a-c-i",t}(r(499).AxiosStorage);t.BrowserAxiosStorage=n},145:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MemoryAxiosStorage=void 0;var a=r(655),n=function(e){function t(t){void 0===t&&(t={});var r=e.call(this)||this;return r.storage=t,r.find=function(e){return(0,a.__awaiter)(r,void 0,void 0,(function(){return(0,a.__generator)(this,(function(t){return[2,this.storage[e]||{state:"empty"}]}))}))},r.set=function(e,t){return(0,a.__awaiter)(r,void 0,void 0,(function(){return(0,a.__generator)(this,(function(r){return this.storage[e]=t,[2]}))}))},r.remove=function(e){return(0,a.__awaiter)(r,void 0,void 0,(function(){return(0,a.__generator)(this,(function(t){return delete this.storage[e],[2]}))}))},r}return(0,a.__extends)(t,e),t}(r(499).AxiosStorage);t.MemoryAxiosStorage=n},499:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AxiosStorage=void 0;var a=r(655),n=r(750),o=function(){function e(){var t=this;this.get=function(r){return(0,a.__awaiter)(t,void 0,void 0,(function(){var t,n;return(0,a.__generator)(this,(function(a){switch(a.label){case 0:return[4,this.find(r)];case 1:return"cached"!==(t=a.sent()).state||t.createdAt+t.ttl>Date.now()?[2,t]:e.keepIfStale(t)?(n={data:t.data,state:"stale",createdAt:t.createdAt},[4,this.set(r,n)]):[3,3];case 2:return a.sent(),[2,n];case 3:return[4,this.remove(r)];case 4:return a.sent(),[2,{state:"empty"}]}}))}))}}return e.keepIfStale=function(e){var t=e.data;return!!(null==t?void 0:t.headers)&&(n.Header.ETag in t.headers||n.Header.LastModified in t.headers||n.Header.XAxiosCacheEtag in t.headers||n.Header.XAxiosCacheLastModified in t.headers)},e}();t.AxiosStorage=o},916:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isCachePredicateValid=t.shouldCacheResponse=void 0;var a=r(655);function n(e,t){var r=t.statusCheck,n=t.containsHeaders,o=t.responseMatch;if(r)if("function"==typeof r){if(!r(e.status))return!1}else{var i=(0,a.__read)(r,2),s=i[0],c=i[1];if(e.status<s||e.status>c)return!1}if(n)for(var u in n){var d=n[u],l=e.headers[u];if(!l)return!1;switch(typeof d){case"string":if(l!=d)return!1;break;case"function":if(!d(l))return!1}}return!(o&&!o(e.data))}t.shouldCacheResponse=function(e,t){var r=t.cachePredicate;return"function"==typeof r?r(e):n(e,r)},t.isCachePredicateValid=n},750:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Header=void 0,function(e){e.IfModifiedSince="if-modified-since",e.LastModified="last-modified",e.IfNoneMatch="if-none-match",e.CacheControl="cache-control",e.ETag="etag",e.Expires="expires",e.Age="age",e.ContentType="content-type",e.XAxiosCacheEtag="x-axios-cache-etag",e.XAxiosCacheLastModified="x-axios-cache-last-modified"}(t.Header||(t.Header={}))},481:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultKeyGenerator=void 0;var r=/^\/|\/+$/g;t.defaultKeyGenerator=function(e){var t=e.baseURL,a=void 0===t?"":t,n=e.url,o=void 0===n?"":n,i=e.method,s=e.params,c=e.id;if(c)return String(c);a=a.replace(r,""),o=o.replace(r,"");var u=(null==i?void 0:i.toLowerCase())||"get",d=s?JSON.stringify(s,Object.keys(s).sort()):"{}";return"".concat(u,"::").concat(a+(o&&a?"/":"")+o,"::").concat(d)}},786:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateCache=void 0;var a=r(655);t.updateCache=function(e,t,r){return(0,a.__awaiter)(this,void 0,void 0,(function(){var n,o,i,s,c,u,d;return(0,a.__generator)(this,(function(a){switch(a.label){case 0:for(o in n=[],r)n.push(o);i=0,a.label=1;case 1:return i<n.length?(s=n[i],"delete"!==(c=r[s])?[3,3]:[4,e.remove(s)]):[3,9];case 2:return a.sent(),[3,8];case 3:return[4,e.get(s)];case 4:if("loading"===(u=a.sent()).state)throw new Error("cannot update the cache while loading");return void 0!==(d=c(u,t))?[3,6]:[4,e.remove(s)];case 5:return a.sent(),[3,8];case 6:return[4,e.set(s,d)];case 7:a.sent(),a.label=8;case 8:return i++,[3,1];case 9:return[2]}}))}))}},655:(e,t,r)=>{"use strict";r.r(t),r.d(t,{__extends:()=>n,__assign:()=>o,__rest:()=>i,__decorate:()=>s,__param:()=>c,__metadata:()=>u,__awaiter:()=>d,__generator:()=>l,__createBinding:()=>f,__exportStar:()=>h,__values:()=>p,__read:()=>v,__spread:()=>_,__spreadArrays:()=>y,__spreadArray:()=>g,__await:()=>m,__asyncGenerator:()=>x,__asyncDelegator:()=>b,__asyncValues:()=>w,__makeTemplateObject:()=>S,__importStar:()=>O,__importDefault:()=>j,__classPrivateFieldGet:()=>P,__classPrivateFieldSet:()=>I});var a=function(e,t){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},a(e,t)};function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var o=function(){return o=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},o.apply(this,arguments)};function i(e,t){var r={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(r[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(a=Object.getOwnPropertySymbols(e);n<a.length;n++)t.indexOf(a[n])<0&&Object.prototype.propertyIsEnumerable.call(e,a[n])&&(r[a[n]]=e[a[n]])}return r}function s(e,t,r,a){var n,o=arguments.length,i=o<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,r):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,a);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(i=(o<3?n(i):o>3?n(t,r,i):n(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i}function c(e,t){return function(r,a){t(r,a,e)}}function u(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function d(e,t,r,a){return new(r||(r=Promise))((function(n,o){function i(e){try{c(a.next(e))}catch(e){o(e)}}function s(e){try{c(a.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}c((a=a.apply(e,t||[])).next())}))}function l(e,t){var r,a,n,o,i={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,a&&(n=2&o[0]?a.return:o[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,o[1])).done)return n;switch(a=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,a=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(n=i.trys,(n=n.length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){i.label=o[1];break}if(6===o[0]&&i.label<n[1]){i.label=n[1],n=o;break}if(n&&i.label<n[2]){i.label=n[2],i.ops.push(o);break}n[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],a=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}var f=Object.create?function(e,t,r,a){void 0===a&&(a=r),Object.defineProperty(e,a,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,a){void 0===a&&(a=r),e[a]=t[r]};function h(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||f(t,e,r)}function p(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],a=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function v(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var a,n,o=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(a=o.next()).done;)i.push(a.value)}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i}function _(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(v(arguments[t]));return e}function y(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var a=Array(e),n=0;for(t=0;t<r;t++)for(var o=arguments[t],i=0,s=o.length;i<s;i++,n++)a[n]=o[i];return a}function g(e,t,r){if(r||2===arguments.length)for(var a,n=0,o=t.length;n<o;n++)!a&&n in t||(a||(a=Array.prototype.slice.call(t,0,n)),a[n]=t[n]);return e.concat(a||Array.prototype.slice.call(t))}function m(e){return this instanceof m?(this.v=e,this):new m(e)}function x(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var a,n=r.apply(e,t||[]),o=[];return a={},i("next"),i("throw"),i("return"),a[Symbol.asyncIterator]=function(){return this},a;function i(e){n[e]&&(a[e]=function(t){return new Promise((function(r,a){o.push([e,t,r,a])>1||s(e,t)}))})}function s(e,t){try{(r=n[e](t)).value instanceof m?Promise.resolve(r.value.v).then(c,u):d(o[0][2],r)}catch(e){d(o[0][3],e)}var r}function c(e){s("next",e)}function u(e){s("throw",e)}function d(e,t){e(t),o.shift(),o.length&&s(o[0][0],o[0][1])}}function b(e){var t,r;return t={},a("next"),a("throw",(function(e){throw e})),a("return"),t[Symbol.iterator]=function(){return this},t;function a(a,n){t[a]=e[a]?function(t){return(r=!r)?{value:m(e[a](t)),done:"return"===a}:n?n(t):t}:n}}function w(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=p(e),t={},a("next"),a("throw"),a("return"),t[Symbol.asyncIterator]=function(){return this},t);function a(r){t[r]=e[r]&&function(t){return new Promise((function(a,n){(function(e,t,r,a){Promise.resolve(a).then((function(t){e({value:t,done:r})}),t)})(a,n,(t=e[r](t)).done,t.value)}))}}}function S(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var C=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function O(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&f(t,e,r);return C(t,e),t}function j(e){return e&&e.__esModule?e:{default:e}}function P(e,t,r,a){if("a"===r&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?a:"a"===r?a.call(e):a?a.value:t.get(e)}function I(e,t,r,a,n){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,r):n?n.value=r:t.set(e,r),r}}},t={};function r(a){var n=t[a];if(void 0!==n)return n.exports;var o=t[a]={exports:{}};return e[a](o,o.exports,r),o.exports}return r.d=(e,t)=>{for(var a in t)r.o(t,a)&&!r.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r(54)})()}));
//# sourceMappingURL=index.min.js.map
/* eslint-disable @typescript-eslint/no-var-requires */
const Axios = require('axios');
const { useCache } = require('axios-cache-interceptor');
const { createCache } = require('axios-cache-interceptor');

@@ -21,3 +21,3 @@ async function main() {

const axiosWithCache = useCache(axios, {
const axiosWithCache = createCache(axios, {
ttl: 99999,

@@ -24,0 +24,0 @@

{
"name": "axios-cache-interceptor",
"version": "0.7.6",
"version": "0.7.7",
"description": "Cache interceptor for axios",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

@@ -72,6 +72,6 @@ <br />

import axios from 'axios';
import { useCache, SessionCacheStorage } from 'axios-cache-interceptor';
import { createCache, SessionCacheStorage } from 'axios-cache-interceptor';
// An axios instance with modified types
const api = useCache(axios.create(), {
const api = createCache(axios.create(), {
/* options */

@@ -152,5 +152,5 @@ });

```js
const { useCache } = require('axios-cache-interceptor');
const { createCache } = require('axios-cache-interceptor');
// or
import { useCache } from 'axios-cache-interceptor';
import { createCache } from 'axios-cache-interceptor';
```

@@ -177,3 +177,3 @@

```js
const { useCache } = window.AxiosCacheInterceptor;
const { createCache } = window.AxiosCacheInterceptor;
```

@@ -206,3 +206,3 @@

```js
import { useCache } from 'axios-cache-interceptor';
import { createCache } from 'axios-cache-interceptor';

@@ -213,3 +213,3 @@ // Your axios instance

// Return the same axios instance, but with a modified Typescript type.
axios = useCache(axios, {
axios = createCache(axios, {
/* options here */

@@ -291,3 +291,3 @@ });

```js
const axios = useCache(axios, {
const axios = createCache(axios, {
// Properties here

@@ -294,0 +294,0 @@ });

@@ -19,3 +19,3 @@ import type { AxiosInstance } from 'axios';

*/
export function useCache(
export function createCache(
axios: AxiosInstance,

@@ -64,1 +64,12 @@ {

}
/**
* Apply the caching interceptors for a already created axios instance.
*
* @param axios The already created axios instance
* @param config The config for the caching interceptors
* @returns The same instance but with caching enabled
*
* @deprecated Prefer {@link createCache}
*/
export const useCache = createCache;

@@ -50,3 +50,3 @@ import { parse } from 'cache-parser';

return maxAge * 1000 - Number(age) * 1000;
return (maxAge - Number(age)) * 1000;
}

@@ -53,0 +53,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc