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.8.3 to 0.8.4

4

cjs/cache/axios.d.ts

@@ -60,4 +60,4 @@ import type { AxiosDefaults, AxiosInstance, AxiosInterceptorManager, AxiosRequestConfig, AxiosResponse } from 'axios';

interceptors: {
request: AxiosInterceptorManager<CacheRequestConfig<unknown, unknown>>;
response: AxiosInterceptorManager<CacheAxiosResponse<unknown, unknown>>;
request: AxiosInterceptorManager<CacheRequestConfig>;
response: AxiosInterceptorManager<CacheAxiosResponse>;
};

@@ -64,0 +64,0 @@ /** @template D The type that the request body use */

@@ -6,3 +6,3 @@ import type { Method } from 'axios';

import type { AxiosStorage, CachedResponse } from '../storage/types';
import type { CachePredicate, CacheUpdater, KeyGenerator } from '../util/types';
import type { CachePredicate, CacheUpdater, KeyGenerator, StaleIfErrorPredicate } from '../util/types';
import type { CacheAxiosResponse, CacheRequestConfig } from './axios';

@@ -73,2 +73,29 @@ /**

modifiedSince: Date | boolean;
/**
* Enables cache to be returned if the response comes with an error, either by invalid
* status code, network errors and etc. You can filter the type of error that should be
* stale by using a predicate function.
*
* **Note**: If the response is treated as error because of invalid status code *(like
* from AxiosRequestConfig#invalidateStatus)*, and this ends up `true`, the cache will
* be preserved over the "invalid" request. So, if you want to preserve the response,
* you can use this predicate:
*
* ```js
* const customPredicate = (response, cache, error) => {
* // Return false if has a response
* return !response;
* };
* ```
*
* Possible types:
*
* - `number` -> the max time (in seconds) that the cache can be reused.
* - `boolean` -> `false` disables and `true` enables with infinite time.
* - `function` -> a predicate that can return `number` or `boolean` as described above.
*
* @default false
* @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#stale-if-error
*/
staleIfError: StaleIfErrorPredicate<R, D>;
};

@@ -100,6 +127,6 @@ export interface CacheInstance {

/** The request interceptor that will be used to handle the cache. */
requestInterceptor: AxiosInterceptor<CacheRequestConfig<unknown, unknown>>;
requestInterceptor: AxiosInterceptor<CacheRequestConfig>;
/** The response interceptor that will be used to handle the cache. */
responseInterceptor: AxiosInterceptor<CacheAxiosResponse<unknown, unknown>>;
responseInterceptor: AxiosInterceptor<CacheAxiosResponse>;
}
//# sourceMappingURL=cache.d.ts.map

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

function setupCache(axios, options = {}) {
var _a, _b, _c, _d;
var _a, _b, _c, _d, _e;
const axiosCache = axios;

@@ -62,13 +62,14 @@ axiosCache.storage = options.storage || (0, memory_1.buildMemoryStorage)();

// CacheRequestConfig values
axiosCache.defaults = Object.assign(Object.assign({}, axios.defaults), { cache: {
ttl: (_a = options.ttl) !== null && _a !== void 0 ? _a : 1000 * 60 * 5,
interpretHeader: (_b = options.interpretHeader) !== null && _b !== void 0 ? _b : false,
methods: options.methods || ['get'],
cachePredicate: options.cachePredicate || {
statusCheck: (status) => status >= 200 && status < 400
},
etag: (_c = options.etag) !== null && _c !== void 0 ? _c : false,
modifiedSince: (_d = options.modifiedSince) !== null && _d !== void 0 ? _d : false,
update: options.update || {}
} });
axiosCache.defaults.cache = {
ttl: (_a = options.ttl) !== null && _a !== void 0 ? _a : 1000 * 60 * 5,
interpretHeader: (_b = options.interpretHeader) !== null && _b !== void 0 ? _b : false,
methods: options.methods || ['get'],
cachePredicate: options.cachePredicate || {
statusCheck: (status) => status >= 200 && status < 400
},
etag: (_c = options.etag) !== null && _c !== void 0 ? _c : false,
modifiedSince: (_d = options.modifiedSince) !== null && _d !== void 0 ? _d : false,
staleIfError: (_e = options.staleIfError) !== null && _e !== void 0 ? _e : false,
update: options.update || {}
};
// Apply interceptors

@@ -75,0 +76,0 @@ axiosCache.requestInterceptor.apply();

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

if (cacheControl) {
const { noCache, noStore, mustRevalidate, maxAge, immutable } = (0, cache_parser_1.parse)(cacheControl);
const { noCache, noStore, mustRevalidate, maxAge, immutable } = (0, cache_parser_1.parse)(String(cacheControl));
// Header told that this response should not be cached.

@@ -36,3 +36,3 @@ if (noCache || noStore) {

if (expires) {
const milliseconds = Date.parse(expires) - Date.now();
const milliseconds = Date.parse(String(expires)) - Date.now();
return milliseconds >= 0 ? milliseconds : 'dont cache';

@@ -39,0 +39,0 @@ }

@@ -0,1 +1,2 @@

import type { AxiosRequestHeaders } from 'axios';
export declare type InterpreterResult = 'dont cache' | 'not enough headers' | number;

@@ -10,3 +11,3 @@ /**

*/
export declare type HeadersInterpreter = (headers?: Record<string, string>) => InterpreterResult;
export declare type HeadersInterpreter = (headers?: AxiosRequestHeaders) => InterpreterResult;
/**

@@ -20,3 +21,3 @@ * Interpret a single string header

*/
export declare type HeaderInterpreter = (header: string, headers: Record<string, string>) => InterpreterResult;
export declare type HeaderInterpreter = (header: string, headers: AxiosRequestHeaders) => InterpreterResult;
//# sourceMappingURL=types.d.ts.map

@@ -5,7 +5,8 @@ import type { CacheAxiosResponse, CacheRequestConfig } from '../cache/axios';

onFulfilled?(value: T): T | Promise<T>;
onRejected?(error: unknown): unknown;
/** Returns a successful response or re-throws the error */
onRejected?(error: Record<string, unknown>): T | Promise<T>;
apply: () => void;
}
export declare type RequestInterceptor = AxiosInterceptor<CacheRequestConfig<unknown, unknown>>;
export declare type ResponseInterceptor = AxiosInterceptor<CacheAxiosResponse<unknown, unknown>>;
export declare type RequestInterceptor = AxiosInterceptor<CacheRequestConfig>;
export declare type ResponseInterceptor = AxiosInterceptor<CacheAxiosResponse>;
//# sourceMappingURL=build.d.ts.map
import type { AxiosCacheInstance } from '../cache/axios';
export declare function defaultRequestInterceptor(axios: AxiosCacheInstance): {
onFulfilled: (value: import("../cache/axios").CacheRequestConfig<unknown, unknown>) => import("../cache/axios").CacheRequestConfig<unknown, unknown> | Promise<import("../cache/axios").CacheRequestConfig<unknown, unknown>>;
onFulfilled: (value: import("../cache/axios").CacheRequestConfig<any, any>) => import("../cache/axios").CacheRequestConfig<any, any> | Promise<import("../cache/axios").CacheRequestConfig<any, any>>;
apply: () => number;
};
//# sourceMappingURL=request.d.ts.map

@@ -40,6 +40,11 @@ "use strict";

state: 'loading',
data: cache.data
previous: cache.state,
// Eslint complains a lot :)
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
data: cache.data,
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
createdAt: cache.createdAt
});
if (cache.state === 'stale') {
(0, util_1.setRevalidationHeaders)(cache, config);
(0, util_1.updateStaleRequest)(cache, config);
}

@@ -69,3 +74,3 @@ config.validateStatus = (0, util_1.createValidateStatus)(config.validateStatus);

}
//Even though the response interceptor receives this one from here,
// Even though the response interceptor receives this one from here,
// it has been configured to ignore cached responses = true

@@ -72,0 +77,0 @@ config.adapter = () => Promise.resolve({

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

*/
const rejectResponse = async ({ storage, waiting }, responseId) => {
const rejectResponse = async (responseId) => {
var _a;
// Update the cache to empty to prevent infinite loading state
await storage.remove(responseId);
await axios.storage.remove(responseId);
// Reject the deferred if present
(_a = waiting[responseId]) === null || _a === void 0 ? void 0 : _a.reject(null);
delete waiting[responseId];
(_a = axios.waiting[responseId]) === null || _a === void 0 ? void 0 : _a.reject(null);
delete axios.waiting[responseId];
};
const onFulfilled = async (response) => {
var _a, _b;
var _c;
response.id = (_a = (_c = response.config).id) !== null && _a !== void 0 ? _a : (_c.id = axios.generateKey(response.config));
var _a, _b, _c;
var _d;
response.id = (_a = (_d = response.config).id) !== null && _a !== void 0 ? _a : (_d.id = axios.generateKey(response.config));
(_b = response.cached) !== null && _b !== void 0 ? _b : (response.cached = false);

@@ -37,2 +37,3 @@ // Response is already cached

}
// Request interceptor merges defaults with per request configuration
const cacheConfig = response.config.cache;

@@ -53,8 +54,12 @@ const cache = await axios.storage.get(response.id);

!(await (0, cache_predicate_1.testCachePredicate)(response, cacheConfig.cachePredicate))) {
await rejectResponse(axios, response.id);
await rejectResponse(response.id);
return response;
}
// avoid remnant headers from remote server to break implementation
delete response.headers[headers_1.Header.XAxiosCacheEtag];
delete response.headers[headers_1.Header.XAxiosCacheLastModified];
for (const header in headers_1.Header) {
if (!header.startsWith('XAxiosCache')) {
continue;
}
delete response.headers[header];
}
if (cacheConfig.etag && cacheConfig.etag !== true) {

@@ -74,3 +79,3 @@ response.headers[headers_1.Header.XAxiosCacheEtag] = cacheConfig.etag;

if (expirationTime === 'dont cache') {
await rejectResponse(axios, response.id);
await rejectResponse(response.id);
return response;

@@ -84,2 +89,9 @@ }

}
if (cacheConfig.staleIfError) {
response.headers[headers_1.Header.XAxiosCacheStaleIfError] = String(ttl);
}
// Update other entries before updating himself
if (cacheConfig === null || cacheConfig === void 0 ? void 0 : cacheConfig.update) {
await (0, update_cache_1.updateCache)(axios.storage, response, cacheConfig.update);
}
const newCache = {

@@ -91,9 +103,4 @@ state: 'cached',

};
// Update other entries before updating himself
if (cacheConfig === null || cacheConfig === void 0 ? void 0 : cacheConfig.update) {
await (0, update_cache_1.updateCache)(axios.storage, response, cacheConfig.update);
}
const deferred = axios.waiting[response.id];
// Resolve all other requests waiting for this response
deferred === null || deferred === void 0 ? void 0 : deferred.resolve(newCache.data);
(_c = axios.waiting[response.id]) === null || _c === void 0 ? void 0 : _c.resolve(newCache.data);
delete axios.waiting[response.id];

@@ -105,7 +112,52 @@ // Define this key as cache on the storage

};
const onRejected = async (error) => {
var _a;
const config = error['config'];
if (!config || config.cache === false || !config.id) {
throw error;
}
const cache = await axios.storage.get(config.id);
const cacheConfig = config.cache;
if (
// This will only not be loading if the interceptor broke
cache.state !== 'loading' ||
cache.previous !== 'stale') {
await rejectResponse(config.id);
throw error;
}
if (cacheConfig === null || cacheConfig === void 0 ? void 0 : cacheConfig.staleIfError) {
const staleIfError = typeof cacheConfig.staleIfError === 'function'
? await cacheConfig.staleIfError(error.response, cache, error)
: cacheConfig.staleIfError;
if (staleIfError === true ||
// staleIfError is the number of seconds that stale is allowed to be used
(typeof staleIfError === 'number' && cache.createdAt + staleIfError > Date.now())) {
// Resolve all other requests waiting for this response
(_a = axios.waiting[config.id]) === null || _a === void 0 ? void 0 : _a.resolve(cache.data);
delete axios.waiting[config.id];
// re-mark the cache as stale
await axios.storage.set(config.id, {
state: 'stale',
createdAt: Date.now(),
data: cache.data
});
return {
cached: true,
config,
id: config.id,
data: cache.data.data,
headers: cache.data.headers,
status: cache.data.status,
statusText: cache.data.statusText
};
}
}
throw error;
};
return {
onFulfilled,
apply: () => axios.interceptors.response.use(onFulfilled)
onRejected,
apply: () => axios.interceptors.response.use(onFulfilled, onRejected)
};
}
exports.defaultResponseInterceptor = defaultResponseInterceptor;

@@ -15,4 +15,8 @@ import type { Method } from 'axios';

};
export declare function setRevalidationHeaders<D>(cache: StaleStorageValue, config: ConfigWithCache<D>): void;
/**
* This function updates the cache when the request is stale. So, the next request to the
* server will be made with proper header / settings.
*/
export declare function updateStaleRequest<D>(cache: StaleStorageValue, config: ConfigWithCache<D>): void;
/**
* Creates the new date to the cache by the provided response. Also handles possible 304

@@ -19,0 +23,0 @@ * Not Modified by updating response properties.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createCacheResponse = exports.setRevalidationHeaders = exports.isMethodIn = exports.createValidateStatus = void 0;
exports.createCacheResponse = exports.updateStaleRequest = exports.isMethodIn = exports.createValidateStatus = void 0;
const headers_1 = require("../util/headers");

@@ -26,3 +26,7 @@ /**

exports.isMethodIn = isMethodIn;
function setRevalidationHeaders(cache, config) {
/**
* This function updates the cache when the request is stale. So, the next request to the
* server will be made with proper header / settings.
*/
function updateStaleRequest(cache, config) {
var _a;

@@ -46,3 +50,3 @@ config.headers || (config.headers = {});

}
exports.setRevalidationHeaders = setRevalidationHeaders;
exports.updateStaleRequest = updateStaleRequest;
/**

@@ -49,0 +53,0 @@ * Creates the new date to the cache by the provided response. Also handles possible 304

@@ -44,10 +44,12 @@ "use strict";

if (value.data.headers &&
// Any header below allows the response to stale
(headers_1.Header.ETag in value.data.headers ||
headers_1.Header.LastModified in value.data.headers ||
headers_1.Header.XAxiosCacheEtag in value.data.headers ||
headers_1.Header.XAxiosCacheStaleIfError in value.data.headers ||
headers_1.Header.XAxiosCacheLastModified in value.data.headers)) {
const stale = {
data: value.data,
state: 'stale',
createdAt: value.createdAt
createdAt: value.createdAt,
data: value.data
};

@@ -54,0 +56,0 @@ await set(key, stale);

@@ -11,2 +11,7 @@ import type { MaybePromise } from '../util/types';

export declare type NotEmptyStorageValue = Exclude<StorageValue, EmptyStorageValue>;
export declare type StorageMetadata = {
/** If the request can be stale */
shouldStale?: boolean;
[key: string]: unknown;
};
export declare type StaleStorageValue = {

@@ -26,11 +31,13 @@ data: CachedResponse;

export declare type LoadingStorageValue = {
/**
* Only present if the previous state was `stale`. So, in case the new response comes
* without a value, this data is used
*/
data?: CachedResponse;
ttl?: number;
/** Defined when the state is cached */
data?: undefined;
ttl?: undefined;
createdAt?: undefined;
state: 'loading';
previous: 'empty';
} | {
state: 'loading';
data: CachedResponse;
ttl?: undefined;
createdAt: number;
previous: 'stale';
};

@@ -37,0 +44,0 @@ export declare type EmptyStorageValue = {

@@ -1,2 +0,2 @@

export declare const Header: {
export declare const Header: Readonly<{
/**

@@ -28,3 +28,9 @@ * ```txt

IfNoneMatch: string;
/** @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control */
/**
* ```txt
* Cache-Control: max-age=604800
* ```
*
* @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
*/
CacheControl: string;

@@ -66,4 +72,4 @@ /**

/**
* Used internally to mark the cache item as being revalidatable and enabling stale
* cache state Contains a string of ASCII characters that can be used as ETag for
* Used internally as metadata to mark the cache item as revalidatable and enabling
* stale cache state Contains a string of ASCII characters that can be used as ETag for
* `If-Match` header Provided by user using `cache.etag` value.

@@ -77,7 +83,7 @@ *

/**
* Used internally to mark the cache item as being revalidatable and enabling stale
* cache state may contain `'use-cache-timestamp'` if `cache.modifiedSince` is `true`,
* otherwise will contain a date from `cache.modifiedSince`. If a date is provided, it
* can be used for `If-Modified-Since` header, otherwise the cache timestamp can be used
* for `If-Modified-Since` header.
* Used internally as metadata to mark the cache item as revalidatable and enabling
* stale cache state may contain `'use-cache-timestamp'` if `cache.modifiedSince` is
* `true`, otherwise will contain a date from `cache.modifiedSince`. If a date is
* provided, it can be used for `If-Modified-Since` header, otherwise the cache
* timestamp can be used for `If-Modified-Since` header.
*

@@ -90,3 +96,13 @@ * ```txt

XAxiosCacheLastModified: string;
};
/**
* Used internally as metadata to mark the cache item able to be used if the server
* returns an error. The stale-if-error response directive indicates that the cache can
* reuse a stale response when any error occurs.
*
* ```txt
* XAxiosCacheStaleIfError: <seconds>
* ```
*/
XAxiosCacheStaleIfError: string;
}>;
//# sourceMappingURL=headers.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Header = void 0;
exports.Header = {
exports.Header = Object.freeze({
/**

@@ -31,3 +31,9 @@ * ```txt

IfNoneMatch: 'if-none-match',
/** @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control */
/**
* ```txt
* Cache-Control: max-age=604800
* ```
*
* @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
*/
CacheControl: 'cache-control',

@@ -69,4 +75,4 @@ /**

/**
* Used internally to mark the cache item as being revalidatable and enabling stale
* cache state Contains a string of ASCII characters that can be used as ETag for
* Used internally as metadata to mark the cache item as revalidatable and enabling
* stale cache state Contains a string of ASCII characters that can be used as ETag for
* `If-Match` header Provided by user using `cache.etag` value.

@@ -80,7 +86,7 @@ *

/**
* Used internally to mark the cache item as being revalidatable and enabling stale
* cache state may contain `'use-cache-timestamp'` if `cache.modifiedSince` is `true`,
* otherwise will contain a date from `cache.modifiedSince`. If a date is provided, it
* can be used for `If-Modified-Since` header, otherwise the cache timestamp can be used
* for `If-Modified-Since` header.
* Used internally as metadata to mark the cache item as revalidatable and enabling
* stale cache state may contain `'use-cache-timestamp'` if `cache.modifiedSince` is
* `true`, otherwise will contain a date from `cache.modifiedSince`. If a date is
* provided, it can be used for `If-Modified-Since` header, otherwise the cache
* timestamp can be used for `If-Modified-Since` header.
*

@@ -92,3 +98,13 @@ * ```txt

*/
XAxiosCacheLastModified: 'x-axios-cache-last-modified'
};
XAxiosCacheLastModified: 'x-axios-cache-last-modified',
/**
* Used internally as metadata to mark the cache item able to be used if the server
* returns an error. The stale-if-error response directive indicates that the cache can
* reuse a stale response when any error occurs.
*
* ```txt
* XAxiosCacheStaleIfError: <seconds>
* ```
*/
XAxiosCacheStaleIfError: 'x-axios-cache-stale-if-error'
});

@@ -23,2 +23,13 @@ import type { CacheAxiosResponse, CacheRequestConfig } from '../cache/axios';

export declare type CacheUpdater<R, D> = 'delete' | ((cached: Exclude<StorageValue, LoadingStorageValue>, response: CacheAxiosResponse<R, D>) => MaybePromise<CachedStorageValue | 'delete' | 'ignore'>);
/**
* You can use a `number` to ensure an max time (in seconds) that the cache can be reused.
*
* You can use `true` to use the cache until a new response is received.
*
* You can use a `function` predicate to determine if the cache can be reused (`boolean`)
* or how much time the cache can be used (`number`)
*/
export declare type StaleIfErrorPredicate<R, D> = number | boolean | ((networkResponse: CacheAxiosResponse<R, D> | undefined, cache: LoadingStorageValue & {
previous: 'stale';
}, error: Record<string, unknown>) => MaybePromise<number | boolean>);
//# sourceMappingURL=types.d.ts.map

@@ -60,4 +60,4 @@ import type { AxiosDefaults, AxiosInstance, AxiosInterceptorManager, AxiosRequestConfig, AxiosResponse } from 'axios';

interceptors: {
request: AxiosInterceptorManager<CacheRequestConfig<unknown, unknown>>;
response: AxiosInterceptorManager<CacheAxiosResponse<unknown, unknown>>;
request: AxiosInterceptorManager<CacheRequestConfig>;
response: AxiosInterceptorManager<CacheAxiosResponse>;
};

@@ -64,0 +64,0 @@ /** @template D The type that the request body use */

@@ -6,3 +6,3 @@ import type { Method } from 'axios';

import type { AxiosStorage, CachedResponse } from '../storage/types';
import type { CachePredicate, CacheUpdater, KeyGenerator } from '../util/types';
import type { CachePredicate, CacheUpdater, KeyGenerator, StaleIfErrorPredicate } from '../util/types';
import type { CacheAxiosResponse, CacheRequestConfig } from './axios';

@@ -73,2 +73,29 @@ /**

modifiedSince: Date | boolean;
/**
* Enables cache to be returned if the response comes with an error, either by invalid
* status code, network errors and etc. You can filter the type of error that should be
* stale by using a predicate function.
*
* **Note**: If the response is treated as error because of invalid status code *(like
* from AxiosRequestConfig#invalidateStatus)*, and this ends up `true`, the cache will
* be preserved over the "invalid" request. So, if you want to preserve the response,
* you can use this predicate:
*
* ```js
* const customPredicate = (response, cache, error) => {
* // Return false if has a response
* return !response;
* };
* ```
*
* Possible types:
*
* - `number` -> the max time (in seconds) that the cache can be reused.
* - `boolean` -> `false` disables and `true` enables with infinite time.
* - `function` -> a predicate that can return `number` or `boolean` as described above.
*
* @default false
* @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#stale-if-error
*/
staleIfError: StaleIfErrorPredicate<R, D>;
};

@@ -100,6 +127,6 @@ export interface CacheInstance {

/** The request interceptor that will be used to handle the cache. */
requestInterceptor: AxiosInterceptor<CacheRequestConfig<unknown, unknown>>;
requestInterceptor: AxiosInterceptor<CacheRequestConfig>;
/** The response interceptor that will be used to handle the cache. */
responseInterceptor: AxiosInterceptor<CacheAxiosResponse<unknown, unknown>>;
responseInterceptor: AxiosInterceptor<CacheAxiosResponse>;
}
//# sourceMappingURL=cache.d.ts.map

@@ -44,3 +44,3 @@ import { defaultHeaderInterpreter } from '../header/interpreter';

export function setupCache(axios, options = {}) {
var _a, _b, _c, _d;
var _a, _b, _c, _d, _e;
const axiosCache = axios;

@@ -59,13 +59,14 @@ axiosCache.storage = options.storage || buildMemoryStorage();

// CacheRequestConfig values
axiosCache.defaults = Object.assign(Object.assign({}, axios.defaults), { cache: {
ttl: (_a = options.ttl) !== null && _a !== void 0 ? _a : 1000 * 60 * 5,
interpretHeader: (_b = options.interpretHeader) !== null && _b !== void 0 ? _b : false,
methods: options.methods || ['get'],
cachePredicate: options.cachePredicate || {
statusCheck: (status) => status >= 200 && status < 400
},
etag: (_c = options.etag) !== null && _c !== void 0 ? _c : false,
modifiedSince: (_d = options.modifiedSince) !== null && _d !== void 0 ? _d : false,
update: options.update || {}
} });
axiosCache.defaults.cache = {
ttl: (_a = options.ttl) !== null && _a !== void 0 ? _a : 1000 * 60 * 5,
interpretHeader: (_b = options.interpretHeader) !== null && _b !== void 0 ? _b : false,
methods: options.methods || ['get'],
cachePredicate: options.cachePredicate || {
statusCheck: (status) => status >= 200 && status < 400
},
etag: (_c = options.etag) !== null && _c !== void 0 ? _c : false,
modifiedSince: (_d = options.modifiedSince) !== null && _d !== void 0 ? _d : false,
staleIfError: (_e = options.staleIfError) !== null && _e !== void 0 ? _e : false,
update: options.update || {}
};
// Apply interceptors

@@ -72,0 +73,0 @@ axiosCache.requestInterceptor.apply();

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

if (cacheControl) {
const { noCache, noStore, mustRevalidate, maxAge, immutable } = parse(cacheControl);
const { noCache, noStore, mustRevalidate, maxAge, immutable } = parse(String(cacheControl));
// Header told that this response should not be cached.

@@ -33,3 +33,3 @@ if (noCache || noStore) {

if (expires) {
const milliseconds = Date.parse(expires) - Date.now();
const milliseconds = Date.parse(String(expires)) - Date.now();
return milliseconds >= 0 ? milliseconds : 'dont cache';

@@ -36,0 +36,0 @@ }

@@ -0,1 +1,2 @@

import type { AxiosRequestHeaders } from 'axios';
export declare type InterpreterResult = 'dont cache' | 'not enough headers' | number;

@@ -10,3 +11,3 @@ /**

*/
export declare type HeadersInterpreter = (headers?: Record<string, string>) => InterpreterResult;
export declare type HeadersInterpreter = (headers?: AxiosRequestHeaders) => InterpreterResult;
/**

@@ -20,3 +21,3 @@ * Interpret a single string header

*/
export declare type HeaderInterpreter = (header: string, headers: Record<string, string>) => InterpreterResult;
export declare type HeaderInterpreter = (header: string, headers: AxiosRequestHeaders) => InterpreterResult;
//# sourceMappingURL=types.d.ts.map

@@ -5,7 +5,8 @@ import type { CacheAxiosResponse, CacheRequestConfig } from '../cache/axios';

onFulfilled?(value: T): T | Promise<T>;
onRejected?(error: unknown): unknown;
/** Returns a successful response or re-throws the error */
onRejected?(error: Record<string, unknown>): T | Promise<T>;
apply: () => void;
}
export declare type RequestInterceptor = AxiosInterceptor<CacheRequestConfig<unknown, unknown>>;
export declare type ResponseInterceptor = AxiosInterceptor<CacheAxiosResponse<unknown, unknown>>;
export declare type RequestInterceptor = AxiosInterceptor<CacheRequestConfig>;
export declare type ResponseInterceptor = AxiosInterceptor<CacheAxiosResponse>;
//# sourceMappingURL=build.d.ts.map
import type { AxiosCacheInstance } from '../cache/axios';
export declare function defaultRequestInterceptor(axios: AxiosCacheInstance): {
onFulfilled: (value: import("../cache/axios").CacheRequestConfig<unknown, unknown>) => import("../cache/axios").CacheRequestConfig<unknown, unknown> | Promise<import("../cache/axios").CacheRequestConfig<unknown, unknown>>;
onFulfilled: (value: import("../cache/axios").CacheRequestConfig<any, any>) => import("../cache/axios").CacheRequestConfig<any, any> | Promise<import("../cache/axios").CacheRequestConfig<any, any>>;
apply: () => number;
};
//# sourceMappingURL=request.d.ts.map
import { deferred } from 'fast-defer';
import { createValidateStatus, isMethodIn, setRevalidationHeaders } from './util';
import { createValidateStatus, isMethodIn, updateStaleRequest } from './util';
export function defaultRequestInterceptor(axios) {

@@ -37,6 +37,11 @@ const onFulfilled = async (config) => {

state: 'loading',
data: cache.data
previous: cache.state,
// Eslint complains a lot :)
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
data: cache.data,
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
createdAt: cache.createdAt
});
if (cache.state === 'stale') {
setRevalidationHeaders(cache, config);
updateStaleRequest(cache, config);
}

@@ -66,3 +71,3 @@ config.validateStatus = createValidateStatus(config.validateStatus);

}
//Even though the response interceptor receives this one from here,
// Even though the response interceptor receives this one from here,
// it has been configured to ignore cached responses = true

@@ -69,0 +74,0 @@ config.adapter = () => Promise.resolve({

@@ -11,14 +11,14 @@ import { testCachePredicate } from '../util/cache-predicate';

*/
const rejectResponse = async ({ storage, waiting }, responseId) => {
const rejectResponse = async (responseId) => {
var _a;
// Update the cache to empty to prevent infinite loading state
await storage.remove(responseId);
await axios.storage.remove(responseId);
// Reject the deferred if present
(_a = waiting[responseId]) === null || _a === void 0 ? void 0 : _a.reject(null);
delete waiting[responseId];
(_a = axios.waiting[responseId]) === null || _a === void 0 ? void 0 : _a.reject(null);
delete axios.waiting[responseId];
};
const onFulfilled = async (response) => {
var _a, _b;
var _c;
response.id = (_a = (_c = response.config).id) !== null && _a !== void 0 ? _a : (_c.id = axios.generateKey(response.config));
var _a, _b, _c;
var _d;
response.id = (_a = (_d = response.config).id) !== null && _a !== void 0 ? _a : (_d.id = axios.generateKey(response.config));
(_b = response.cached) !== null && _b !== void 0 ? _b : (response.cached = false);

@@ -34,2 +34,3 @@ // Response is already cached

}
// Request interceptor merges defaults with per request configuration
const cacheConfig = response.config.cache;

@@ -50,8 +51,12 @@ const cache = await axios.storage.get(response.id);

!(await testCachePredicate(response, cacheConfig.cachePredicate))) {
await rejectResponse(axios, response.id);
await rejectResponse(response.id);
return response;
}
// avoid remnant headers from remote server to break implementation
delete response.headers[Header.XAxiosCacheEtag];
delete response.headers[Header.XAxiosCacheLastModified];
for (const header in Header) {
if (!header.startsWith('XAxiosCache')) {
continue;
}
delete response.headers[header];
}
if (cacheConfig.etag && cacheConfig.etag !== true) {

@@ -71,3 +76,3 @@ response.headers[Header.XAxiosCacheEtag] = cacheConfig.etag;

if (expirationTime === 'dont cache') {
await rejectResponse(axios, response.id);
await rejectResponse(response.id);
return response;

@@ -81,2 +86,9 @@ }

}
if (cacheConfig.staleIfError) {
response.headers[Header.XAxiosCacheStaleIfError] = String(ttl);
}
// Update other entries before updating himself
if (cacheConfig === null || cacheConfig === void 0 ? void 0 : cacheConfig.update) {
await updateCache(axios.storage, response, cacheConfig.update);
}
const newCache = {

@@ -88,9 +100,4 @@ state: 'cached',

};
// Update other entries before updating himself
if (cacheConfig === null || cacheConfig === void 0 ? void 0 : cacheConfig.update) {
await updateCache(axios.storage, response, cacheConfig.update);
}
const deferred = axios.waiting[response.id];
// Resolve all other requests waiting for this response
deferred === null || deferred === void 0 ? void 0 : deferred.resolve(newCache.data);
(_c = axios.waiting[response.id]) === null || _c === void 0 ? void 0 : _c.resolve(newCache.data);
delete axios.waiting[response.id];

@@ -102,6 +109,51 @@ // Define this key as cache on the storage

};
const onRejected = async (error) => {
var _a;
const config = error['config'];
if (!config || config.cache === false || !config.id) {
throw error;
}
const cache = await axios.storage.get(config.id);
const cacheConfig = config.cache;
if (
// This will only not be loading if the interceptor broke
cache.state !== 'loading' ||
cache.previous !== 'stale') {
await rejectResponse(config.id);
throw error;
}
if (cacheConfig === null || cacheConfig === void 0 ? void 0 : cacheConfig.staleIfError) {
const staleIfError = typeof cacheConfig.staleIfError === 'function'
? await cacheConfig.staleIfError(error.response, cache, error)
: cacheConfig.staleIfError;
if (staleIfError === true ||
// staleIfError is the number of seconds that stale is allowed to be used
(typeof staleIfError === 'number' && cache.createdAt + staleIfError > Date.now())) {
// Resolve all other requests waiting for this response
(_a = axios.waiting[config.id]) === null || _a === void 0 ? void 0 : _a.resolve(cache.data);
delete axios.waiting[config.id];
// re-mark the cache as stale
await axios.storage.set(config.id, {
state: 'stale',
createdAt: Date.now(),
data: cache.data
});
return {
cached: true,
config,
id: config.id,
data: cache.data.data,
headers: cache.data.headers,
status: cache.data.status,
statusText: cache.data.statusText
};
}
}
throw error;
};
return {
onFulfilled,
apply: () => axios.interceptors.response.use(onFulfilled)
onRejected,
apply: () => axios.interceptors.response.use(onFulfilled, onRejected)
};
}

@@ -15,4 +15,8 @@ import type { Method } from 'axios';

};
export declare function setRevalidationHeaders<D>(cache: StaleStorageValue, config: ConfigWithCache<D>): void;
/**
* This function updates the cache when the request is stale. So, the next request to the
* server will be made with proper header / settings.
*/
export declare function updateStaleRequest<D>(cache: StaleStorageValue, config: ConfigWithCache<D>): void;
/**
* Creates the new date to the cache by the provided response. Also handles possible 304

@@ -19,0 +23,0 @@ * Not Modified by updating response properties.

@@ -21,3 +21,7 @@ import { Header } from '../util/headers';

}
export function setRevalidationHeaders(cache, config) {
/**
* This function updates the cache when the request is stale. So, the next request to the
* server will be made with proper header / settings.
*/
export function updateStaleRequest(cache, config) {
var _a;

@@ -24,0 +28,0 @@ config.headers || (config.headers = {});

@@ -40,10 +40,12 @@ import { Header } from '../util/headers';

if (value.data.headers &&
// Any header below allows the response to stale
(Header.ETag in value.data.headers ||
Header.LastModified in value.data.headers ||
Header.XAxiosCacheEtag in value.data.headers ||
Header.XAxiosCacheStaleIfError in value.data.headers ||
Header.XAxiosCacheLastModified in value.data.headers)) {
const stale = {
data: value.data,
state: 'stale',
createdAt: value.createdAt
createdAt: value.createdAt,
data: value.data
};

@@ -50,0 +52,0 @@ await set(key, stale);

@@ -11,2 +11,7 @@ import type { MaybePromise } from '../util/types';

export declare type NotEmptyStorageValue = Exclude<StorageValue, EmptyStorageValue>;
export declare type StorageMetadata = {
/** If the request can be stale */
shouldStale?: boolean;
[key: string]: unknown;
};
export declare type StaleStorageValue = {

@@ -26,11 +31,13 @@ data: CachedResponse;

export declare type LoadingStorageValue = {
/**
* Only present if the previous state was `stale`. So, in case the new response comes
* without a value, this data is used
*/
data?: CachedResponse;
ttl?: number;
/** Defined when the state is cached */
data?: undefined;
ttl?: undefined;
createdAt?: undefined;
state: 'loading';
previous: 'empty';
} | {
state: 'loading';
data: CachedResponse;
ttl?: undefined;
createdAt: number;
previous: 'stale';
};

@@ -37,0 +44,0 @@ export declare type EmptyStorageValue = {

@@ -1,2 +0,2 @@

export declare const Header: {
export declare const Header: Readonly<{
/**

@@ -28,3 +28,9 @@ * ```txt

IfNoneMatch: string;
/** @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control */
/**
* ```txt
* Cache-Control: max-age=604800
* ```
*
* @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
*/
CacheControl: string;

@@ -66,4 +72,4 @@ /**

/**
* Used internally to mark the cache item as being revalidatable and enabling stale
* cache state Contains a string of ASCII characters that can be used as ETag for
* Used internally as metadata to mark the cache item as revalidatable and enabling
* stale cache state Contains a string of ASCII characters that can be used as ETag for
* `If-Match` header Provided by user using `cache.etag` value.

@@ -77,7 +83,7 @@ *

/**
* Used internally to mark the cache item as being revalidatable and enabling stale
* cache state may contain `'use-cache-timestamp'` if `cache.modifiedSince` is `true`,
* otherwise will contain a date from `cache.modifiedSince`. If a date is provided, it
* can be used for `If-Modified-Since` header, otherwise the cache timestamp can be used
* for `If-Modified-Since` header.
* Used internally as metadata to mark the cache item as revalidatable and enabling
* stale cache state may contain `'use-cache-timestamp'` if `cache.modifiedSince` is
* `true`, otherwise will contain a date from `cache.modifiedSince`. If a date is
* provided, it can be used for `If-Modified-Since` header, otherwise the cache
* timestamp can be used for `If-Modified-Since` header.
*

@@ -90,3 +96,13 @@ * ```txt

XAxiosCacheLastModified: string;
};
/**
* Used internally as metadata to mark the cache item able to be used if the server
* returns an error. The stale-if-error response directive indicates that the cache can
* reuse a stale response when any error occurs.
*
* ```txt
* XAxiosCacheStaleIfError: <seconds>
* ```
*/
XAxiosCacheStaleIfError: string;
}>;
//# sourceMappingURL=headers.d.ts.map

@@ -1,2 +0,2 @@

export const Header = {
export const Header = Object.freeze({
/**

@@ -28,3 +28,9 @@ * ```txt

IfNoneMatch: 'if-none-match',
/** @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control */
/**
* ```txt
* Cache-Control: max-age=604800
* ```
*
* @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
*/
CacheControl: 'cache-control',

@@ -66,4 +72,4 @@ /**

/**
* Used internally to mark the cache item as being revalidatable and enabling stale
* cache state Contains a string of ASCII characters that can be used as ETag for
* Used internally as metadata to mark the cache item as revalidatable and enabling
* stale cache state Contains a string of ASCII characters that can be used as ETag for
* `If-Match` header Provided by user using `cache.etag` value.

@@ -77,7 +83,7 @@ *

/**
* Used internally to mark the cache item as being revalidatable and enabling stale
* cache state may contain `'use-cache-timestamp'` if `cache.modifiedSince` is `true`,
* otherwise will contain a date from `cache.modifiedSince`. If a date is provided, it
* can be used for `If-Modified-Since` header, otherwise the cache timestamp can be used
* for `If-Modified-Since` header.
* Used internally as metadata to mark the cache item as revalidatable and enabling
* stale cache state may contain `'use-cache-timestamp'` if `cache.modifiedSince` is
* `true`, otherwise will contain a date from `cache.modifiedSince`. If a date is
* provided, it can be used for `If-Modified-Since` header, otherwise the cache
* timestamp can be used for `If-Modified-Since` header.
*

@@ -89,3 +95,13 @@ * ```txt

*/
XAxiosCacheLastModified: 'x-axios-cache-last-modified'
};
XAxiosCacheLastModified: 'x-axios-cache-last-modified',
/**
* Used internally as metadata to mark the cache item able to be used if the server
* returns an error. The stale-if-error response directive indicates that the cache can
* reuse a stale response when any error occurs.
*
* ```txt
* XAxiosCacheStaleIfError: <seconds>
* ```
*/
XAxiosCacheStaleIfError: 'x-axios-cache-stale-if-error'
});

@@ -23,2 +23,13 @@ import type { CacheAxiosResponse, CacheRequestConfig } from '../cache/axios';

export declare type CacheUpdater<R, D> = 'delete' | ((cached: Exclude<StorageValue, LoadingStorageValue>, response: CacheAxiosResponse<R, D>) => MaybePromise<CachedStorageValue | 'delete' | 'ignore'>);
/**
* You can use a `number` to ensure an max time (in seconds) that the cache can be reused.
*
* You can use `true` to use the cache until a new response is received.
*
* You can use a `function` predicate to determine if the cache can be reused (`boolean`)
* or how much time the cache can be used (`number`)
*/
export declare type StaleIfErrorPredicate<R, D> = number | boolean | ((networkResponse: CacheAxiosResponse<R, D> | undefined, cache: LoadingStorageValue & {
previous: 'stale';
}, error: Record<string, unknown>) => MaybePromise<number | boolean>);
//# sourceMappingURL=types.d.ts.map
{
"name": "axios-cache-interceptor",
"version": "0.8.3",
"version": "0.8.4",
"description": "Cache interceptor for axios",

@@ -16,6 +16,7 @@ "main": "./cjs/index.js",

"unpkg": "./umd/es6.js",
"sideEffects": false,
"runkitExampleFilename": "./examples/runkit.js",
"scripts": {
"build": "sh build/build.sh",
"test": "jest --coverage",
"test": "tsc --noEmit && jest --coverage",
"check": "sh build/check.sh",

@@ -39,2 +40,12 @@ "format": "prettier --write .",

],
"files": [
"LICENSE",
"README.md",
"tsconfig.json",
"umd/",
"cjs/",
"esm/",
"src/",
"examples/"
],
"author": {

@@ -62,8 +73,8 @@ "name": "Arthur Fiorette",

"@types/webpack": "^5.28.0",
"@typescript-eslint/eslint-plugin": "^5.9.1",
"@typescript-eslint/parser": "^5.9.1",
"@typescript-eslint/eslint-plugin": "^5.10.0",
"@typescript-eslint/parser": "^5.10.0",
"auto-changelog": "^2.3.0",
"axios": "~0.24.0",
"axios": "~0.25.0",
"es-check": "^6.1.1",
"eslint": "^8.6.0",
"eslint": "^8.7.0",
"eslint-config-prettier": "^8.3.0",

@@ -83,4 +94,4 @@ "eslint-plugin-prettier": "^4.0.0",

"peerDependencies": {
"axios": "~0.24.0"
"axios": "~0.25.0"
}
}

@@ -0,72 +1,15 @@

[![Issues](https://img.shields.io/github/issues/arthurfiorette/axios-cache-interceptor?logo=github&label=Issues)](https://github.com/arthurfiorette/axios-cache-interceptor/issues)
[![Stars](https://img.shields.io/github/stars/arthurfiorette/axios-cache-interceptor?logo=github&label=Stars)](https://github.com/arthurfiorette/axios-cache-interceptor/stargazers)
[![License](https://img.shields.io/github/license/arthurfiorette/axios-cache-interceptor?logo=githu&label=License)](https://github.com/arthurfiorette/axios-cache-interceptor/blob/main/LICENSE)
[![Try on Runkit](https://img.shields.io/badge/try%20on-RunKit-brightgreen?logo=runkit&logoColor=e83e8c)](https://npm.runkit.com/axios-cache-interceptor)
[![Codecov](https://codecov.io/gh/arthurfiorette/axios-cache-interceptor/branch/main/graph/badge.svg?token=ML0KGCU0VM)](https://codecov.io/gh/arthurfiorette/axios-cache-interceptor)
[![Downloads](https://img.shields.io/npm/dw/axios-cache-interceptor?style=flat)](https://www.npmjs.com/package/axios-cache-interceptor)
[![Bundlephobia](https://img.shields.io/bundlephobia/minzip/axios-cache-interceptor/latest?style=flat)](https://bundlephobia.com/package/axios-cache-interceptor@latest)
[![Packagephobia](https://packagephobia.com/badge?p=axios-cache-interceptor@latest)](https://packagephobia.com/result?p=axios-cache-interceptor@latest)
<br />
<div align="center">
<code
><a href="https://github.com/arthurfiorette/axios-cache-interceptor/issues"
><img
src="https://img.shields.io/github/issues/arthurfiorette/axios-cache-interceptor?logo=github&label=Issues"
target="_blank"
alt="Issues" /></a
></code>
<code
><a href="https://github.com/arthurfiorette/axios-cache-interceptor/stargazers"
><img
src="https://img.shields.io/github/stars/arthurfiorette/axios-cache-interceptor?logo=github&label=Stars"
target="_blank"
alt="Stars" /></a
></code>
<code
><a href="https://github.com/arthurfiorette/axios-cache-interceptor/blob/main/LICENSE"
><img
src="https://img.shields.io/github/license/arthurfiorette/axios-cache-interceptor?logo=githu&label=License"
target="_blank"
alt="License" /></a
></code>
<code
><a href="https://codecov.io/gh/arthurfiorette/axios-cache-interceptor"
><img
src="https://codecov.io/gh/arthurfiorette/axios-cache-interceptor/branch/main/graph/badge.svg?token=ML0KGCU0VM"
target="_blank"
alt="Codecov" /></a
></code>
<code
><a href="https://twitter.com/acdlite/status/974390255393505280"
><img
src="https://img.shields.io/badge/speed-Blazing%20%F0%9F%94%A5-brightgreen.svg"
target="_blank"
alt="Blazing Fast" /></a
></code>
<br />
<code
><a href="https://www.npmjs.com/package/axios-cache-interceptor"
><img
src="https://img.shields.io/npm/dm/axios-cache-interceptor?style=flat"
target="_blank"
alt="Downloads" /></a
></code>
<code
><a href="https://bundlephobia.com/package/axios-cache-interceptor@latest"
><img
src="https://img.shields.io/bundlephobia/minzip/axios-cache-interceptor/latest?style=flat"
target="_blank"
alt="Minified Size" /></a
></code>
<code
><a href="https://packagephobia.com/result?p=axios-cache-interceptor@latest"
><img
src="https://packagephobia.com/badge?p=axios-cache-interceptor@latest"
target="_blank"
alt="Install Size" /></a
></code>
<code
><a href="https://npm.runkit.com/axios-cache-interceptor"
><img
src="https://img.shields.io/badge/try%20on-RunKit-brightgreen"
target="_blank"
alt="Try on RunKit" /></a
></code>
<br />
<br />
<br />
<pre>
<h1>📬
<h1>⚡
Axios Cache Interceptor</h1>

@@ -73,0 +16,0 @@ </pre>

@@ -80,4 +80,4 @@ /* eslint-disable @typescript-eslint/no-explicit-any */

interceptors: {
request: AxiosInterceptorManager<CacheRequestConfig<unknown, unknown>>;
response: AxiosInterceptorManager<CacheAxiosResponse<unknown, unknown>>;
request: AxiosInterceptorManager<CacheRequestConfig>;
response: AxiosInterceptorManager<CacheAxiosResponse>;
};

@@ -84,0 +84,0 @@

@@ -6,3 +6,8 @@ import type { Method } from 'axios';

import type { AxiosStorage, CachedResponse } from '../storage/types';
import type { CachePredicate, CacheUpdater, KeyGenerator } from '../util/types';
import type {
CachePredicate,
CacheUpdater,
KeyGenerator,
StaleIfErrorPredicate
} from '../util/types';
import type { CacheAxiosResponse, CacheRequestConfig } from './axios';

@@ -80,2 +85,30 @@

modifiedSince: Date | boolean;
/**
* Enables cache to be returned if the response comes with an error, either by invalid
* status code, network errors and etc. You can filter the type of error that should be
* stale by using a predicate function.
*
* **Note**: If the response is treated as error because of invalid status code *(like
* from AxiosRequestConfig#invalidateStatus)*, and this ends up `true`, the cache will
* be preserved over the "invalid" request. So, if you want to preserve the response,
* you can use this predicate:
*
* ```js
* const customPredicate = (response, cache, error) => {
* // Return false if has a response
* return !response;
* };
* ```
*
* Possible types:
*
* - `number` -> the max time (in seconds) that the cache can be reused.
* - `boolean` -> `false` disables and `true` enables with infinite time.
* - `function` -> a predicate that can return `number` or `boolean` as described above.
*
* @default false
* @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#stale-if-error
*/
staleIfError: StaleIfErrorPredicate<R, D>;
};

@@ -112,6 +145,6 @@

/** The request interceptor that will be used to handle the cache. */
requestInterceptor: AxiosInterceptor<CacheRequestConfig<unknown, unknown>>;
requestInterceptor: AxiosInterceptor<CacheRequestConfig>;
/** The response interceptor that will be used to handle the cache. */
responseInterceptor: AxiosInterceptor<CacheAxiosResponse<unknown, unknown>>;
responseInterceptor: AxiosInterceptor<CacheAxiosResponse>;
}

@@ -70,15 +70,13 @@ import type { AxiosInstance } from 'axios';

// CacheRequestConfig values
axiosCache.defaults = {
...axios.defaults,
cache: {
ttl: options.ttl ?? 1000 * 60 * 5,
interpretHeader: options.interpretHeader ?? false,
methods: options.methods || ['get'],
cachePredicate: options.cachePredicate || {
statusCheck: (status) => status >= 200 && status < 400
},
etag: options.etag ?? false,
modifiedSince: options.modifiedSince ?? false,
update: options.update || {}
}
axiosCache.defaults.cache = {
ttl: options.ttl ?? 1000 * 60 * 5,
interpretHeader: options.interpretHeader ?? false,
methods: options.methods || ['get'],
cachePredicate: options.cachePredicate || {
statusCheck: (status) => status >= 200 && status < 400
},
etag: options.etag ?? false,
modifiedSince: options.modifiedSince ?? false,
staleIfError: options.staleIfError ?? false,
update: options.update || {}
};

@@ -85,0 +83,0 @@

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

if (cacheControl) {
const { noCache, noStore, mustRevalidate, maxAge, immutable } = parse(cacheControl);
const { noCache, noStore, mustRevalidate, maxAge, immutable } = parse(
String(cacheControl)
);

@@ -44,3 +46,3 @@ // Header told that this response should not be cached.

if (expires) {
const milliseconds = Date.parse(expires) - Date.now();
const milliseconds = Date.parse(String(expires)) - Date.now();
return milliseconds >= 0 ? milliseconds : 'dont cache';

@@ -47,0 +49,0 @@ }

@@ -0,1 +1,3 @@

import type { AxiosRequestHeaders } from 'axios';
export type InterpreterResult = 'dont cache' | 'not enough headers' | number;

@@ -11,3 +13,3 @@

*/
export type HeadersInterpreter = (headers?: Record<string, string>) => InterpreterResult;
export type HeadersInterpreter = (headers?: AxiosRequestHeaders) => InterpreterResult;

@@ -24,3 +26,3 @@ /**

header: string,
headers: Record<string, string>
headers: AxiosRequestHeaders
) => InterpreterResult;

@@ -6,7 +6,10 @@ import type { CacheAxiosResponse, CacheRequestConfig } from '../cache/axios';

onFulfilled?(value: T): T | Promise<T>;
onRejected?(error: unknown): unknown;
/** Returns a successful response or re-throws the error */
onRejected?(error: Record<string, unknown>): T | Promise<T>;
apply: () => void;
}
export type RequestInterceptor = AxiosInterceptor<CacheRequestConfig<unknown, unknown>>;
export type ResponseInterceptor = AxiosInterceptor<CacheAxiosResponse<unknown, unknown>>;
export type RequestInterceptor = AxiosInterceptor<CacheRequestConfig>;
export type ResponseInterceptor = AxiosInterceptor<CacheAxiosResponse>;

@@ -13,3 +13,3 @@ import { deferred } from 'fast-defer';

isMethodIn,
setRevalidationHeaders
updateStaleRequest
} from './util';

@@ -60,7 +60,13 @@

state: 'loading',
data: cache.data
previous: cache.state,
// Eslint complains a lot :)
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
data: cache.data as any,
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
createdAt: cache.createdAt as any
});
if (cache.state === 'stale') {
setRevalidationHeaders(cache, config as ConfigWithCache<unknown>);
updateStaleRequest(cache, config as ConfigWithCache<unknown>);
}

@@ -95,5 +101,5 @@

//Even though the response interceptor receives this one from here,
// Even though the response interceptor receives this one from here,
// it has been configured to ignore cached responses = true
config.adapter = (): Promise<CacheAxiosResponse<unknown, unknown>> =>
config.adapter = (): Promise<CacheAxiosResponse> =>
Promise.resolve({

@@ -100,0 +106,0 @@ config,

@@ -1,3 +0,7 @@

import type { AxiosCacheInstance } from '../cache/axios';
import type { CacheProperties } from '../cache/cache';
import type { CacheProperties } from '..';
import type {
AxiosCacheInstance,
CacheAxiosResponse,
CacheRequestConfig
} from '../cache/axios';
import type { CachedStorageValue } from '../storage/types';

@@ -18,11 +22,8 @@ import { testCachePredicate } from '../util/cache-predicate';

*/
const rejectResponse = async (
{ storage, waiting }: AxiosCacheInstance,
responseId: string
) => {
const rejectResponse = async (responseId: string) => {
// Update the cache to empty to prevent infinite loading state
await storage.remove(responseId);
await axios.storage.remove(responseId);
// Reject the deferred if present
waiting[responseId]?.reject(null);
delete waiting[responseId];
axios.waiting[responseId]?.reject(null);
delete axios.waiting[responseId];
};

@@ -45,2 +46,3 @@

// Request interceptor merges defaults with per request configuration
const cacheConfig = response.config.cache as CacheProperties;

@@ -66,3 +68,3 @@

) {
await rejectResponse(axios, response.id);
await rejectResponse(response.id);
return response;

@@ -72,5 +74,10 @@ }

// avoid remnant headers from remote server to break implementation
delete response.headers[Header.XAxiosCacheEtag];
delete response.headers[Header.XAxiosCacheLastModified];
for (const header in Header) {
if (!header.startsWith('XAxiosCache')) {
continue;
}
delete response.headers[header];
}
if (cacheConfig.etag && cacheConfig.etag !== true) {

@@ -94,3 +101,3 @@ response.headers[Header.XAxiosCacheEtag] = cacheConfig.etag;

if (expirationTime === 'dont cache') {
await rejectResponse(axios, response.id);
await rejectResponse(response.id);
return response;

@@ -108,2 +115,11 @@ }

if (cacheConfig.staleIfError) {
response.headers[Header.XAxiosCacheStaleIfError] = String(ttl);
}
// Update other entries before updating himself
if (cacheConfig?.update) {
await updateCache(axios.storage, response, cacheConfig.update);
}
const newCache: CachedStorageValue = {

@@ -116,11 +132,4 @@ state: 'cached',

// Update other entries before updating himself
if (cacheConfig?.update) {
await updateCache(axios.storage, response, cacheConfig.update);
}
const deferred = axios.waiting[response.id];
// Resolve all other requests waiting for this response
deferred?.resolve(newCache.data);
axios.waiting[response.id]?.resolve(newCache.data);
delete axios.waiting[response.id];

@@ -135,6 +144,67 @@

const onRejected: ResponseInterceptor['onRejected'] = async (error) => {
const config = error['config'] as CacheRequestConfig;
if (!config || config.cache === false || !config.id) {
throw error;
}
const cache = await axios.storage.get(config.id);
const cacheConfig = config.cache;
if (
// This will only not be loading if the interceptor broke
cache.state !== 'loading' ||
cache.previous !== 'stale'
) {
await rejectResponse(config.id);
throw error;
}
if (cacheConfig?.staleIfError) {
const staleIfError =
typeof cacheConfig.staleIfError === 'function'
? await cacheConfig.staleIfError(
error.response as CacheAxiosResponse,
cache,
error
)
: cacheConfig.staleIfError;
if (
staleIfError === true ||
// staleIfError is the number of seconds that stale is allowed to be used
(typeof staleIfError === 'number' && cache.createdAt + staleIfError > Date.now())
) {
// Resolve all other requests waiting for this response
axios.waiting[config.id]?.resolve(cache.data);
delete axios.waiting[config.id];
// re-mark the cache as stale
await axios.storage.set(config.id, {
state: 'stale',
createdAt: Date.now(),
data: cache.data
});
return {
cached: true,
config,
id: config.id,
data: cache.data.data,
headers: cache.data.headers,
status: cache.data.status,
statusText: cache.data.statusText
};
}
}
throw error;
};
return {
onFulfilled,
apply: () => axios.interceptors.response.use(onFulfilled)
onRejected,
apply: () => axios.interceptors.response.use(onFulfilled, onRejected)
};
}

@@ -39,3 +39,7 @@ import type { Method } from 'axios';

export function setRevalidationHeaders<D>(
/**
* This function updates the cache when the request is stale. So, the next request to the
* server will be made with proper header / settings.
*/
export function updateStaleRequest<D>(
cache: StaleStorageValue,

@@ -42,0 +46,0 @@ config: ConfigWithCache<D>

@@ -59,11 +59,13 @@ import { Header } from '../util/headers';

value.data.headers &&
// Any header below allows the response to stale
(Header.ETag in value.data.headers ||
Header.LastModified in value.data.headers ||
Header.XAxiosCacheEtag in value.data.headers ||
Header.XAxiosCacheStaleIfError in value.data.headers ||
Header.XAxiosCacheLastModified in value.data.headers)
) {
const stale: StaleStorageValue = {
data: value.data,
state: 'stale',
createdAt: value.createdAt
createdAt: value.createdAt,
data: value.data
};

@@ -70,0 +72,0 @@ await set(key, stale);

@@ -19,2 +19,8 @@ import type { MaybePromise } from '../util/types';

export type StorageMetadata = {
/** If the request can be stale */
shouldStale?: boolean;
[key: string]: unknown;
};
export type StaleStorageValue = {

@@ -35,15 +41,18 @@ data: CachedResponse;

export type LoadingStorageValue = {
/**
* Only present if the previous state was `stale`. So, in case the new response comes
* without a value, this data is used
*/
data?: CachedResponse;
ttl?: number;
export type LoadingStorageValue =
| {
data?: undefined;
ttl?: undefined;
createdAt?: undefined;
state: 'loading';
previous: 'empty';
}
| {
state: 'loading';
data: CachedResponse;
ttl?: undefined;
createdAt: number;
previous: 'stale';
};
/** Defined when the state is cached */
createdAt?: undefined;
state: 'loading';
};
export type EmptyStorageValue = {

@@ -50,0 +59,0 @@ data?: undefined;

@@ -1,2 +0,2 @@

export const Header = {
export const Header = Object.freeze({
/**

@@ -31,3 +31,9 @@ * ```txt

/** @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control */
/**
* ```txt
* Cache-Control: max-age=604800
* ```
*
* @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
*/
CacheControl: 'cache-control',

@@ -74,4 +80,4 @@

/**
* Used internally to mark the cache item as being revalidatable and enabling stale
* cache state Contains a string of ASCII characters that can be used as ETag for
* Used internally as metadata to mark the cache item as revalidatable and enabling
* stale cache state Contains a string of ASCII characters that can be used as ETag for
* `If-Match` header Provided by user using `cache.etag` value.

@@ -86,7 +92,7 @@ *

/**
* Used internally to mark the cache item as being revalidatable and enabling stale
* cache state may contain `'use-cache-timestamp'` if `cache.modifiedSince` is `true`,
* otherwise will contain a date from `cache.modifiedSince`. If a date is provided, it
* can be used for `If-Modified-Since` header, otherwise the cache timestamp can be used
* for `If-Modified-Since` header.
* Used internally as metadata to mark the cache item as revalidatable and enabling
* stale cache state may contain `'use-cache-timestamp'` if `cache.modifiedSince` is
* `true`, otherwise will contain a date from `cache.modifiedSince`. If a date is
* provided, it can be used for `If-Modified-Since` header, otherwise the cache
* timestamp can be used for `If-Modified-Since` header.
*

@@ -98,3 +104,14 @@ * ```txt

*/
XAxiosCacheLastModified: 'x-axios-cache-last-modified'
};
XAxiosCacheLastModified: 'x-axios-cache-last-modified',
/**
* Used internally as metadata to mark the cache item able to be used if the server
* returns an error. The stale-if-error response directive indicates that the cache can
* reuse a stale response when any error occurs.
*
* ```txt
* XAxiosCacheStaleIfError: <seconds>
* ```
*/
XAxiosCacheStaleIfError: 'x-axios-cache-stale-if-error'
});

@@ -44,1 +44,18 @@ import type { CacheAxiosResponse, CacheRequestConfig } from '../cache/axios';

) => MaybePromise<CachedStorageValue | 'delete' | 'ignore'>);
/**
* You can use a `number` to ensure an max time (in seconds) that the cache can be reused.
*
* You can use `true` to use the cache until a new response is received.
*
* You can use a `function` predicate to determine if the cache can be reused (`boolean`)
* or how much time the cache can be used (`number`)
*/
export type StaleIfErrorPredicate<R, D> =
| number
| boolean
| ((
networkResponse: CacheAxiosResponse<R, D> | undefined,
cache: LoadingStorageValue & { previous: 'stale' },
error: Record<string, unknown>
) => MaybePromise<number | boolean>);

@@ -1,2 +0,2 @@

!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()}("undefined"!=typeof self?self:this,(function(){return function(){var e={549:function(e,t){var r,n;r=t,n=Symbol("fast-defer"),r.deferred=function(){var e,t,r=new Promise((function(r,n){e=r,t=n}));return r.resolve=e,r.reject=t,r[n]=1,r},r.isDeferred=function(e){return!!e&&!!e[n]}},246:function(e,t){var r;(r=t).transform=function(e){var t=typeof e;if("object"===t&&e){if(e instanceof Date)return"#"+e.getTime();if(e instanceof RegExp)return"#"+e.toString();var n=Array.isArray(e)?[]:{};for(var a in e)n[a]=r.transform(e[a]);return"#"+String(e.constructor)+JSON.stringify(n,Object.keys(n).sort())}return t+String(e)+("symbol"===t?Math.random():"")},r.code=function(e){e=r.transform(e);for(var t=7,n=0;n<e.length;)t=31*t+e.charCodeAt(n++)&9007199254740991;return t}}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return function(){"use strict";r.r(n),r.d(n,{Header:function(){return u},buildKeyGenerator:function(){return A},buildMemoryStorage:function(){return S},buildStorage:function(){return w},buildWebStorage:function(){return j},createCacheResponse:function(){return p},createValidateStatus:function(){return f},defaultHeaderInterpreter:function(){return c},defaultKeyGenerator:function(){return M},defaultRequestInterceptor:function(){return v},defaultResponseInterceptor:function(){return b},isMethodIn:function(){return l},isStorage:function(){return x},setRevalidationHeaders:function(){return h},setupCache:function(){return T},testCachePredicate:function(){return g},updateCache:function(){return m}});var e=function(){return e=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},e.apply(this,arguments)};function t(e,t,r,n){return new(r||(r=Promise))((function(a,o){function i(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}u((n=n.apply(e,t||[])).next())}))}function a(e,t){var r,n,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[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,n&&(a=2&o[0]?n.return:o[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,o[1])).done)return a;switch(n=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,n=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(a=i.trys,(a=a.length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){i.label=o[1];break}if(6===o[0]&&i.label<a[1]){i.label=a[1],a=o;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(o);break}a[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],n=0}finally{r=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}Object.create;Object.create;var o=Symbol("cache-parser");function i(e){return("string"==typeof e||"number"==typeof e)&&(e=Number(e))>=0&&e<1/0}function s(e){return"number"==typeof e||!0===e||"string"==typeof e&&"false"!==e}var u={IfModifiedSince:"if-modified-since",LastModified:"last-modified",IfNoneMatch:"if-none-match",CacheControl:"cache-control",ETag:"etag",Expires:"expires",Age:"age",ContentType:"content-type",XAxiosCacheEtag:"x-axios-cache-etag",XAxiosCacheLastModified:"x-axios-cache-last-modified"},c=function(e){if(!e)return"not enough headers";var t=e[u.CacheControl];if(t){var r=function(e){var t=Object.defineProperty({},o,{enumerable:!1,value:1});if(!e||"string"!=typeof e)return t;var r=function(e){var t=e.toLowerCase().replace(/\s+/g,"").split(","),r={};for(var n in t){var a=t[n].split("=",2);r[a[0]]=1===a.length||a[1]}return r}(e);return s(r.immutable)&&(t.immutable=!0),i(r["max-age"])&&(t.maxAge=Number(r["max-age"])),i(r["max-stale"])&&(t.maxStale=Number(r["max-stale"])),i(r["min-fresh"])&&(t.minFresh=Number(r["min-fresh"])),s(r["must-revalidate"])&&(t.mustRevalidate=!0),s(r["must-understand"])&&(t.mustUnderstand=!0),s(r["no-cache"])&&(t.noCache=!0),s(r["no-store"])&&(t.noStore=!0),s(r["no-transform"])&&(t.noTransform=!0),s(r["only-if-cached"])&&(t.onlyIfCached=!0),s(r.private)&&(t.private=!0),s(r["proxy-revalidate"])&&(t.proxyRevalidate=!0),s(r.public)&&(t.public=!0),i(r["s-maxage"])&&(t.sMaxAge=Number(r["s-maxage"])),i(r["stale-if-error"])&&(t.staleIfError=Number(r["stale-if-error"])),i(r["stale-while-revalidate"])&&(t.staleWhileRevalidate=Number(r["stale-while-revalidate"])),t}(t),n=r.noCache,a=r.noStore,c=r.mustRevalidate,d=r.maxAge,f=r.immutable;if(n||a)return"dont cache";if(f)return 31536e6;if(c)return 0;if(d){var l=e[u.Age];return l?1e3*(d-Number(l)):1e3*d}}var h=e[u.Expires];if(h){var p=Date.parse(h)-Date.now();return p>=0?p:"dont cache"}return"not enough headers"},d=r(549);function f(e){return e?function(t){return e(t)||304===t}:function(e){return e>=200&&e<300||304===e}}function l(e,t){void 0===e&&(e="get"),void 0===t&&(t=[]),e=e.toLowerCase();for(var r=0,n=t;r<n.length;r++){if(n[r].toLowerCase()===e)return!0}return!1}function h(e,t){var r;t.headers||(t.headers={});var n=t.cache,a=n.etag,o=n.modifiedSince;if(a){var i=!0===a?null===(r=e.data)||void 0===r?void 0:r.headers[u.ETag]:a;i&&(t.headers[u.IfNoneMatch]=i)}o&&(t.headers[u.IfModifiedSince]=!0===o?e.data.headers[u.LastModified]||new Date(e.createdAt).toUTCString():o.toUTCString())}function p(t,r){return 304===t.status&&r?(t.cached=!0,t.data=r.data,t.status=r.status,t.statusText=r.statusText,t.headers=e(e({},r.headers),t.headers),r):{data:t.data,status:t.status,statusText:t.statusText,headers:t.headers}}function v(r){var n=this,o=function(o){return t(n,void 0,void 0,(function(){var t,n,i,s,u;return a(this,(function(a){switch(a.label){case 0:return!1===o.cache?[2,o]:(o.cache=e(e({},r.defaults.cache),o.cache),l(o.method,o.cache.methods)?(t=o.id=r.generateKey(o),[4,r.storage.get(t)]):[2,o]);case 1:return"empty"!==(n=a.sent()).state&&"stale"!==n.state?[3,5]:r.waiting[t]?[4,r.storage.get(t)]:[3,3];case 2:return n=a.sent(),[3,5];case 3:return r.waiting[t]=(0,d.deferred)(),null===(u=r.waiting[t])||void 0===u||u.catch((function(){})),[4,r.storage.set(t,{state:"loading",data:n.data})];case 4:return a.sent(),"stale"===n.state&&h(n,o),o.validateStatus=f(o.validateStatus),[2,o];case 5:return"loading"!==n.state?[3,11]:(s=r.waiting[t])?[3,7]:[4,r.storage.remove(t)];case 6:return a.sent(),[2,o];case 7:return a.trys.push([7,9,,10]),[4,s];case 8:return i=a.sent(),[3,10];case 9:return a.sent(),[2,o];case 10:return[3,12];case 11:i=n.data,a.label=12;case 12:return o.adapter=function(){return Promise.resolve({config:o,data:i.data,headers:i.headers,status:i.status,statusText:i.statusText,cached:!0,id:t})},[2,o]}}))}))};return{onFulfilled:o,apply:function(){return r.interceptors.request.use(o)}}}function g(e,r){var n;return t(this,void 0,void 0,(function(){var t,o,i,s,u,c,d,f,l,h,p,v;return a(this,(function(a){switch(a.label){case 0:return"function"==typeof r?[2,r(e)]:(t=r.statusCheck,o=r.responseMatch,i=r.containsHeaders,(u=t)?[4,t(e.status)]:[3,2]);case 1:u=!a.sent(),a.label=2;case 2:return(s=u)?[3,5]:(c=o)?[4,o(e)]:[3,4];case 3:c=!a.sent(),a.label=4;case 4:s=c,a.label=5;case 5:if(s)return[2,!1];if(!i)return[3,10];for(f in d=[],i)d.push(f);l=0,a.label=6;case 6:return l<d.length?(h=d[l],p=i[h],(v=p)?[4,p(null!==(n=e.headers[h.toLowerCase()])&&void 0!==n?n:e.headers[h])]:[3,8]):[3,10];case 7:v=!a.sent(),a.label=8;case 8:if(v)return[2,!1];a.label=9;case 9:return l++,[3,6];case 10:return[2,!0]}}))}))}function m(e,r,n){return t(this,void 0,void 0,(function(){var t,o,i,s,u,c,d;return a(this,(function(a){switch(a.label){case 0:for(o in t=[],n)t.push(o);i=0,a.label=1;case 1:return i<t.length?(s=t[i],"delete"!==(u=n[s])?[3,3]:[4,e.remove(s)]):[3,10];case 2:return a.sent(),[3,9];case 3:return[4,e.get(s)];case 4:return"loading"===(c=a.sent()).state?[3,9]:[4,u(c,r)];case 5:return"delete"!==(d=a.sent())?[3,7]:[4,e.remove(s)];case 6:return a.sent(),[3,9];case 7:return"ignore"===d?[3,9]:[4,e.set(s,d)];case 8:a.sent(),a.label=9;case 9:return i++,[3,1];case 10:return[2]}}))}))}function b(r){var n=this,o=function(e,r){var o=e.storage,i=e.waiting;return t(n,void 0,void 0,(function(){var e;return a(this,(function(t){switch(t.label){case 0:return[4,o.remove(r)];case 1:return t.sent(),null===(e=i[r])||void 0===e||e.reject(null),delete i[r],[2]}}))}))},i=function(i){return t(n,void 0,void 0,(function(){var t,n,s,c,d,f,l,h,v,b,y;return a(this,(function(a){switch(a.label){case 0:return i.id=null!==(v=(y=i.config).id)&&void 0!==v?v:y.id=r.generateKey(i.config),null!==(b=i.cached)&&void 0!==b||(i.cached=!1),i.cached?[2,i]:i.config.cache?(t=i.config.cache,[4,r.storage.get(i.id)]):[2,e(e({},i),{cached:!1})];case 1:return"stale"===(n=a.sent()).state||"empty"===n.state||"cached"===n.state?[2,i]:(s=!n.data)?[4,g(i,t.cachePredicate)]:[3,3];case 2:s=!a.sent(),a.label=3;case 3:return s?[4,o(r,i.id)]:[3,5];case 4:return a.sent(),[2,i];case 5:return delete i.headers[u.XAxiosCacheEtag],delete i.headers[u.XAxiosCacheLastModified],t.etag&&!0!==t.etag&&(i.headers[u.XAxiosCacheEtag]=t.etag),t.modifiedSince&&(i.headers[u.XAxiosCacheLastModified]=!0===t.modifiedSince?"use-cache-timestamp":t.modifiedSince.toUTCString()),c=t.ttl||-1,(null==t?void 0:t.interpretHeader)?"dont cache"!==(d=r.headerInterpreter(i.headers))?[3,7]:[4,o(r,i.id)]:[3,8];case 6:return a.sent(),[2,i];case 7:c="not enough headers"===d?c:d,a.label=8;case 8:return f=p(i,n.data),"function"!=typeof c?[3,10]:[4,c(i)];case 9:c=a.sent(),a.label=10;case 10:return l={state:"cached",ttl:c,createdAt:Date.now(),data:f},(null==t?void 0:t.update)?[4,m(r.storage,i,t.update)]:[3,12];case 11:a.sent(),a.label=12;case 12:return null==(h=r.waiting[i.id])||h.resolve(l.data),delete r.waiting[i.id],[4,r.storage.set(i.id,l)];case 13:return a.sent(),[2,i]}}))}))};return{onFulfilled:i,apply:function(){return r.interceptors.response.use(i)}}}var y=Symbol(),x=function(e){return!!e&&!!e[y]};function w(e){var r,n=this,o=e.set,i=e.find,s=e.remove;return(r={})[y]=1,r.set=o,r.remove=s,r.get=function(e){return t(n,void 0,void 0,(function(){var t,r;return a(this,(function(n){switch(n.label){case 0:return[4,i(e)];case 1:return(t=n.sent())?"cached"!==t.state||t.createdAt+t.ttl>Date.now()?[2,t]:t.data.headers&&(u.ETag in t.data.headers||u.LastModified in t.data.headers||u.XAxiosCacheEtag in t.data.headers||u.XAxiosCacheLastModified in t.data.headers)?(r={data:t.data,state:"stale",createdAt:t.createdAt},[4,o(e,r)]):[3,3]:[2,{state:"empty"}];case 2:return n.sent(),[2,r];case 3:return[4,s(e)];case 4:return n.sent(),[2,{state:"empty"}]}}))}))},r}function S(){var t={},r=w({find:function(e){return t[e]},set:function(e,r){t[e]=r},remove:function(e){delete t[e]}});return e(e({},r),{data:t})}var C=r(246),I=/^\/|\/$/g;function A(e,t){return function(r){if(r.id)return r.id;r.baseURL&&(r.baseURL=r.baseURL.replace(I,"")),r.url&&(r.url=r.url.replace(I,"")),r.method&&(r.method=r.method.toLowerCase());var n=t(r);return e?(0,C.code)(n).toString():n}}var M=A(!0,(function(e){var t=e.baseURL,r=void 0===t?"":t,n=e.url,a=void 0===n?"":n,o=e.method;return{url:r+(r&&a?"/":"")+a,method:void 0===o?"get":o,params:e.params,data:e.data}}));function T(t,r){var n,a,o,i;void 0===r&&(r={});var s=t;if(s.storage=r.storage||S(),!x(s.storage))throw new Error("Use buildStorage() function");return s.generateKey=r.generateKey||M,s.waiting=r.waiting||{},s.headerInterpreter=r.headerInterpreter||c,s.requestInterceptor=r.requestInterceptor||v(s),s.responseInterceptor=r.responseInterceptor||b(s),s.defaults=e(e({},t.defaults),{cache:{ttl:null!==(n=r.ttl)&&void 0!==n?n:3e5,interpretHeader:null!==(a=r.interpretHeader)&&void 0!==a&&a,methods:r.methods||["get"],cachePredicate:r.cachePredicate||{statusCheck:function(e){return e>=200&&e<400}},etag:null!==(o=r.etag)&&void 0!==o&&o,modifiedSince:null!==(i=r.modifiedSince)&&void 0!==i&&i,update:r.update||{}}}),s.requestInterceptor.apply(),s.responseInterceptor.apply(),s}function j(e,t){return void 0===t&&(t=""),w({find:function(r){var n=e.getItem(t+r);return n?JSON.parse(n):void 0},set:function(r,n){e.setItem(t+r,JSON.stringify(n))},remove:function(r){e.removeItem(t+r)}})}}(),n}()}));
!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()}("undefined"!=typeof self?self:this,(function(){return function(){var e={549:function(e,t){var r,a;r=t,a=Symbol("fast-defer"),r.deferred=function(){var e,t,r=new Promise((function(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]}},246:function(e,t){var r;(r=t).transform=function(e){var t=typeof e;if("object"===t&&e){if(e instanceof Date)return"#"+e.getTime();if(e instanceof RegExp)return"#"+e.toString();var a=Array.isArray(e)?[]:{};for(var n in e)a[n]=r.transform(e[n]);return"#"+String(e.constructor)+JSON.stringify(a,Object.keys(a).sort())}return t+String(e)+("symbol"===t?Math.random():"")},r.code=function(e){e=r.transform(e);for(var t=7,a=0;a<e.length;)t=31*t+e.charCodeAt(a++)&9007199254740991;return t}}},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}r.d=function(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=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return function(){"use strict";r.r(a),r.d(a,{Header:function(){return o},buildKeyGenerator:function(){return A},buildMemoryStorage:function(){return S},buildStorage:function(){return w},buildWebStorage:function(){return j},createCacheResponse:function(){return v},createValidateStatus:function(){return f},defaultHeaderInterpreter:function(){return i},defaultKeyGenerator:function(){return E},defaultRequestInterceptor:function(){return p},defaultResponseInterceptor:function(){return b},isMethodIn:function(){return l},isStorage:function(){return x},setupCache:function(){return T},testCachePredicate:function(){return g},updateCache:function(){return m},updateStaleRequest:function(){return h}});var e=Symbol("cache-parser");function t(e){return("string"==typeof e||"number"==typeof e)&&(e=Number(e))>=0&&e<1/0}function n(e){return"number"==typeof e||!0===e||"string"==typeof e&&"false"!==e}var o=Object.freeze({IfModifiedSince:"if-modified-since",LastModified:"last-modified",IfNoneMatch:"if-none-match",CacheControl:"cache-control",ETag:"etag",Expires:"expires",Age:"age",ContentType:"content-type",XAxiosCacheEtag:"x-axios-cache-etag",XAxiosCacheLastModified:"x-axios-cache-last-modified",XAxiosCacheStaleIfError:"x-axios-cache-stale-if-error"}),i=function(r){if(!r)return"not enough headers";var a=r[o.CacheControl];if(a){var i=function(r){var a=Object.defineProperty({},e,{enumerable:!1,value:1});if(!r||"string"!=typeof r)return a;var o=function(e){var t=e.toLowerCase().replace(/\s+/g,"").split(","),r={};for(var a in t){var n=t[a].split("=",2);r[n[0]]=1===n.length||n[1]}return r}(r);return n(o.immutable)&&(a.immutable=!0),t(o["max-age"])&&(a.maxAge=Number(o["max-age"])),t(o["max-stale"])&&(a.maxStale=Number(o["max-stale"])),t(o["min-fresh"])&&(a.minFresh=Number(o["min-fresh"])),n(o["must-revalidate"])&&(a.mustRevalidate=!0),n(o["must-understand"])&&(a.mustUnderstand=!0),n(o["no-cache"])&&(a.noCache=!0),n(o["no-store"])&&(a.noStore=!0),n(o["no-transform"])&&(a.noTransform=!0),n(o["only-if-cached"])&&(a.onlyIfCached=!0),n(o.private)&&(a.private=!0),n(o["proxy-revalidate"])&&(a.proxyRevalidate=!0),n(o.public)&&(a.public=!0),t(o["s-maxage"])&&(a.sMaxAge=Number(o["s-maxage"])),t(o["stale-if-error"])&&(a.staleIfError=Number(o["stale-if-error"])),t(o["stale-while-revalidate"])&&(a.staleWhileRevalidate=Number(o["stale-while-revalidate"])),a}(String(a)),s=i.noCache,c=i.noStore,u=i.mustRevalidate,d=i.maxAge,f=i.immutable;if(s||c)return"dont cache";if(f)return 31536e6;if(u)return 0;if(d){var l=r[o.Age];return l?1e3*(d-Number(l)):1e3*d}}var h=r[o.Expires];if(h){var v=Date.parse(String(h))-Date.now();return v>=0?v:"dont cache"}return"not enough headers"};var s=function(){return s=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},s.apply(this,arguments)};function c(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 u(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])}}}Object.create;Object.create;var d=r(549);function f(e){return e?function(t){return e(t)||304===t}:function(e){return e>=200&&e<300||304===e}}function l(e,t){void 0===e&&(e="get"),void 0===t&&(t=[]),e=e.toLowerCase();for(var r=0,a=t;r<a.length;r++){if(a[r].toLowerCase()===e)return!0}return!1}function h(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.ETag]:n;s&&(t.headers[o.IfNoneMatch]=s)}i&&(t.headers[o.IfModifiedSince]=!0===i?e.data.headers[o.LastModified]||new Date(e.createdAt).toUTCString():i.toUTCString())}function v(e,t){return 304===e.status&&t?(e.cached=!0,e.data=t.data,e.status=t.status,e.statusText=t.statusText,e.headers=s(s({},t.headers),e.headers),t):{data:e.data,status:e.status,statusText:e.statusText,headers:e.headers}}function p(e){var t=this,r=function(r){return c(t,void 0,void 0,(function(){var t,a,n,o,i;return u(this,(function(c){switch(c.label){case 0:return!1===r.cache?[2,r]:(r.cache=s(s({},e.defaults.cache),r.cache),l(r.method,r.cache.methods)?(t=r.id=e.generateKey(r),[4,e.storage.get(t)]):[2,r]);case 1:return"empty"!==(a=c.sent()).state&&"stale"!==a.state?[3,5]:e.waiting[t]?[4,e.storage.get(t)]:[3,3];case 2:return a=c.sent(),[3,5];case 3:return e.waiting[t]=(0,d.deferred)(),null===(i=e.waiting[t])||void 0===i||i.catch((function(){})),[4,e.storage.set(t,{state:"loading",previous:a.state,data:a.data,createdAt:a.createdAt})];case 4:return c.sent(),"stale"===a.state&&h(a,r),r.validateStatus=f(r.validateStatus),[2,r];case 5:return"loading"!==a.state?[3,11]:(o=e.waiting[t])?[3,7]:[4,e.storage.remove(t)];case 6:return c.sent(),[2,r];case 7:return c.trys.push([7,9,,10]),[4,o];case 8:return n=c.sent(),[3,10];case 9:return c.sent(),[2,r];case 10:return[3,12];case 11:n=a.data,c.label=12;case 12:return r.adapter=function(){return Promise.resolve({config:r,data:n.data,headers:n.headers,status:n.status,statusText:n.statusText,cached:!0,id:t})},[2,r]}}))}))};return{onFulfilled:r,apply:function(){return e.interceptors.request.use(r)}}}function g(e,t){var r;return c(this,void 0,void 0,(function(){var a,n,o,i,s,c,d,f,l,h,v,p;return u(this,(function(u){switch(u.label){case 0:return"function"==typeof t?[2,t(e)]:(a=t.statusCheck,n=t.responseMatch,o=t.containsHeaders,(s=a)?[4,a(e.status)]:[3,2]);case 1:s=!u.sent(),u.label=2;case 2:return(i=s)?[3,5]:(c=n)?[4,n(e)]:[3,4];case 3:c=!u.sent(),u.label=4;case 4:i=c,u.label=5;case 5:if(i)return[2,!1];if(!o)return[3,10];for(f in d=[],o)d.push(f);l=0,u.label=6;case 6:return l<d.length?(h=d[l],v=o[h],(p=v)?[4,v(null!==(r=e.headers[h.toLowerCase()])&&void 0!==r?r:e.headers[h])]:[3,8]):[3,10];case 7:p=!u.sent(),u.label=8;case 8:if(p)return[2,!1];u.label=9;case 9:return l++,[3,6];case 10:return[2,!0]}}))}))}function m(e,t,r){return c(this,void 0,void 0,(function(){var a,n,o,i,s,c,d;return u(this,(function(u){switch(u.label){case 0:for(n in a=[],r)a.push(n);o=0,u.label=1;case 1:return o<a.length?(i=a[o],"delete"!==(s=r[i])?[3,3]:[4,e.remove(i)]):[3,10];case 2:return u.sent(),[3,9];case 3:return[4,e.get(i)];case 4:return"loading"===(c=u.sent()).state?[3,9]:[4,s(c,t)];case 5:return"delete"!==(d=u.sent())?[3,7]:[4,e.remove(i)];case 6:return u.sent(),[3,9];case 7:return"ignore"===d?[3,9]:[4,e.set(i,d)];case 8:u.sent(),u.label=9;case 9:return o++,[3,1];case 10:return[2]}}))}))}function b(e){var t=this,r=function(r){return c(t,void 0,void 0,(function(){var t;return u(this,(function(a){switch(a.label){case 0:return[4,e.storage.remove(r)];case 1:return a.sent(),null===(t=e.waiting[r])||void 0===t||t.reject(null),delete e.waiting[r],[2]}}))}))},a=function(a){return c(t,void 0,void 0,(function(){var t,n,i,c,d,f,l,h,p,b,y,x;return u(this,(function(u){switch(u.label){case 0:return a.id=null!==(p=(x=a.config).id)&&void 0!==p?p:x.id=e.generateKey(a.config),null!==(b=a.cached)&&void 0!==b||(a.cached=!1),a.cached?[2,a]:a.config.cache?(t=a.config.cache,[4,e.storage.get(a.id)]):[2,s(s({},a),{cached:!1})];case 1:return"stale"===(n=u.sent()).state||"empty"===n.state||"cached"===n.state?[2,a]:(i=!n.data)?[4,g(a,t.cachePredicate)]:[3,3];case 2:i=!u.sent(),u.label=3;case 3:return i?[4,r(a.id)]:[3,5];case 4:return u.sent(),[2,a];case 5:for(c in o)c.startsWith("XAxiosCache")&&delete a.headers[c];return t.etag&&!0!==t.etag&&(a.headers[o.XAxiosCacheEtag]=t.etag),t.modifiedSince&&(a.headers[o.XAxiosCacheLastModified]=!0===t.modifiedSince?"use-cache-timestamp":t.modifiedSince.toUTCString()),d=t.ttl||-1,(null==t?void 0:t.interpretHeader)?"dont cache"!==(f=e.headerInterpreter(a.headers))?[3,7]:[4,r(a.id)]:[3,8];case 6:return u.sent(),[2,a];case 7:d="not enough headers"===f?d:f,u.label=8;case 8:return l=v(a,n.data),"function"!=typeof d?[3,10]:[4,d(a)];case 9:d=u.sent(),u.label=10;case 10:return t.staleIfError&&(a.headers[o.XAxiosCacheStaleIfError]=String(d)),(null==t?void 0:t.update)?[4,m(e.storage,a,t.update)]:[3,12];case 11:u.sent(),u.label=12;case 12:return h={state:"cached",ttl:d,createdAt:Date.now(),data:l},null===(y=e.waiting[a.id])||void 0===y||y.resolve(h.data),delete e.waiting[a.id],[4,e.storage.set(a.id,h)];case 13:return u.sent(),[2,a]}}))}))},n=function(a){return c(t,void 0,void 0,(function(){var t,n,o,i,s,c;return u(this,(function(u){switch(u.label){case 0:if(!(t=a.config)||!1===t.cache||!t.id)throw a;return[4,e.storage.get(t.id)];case 1:return n=u.sent(),o=t.cache,"loading"===n.state&&"stale"===n.previous?[3,3]:[4,r(t.id)];case 2:throw u.sent(),a;case 3:return(null==o?void 0:o.staleIfError)?"function"!=typeof o.staleIfError?[3,5]:[4,o.staleIfError(a.response,n,a)]:[3,8];case 4:return s=u.sent(),[3,6];case 5:s=o.staleIfError,u.label=6;case 6:return!0===(i=s)||"number"==typeof i&&n.createdAt+i>Date.now()?(null===(c=e.waiting[t.id])||void 0===c||c.resolve(n.data),delete e.waiting[t.id],[4,e.storage.set(t.id,{state:"stale",createdAt:Date.now(),data:n.data})]):[3,8];case 7:return u.sent(),[2,{cached:!0,config:t,id:t.id,data:n.data.data,headers:n.data.headers,status:n.data.status,statusText:n.data.statusText}];case 8:throw a}}))}))};return{onFulfilled:a,onRejected:n,apply:function(){return e.interceptors.response.use(a,n)}}}var y=Symbol(),x=function(e){return!!e&&!!e[y]};function w(e){var t,r=this,a=e.set,n=e.find,i=e.remove;return(t={})[y]=1,t.set=a,t.remove=i,t.get=function(e){return c(r,void 0,void 0,(function(){var t,r;return u(this,(function(s){switch(s.label){case 0:return[4,n(e)];case 1:return(t=s.sent())?"cached"!==t.state||t.createdAt+t.ttl>Date.now()?[2,t]:t.data.headers&&(o.ETag in t.data.headers||o.LastModified in t.data.headers||o.XAxiosCacheEtag in t.data.headers||o.XAxiosCacheStaleIfError in t.data.headers||o.XAxiosCacheLastModified in t.data.headers)?(r={state:"stale",createdAt:t.createdAt,data:t.data},[4,a(e,r)]):[3,3]:[2,{state:"empty"}];case 2:return s.sent(),[2,r];case 3:return[4,i(e)];case 4:return s.sent(),[2,{state:"empty"}]}}))}))},t}function S(){var e={},t=w({find:function(t){return e[t]},set:function(t,r){e[t]=r},remove:function(t){delete e[t]}});return s(s({},t),{data:e})}var C=r(246),I=/^\/|\/$/g;function A(e,t){return function(r){if(r.id)return r.id;r.baseURL&&(r.baseURL=r.baseURL.replace(I,"")),r.url&&(r.url=r.url.replace(I,"")),r.method&&(r.method=r.method.toLowerCase());var a=t(r);return e?(0,C.code)(a).toString():a}}var E=A(!0,(function(e){var t=e.baseURL,r=void 0===t?"":t,a=e.url,n=void 0===a?"":a,o=e.method;return{url:r+(r&&n?"/":"")+n,method:void 0===o?"get":o,params:e.params,data:e.data}}));function T(e,t){var r,a,n,o,s;void 0===t&&(t={});var c=e;if(c.storage=t.storage||S(),!x(c.storage))throw new Error("Use buildStorage() function");return c.generateKey=t.generateKey||E,c.waiting=t.waiting||{},c.headerInterpreter=t.headerInterpreter||i,c.requestInterceptor=t.requestInterceptor||p(c),c.responseInterceptor=t.responseInterceptor||b(c),c.defaults.cache={ttl:null!==(r=t.ttl)&&void 0!==r?r:3e5,interpretHeader:null!==(a=t.interpretHeader)&&void 0!==a&&a,methods:t.methods||["get"],cachePredicate:t.cachePredicate||{statusCheck:function(e){return e>=200&&e<400}},etag:null!==(n=t.etag)&&void 0!==n&&n,modifiedSince:null!==(o=t.modifiedSince)&&void 0!==o&&o,staleIfError:null!==(s=t.staleIfError)&&void 0!==s&&s,update:t.update||{}},c.requestInterceptor.apply(),c.responseInterceptor.apply(),c}function j(e,t){return void 0===t&&(t=""),w({find:function(r){var a=e.getItem(t+r);return a?JSON.parse(a):void 0},set:function(r,a){e.setItem(t+r,JSON.stringify(a))},remove:function(r){e.removeItem(t+r)}})}}(),a}()}));
//# sourceMappingURL=es5.map

@@ -1,2 +0,2 @@

!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()}("undefined"!=typeof self?self:this,(function(){return(()=>{var e={549:(e,t)=>{var r,a;r=t,a=Symbol("fast-defer"),r.deferred=function(){var e,t,r=new Promise((function(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]}},246:(e,t)=>{var r;(r=t).transform=function(e){var t=typeof e;if("object"===t&&e){if(e instanceof Date)return"#"+e.getTime();if(e instanceof RegExp)return"#"+e.toString();var a=Array.isArray(e)?[]:{};for(var n in e)a[n]=r.transform(e[n]);return"#"+String(e.constructor)+JSON.stringify(a,Object.keys(a).sort())}return t+String(e)+("symbol"===t?Math.random():"")},r.code=function(e){e=r.transform(e);for(var t=7,a=0;a<e.length;)t=31*t+e.charCodeAt(a++)&9007199254740991;return t}}},t={};function r(a){var n=t[a];if(void 0!==n)return n.exports;var i=t[a]={exports:{}};return e[a](i,i.exports,r),i.exports}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})};var a={};return(()=>{"use strict";r.r(a),r.d(a,{Header:()=>i,buildKeyGenerator:()=>w,buildMemoryStorage:()=>x,buildStorage:()=>b,buildWebStorage:()=>A,createCacheResponse:()=>l,createValidateStatus:()=>c,defaultHeaderInterpreter:()=>o,defaultKeyGenerator:()=>j,defaultRequestInterceptor:()=>h,defaultResponseInterceptor:()=>m,isMethodIn:()=>u,isStorage:()=>y,setRevalidationHeaders:()=>f,setupCache:()=>I,testCachePredicate:()=>g,updateCache:()=>p});var e=Symbol("cache-parser");function t(e){return("string"==typeof e||"number"==typeof e)&&(e=Number(e))>=0&&e<1/0}function n(e){return"number"==typeof e||!0===e||"string"==typeof e&&"false"!==e}const i={IfModifiedSince:"if-modified-since",LastModified:"last-modified",IfNoneMatch:"if-none-match",CacheControl:"cache-control",ETag:"etag",Expires:"expires",Age:"age",ContentType:"content-type",XAxiosCacheEtag:"x-axios-cache-etag",XAxiosCacheLastModified:"x-axios-cache-last-modified"},o=r=>{if(!r)return"not enough headers";const a=r[i.CacheControl];if(a){const{noCache:o,noStore:s,mustRevalidate:d,maxAge:c,immutable:u}=function(r){var a=Object.defineProperty({},e,{enumerable:!1,value:1});if(!r||"string"!=typeof r)return a;var i=function(e){var t=e.toLowerCase().replace(/\s+/g,"").split(","),r={};for(var a in t){var n=t[a].split("=",2);r[n[0]]=1===n.length||n[1]}return r}(r);return n(i.immutable)&&(a.immutable=!0),t(i["max-age"])&&(a.maxAge=Number(i["max-age"])),t(i["max-stale"])&&(a.maxStale=Number(i["max-stale"])),t(i["min-fresh"])&&(a.minFresh=Number(i["min-fresh"])),n(i["must-revalidate"])&&(a.mustRevalidate=!0),n(i["must-understand"])&&(a.mustUnderstand=!0),n(i["no-cache"])&&(a.noCache=!0),n(i["no-store"])&&(a.noStore=!0),n(i["no-transform"])&&(a.noTransform=!0),n(i["only-if-cached"])&&(a.onlyIfCached=!0),n(i.private)&&(a.private=!0),n(i["proxy-revalidate"])&&(a.proxyRevalidate=!0),n(i.public)&&(a.public=!0),t(i["s-maxage"])&&(a.sMaxAge=Number(i["s-maxage"])),t(i["stale-if-error"])&&(a.staleIfError=Number(i["stale-if-error"])),t(i["stale-while-revalidate"])&&(a.staleWhileRevalidate=Number(i["stale-while-revalidate"])),a}(a);if(o||s)return"dont cache";if(u)return 31536e6;if(d)return 0;if(c){const e=r[i.Age];return e?1e3*(c-Number(e)):1e3*c}}const o=r[i.Expires];if(o){const e=Date.parse(o)-Date.now();return e>=0?e:"dont cache"}return"not enough headers"};function s(e,t,r,a){return new(r||(r=Promise))((function(n,i){function o(e){try{d(a.next(e))}catch(e){i(e)}}function s(e){try{d(a.throw(e))}catch(e){i(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,s)}d((a=a.apply(e,t||[])).next())}))}Object.create;Object.create;var d=r(549);function c(e){return e?t=>e(t)||304===t:e=>e>=200&&e<300||304===e}function u(e="get",t=[]){e=e.toLowerCase();for(const r of t)if(r.toLowerCase()===e)return!0;return!1}function f(e,t){var r;t.headers||(t.headers={});const{etag:a,modifiedSince:n}=t.cache;if(a){const n=!0===a?null===(r=e.data)||void 0===r?void 0:r.headers[i.ETag]:a;n&&(t.headers[i.IfNoneMatch]=n)}n&&(t.headers[i.IfModifiedSince]=!0===n?e.data.headers[i.LastModified]||new Date(e.createdAt).toUTCString():n.toUTCString())}function l(e,t){return 304===e.status&&t?(e.cached=!0,e.data=t.data,e.status=t.status,e.statusText=t.statusText,e.headers=Object.assign(Object.assign({},t.headers),e.headers),t):{data:e.data,status:e.status,statusText:e.statusText,headers:e.headers}}function h(e){const t=t=>s(this,void 0,void 0,(function*(){var r;if(!1===t.cache)return t;if(t.cache=Object.assign(Object.assign({},e.defaults.cache),t.cache),!u(t.method,t.cache.methods))return t;const a=t.id=e.generateKey(t);let n,i=yield e.storage.get(a);e:if("empty"===i.state||"stale"===i.state){if(e.waiting[a]){i=yield e.storage.get(a);break e}return e.waiting[a]=(0,d.deferred)(),null===(r=e.waiting[a])||void 0===r||r.catch((()=>{})),yield e.storage.set(a,{state:"loading",data:i.data}),"stale"===i.state&&f(i,t),t.validateStatus=c(t.validateStatus),t}if("loading"===i.state){const r=e.waiting[a];if(!r)return yield e.storage.remove(a),t;try{n=yield r}catch(e){return t}}else n=i.data;return t.adapter=()=>Promise.resolve({config:t,data:n.data,headers:n.headers,status:n.status,statusText:n.statusText,cached:!0,id:a}),t}));return{onFulfilled:t,apply:()=>e.interceptors.request.use(t)}}function g(e,t){var r;return s(this,void 0,void 0,(function*(){if("function"==typeof t)return t(e);const{statusCheck:a,responseMatch:n,containsHeaders:i}=t;if(a&&!(yield a(e.status))||n&&!(yield n(e)))return!1;if(i)for(const t in i){const a=i[t];if(a&&!(yield a(null!==(r=e.headers[t.toLowerCase()])&&void 0!==r?r:e.headers[t])))return!1}return!0}))}function p(e,t,r){return s(this,void 0,void 0,(function*(){for(const a in r){const n=r[a];if("delete"===n){yield e.remove(a);continue}const i=yield e.get(a);if("loading"===i.state)continue;const o=yield n(i,t);"delete"!==o?"ignore"!==o&&(yield e.set(a,o)):yield e.remove(a)}}))}function m(e){const t=({storage:e,waiting:t},r)=>s(this,void 0,void 0,(function*(){var a;yield e.remove(r),null===(a=t[r])||void 0===a||a.reject(null),delete t[r]})),r=r=>s(this,void 0,void 0,(function*(){var a,n,o;if(r.id=null!==(a=(o=r.config).id)&&void 0!==a?a:o.id=e.generateKey(r.config),null!==(n=r.cached)&&void 0!==n||(r.cached=!1),r.cached)return r;if(!r.config.cache)return Object.assign(Object.assign({},r),{cached:!1});const s=r.config.cache,d=yield e.storage.get(r.id);if("stale"===d.state||"empty"===d.state||"cached"===d.state)return r;if(!d.data&&!(yield g(r,s.cachePredicate)))return yield t(e,r.id),r;delete r.headers[i.XAxiosCacheEtag],delete r.headers[i.XAxiosCacheLastModified],s.etag&&!0!==s.etag&&(r.headers[i.XAxiosCacheEtag]=s.etag),s.modifiedSince&&(r.headers[i.XAxiosCacheLastModified]=!0===s.modifiedSince?"use-cache-timestamp":s.modifiedSince.toUTCString());let c=s.ttl||-1;if(null==s?void 0:s.interpretHeader){const a=e.headerInterpreter(r.headers);if("dont cache"===a)return yield t(e,r.id),r;c="not enough headers"===a?c:a}const u=l(r,d.data);"function"==typeof c&&(c=yield c(r));const f={state:"cached",ttl:c,createdAt:Date.now(),data:u};(null==s?void 0:s.update)&&(yield p(e.storage,r,s.update));const h=e.waiting[r.id];return null==h||h.resolve(f.data),delete e.waiting[r.id],yield e.storage.set(r.id,f),r}));return{onFulfilled:r,apply:()=>e.interceptors.response.use(r)}}const v=Symbol(),y=e=>!!e&&!!e[v];function b({set:e,find:t,remove:r}){return{[v]:1,set:e,remove:r,get:a=>s(this,void 0,void 0,(function*(){const n=yield t(a);if(!n)return{state:"empty"};if("cached"!==n.state||n.createdAt+n.ttl>Date.now())return n;if(n.data.headers&&(i.ETag in n.data.headers||i.LastModified in n.data.headers||i.XAxiosCacheEtag in n.data.headers||i.XAxiosCacheLastModified in n.data.headers)){const t={data:n.data,state:"stale",createdAt:n.createdAt};return yield e(a,t),t}return yield r(a),{state:"empty"}}))}}function x(){const e={},t=b({find:t=>e[t],set:(t,r)=>{e[t]=r},remove:t=>{delete e[t]}});return Object.assign(Object.assign({},t),{data:e})}var S=r(246);const C=/^\/|\/$/g;function w(e,t){return r=>{if(r.id)return r.id;r.baseURL&&(r.baseURL=r.baseURL.replace(C,"")),r.url&&(r.url=r.url.replace(C,"")),r.method&&(r.method=r.method.toLowerCase());const a=t(r);return e?(0,S.code)(a).toString():a}}const j=w(!0,(({baseURL:e="",url:t="",method:r="get",params:a,data:n})=>({url:e+(e&&t?"/":"")+t,method:r,params:a,data:n})));function I(e,t={}){var r,a,n,i;const s=e;if(s.storage=t.storage||x(),!y(s.storage))throw new Error("Use buildStorage() function");return s.generateKey=t.generateKey||j,s.waiting=t.waiting||{},s.headerInterpreter=t.headerInterpreter||o,s.requestInterceptor=t.requestInterceptor||h(s),s.responseInterceptor=t.responseInterceptor||m(s),s.defaults=Object.assign(Object.assign({},e.defaults),{cache:{ttl:null!==(r=t.ttl)&&void 0!==r?r:3e5,interpretHeader:null!==(a=t.interpretHeader)&&void 0!==a&&a,methods:t.methods||["get"],cachePredicate:t.cachePredicate||{statusCheck:e=>e>=200&&e<400},etag:null!==(n=t.etag)&&void 0!==n&&n,modifiedSince:null!==(i=t.modifiedSince)&&void 0!==i&&i,update:t.update||{}}}),s.requestInterceptor.apply(),s.responseInterceptor.apply(),s}function A(e,t=""){return b({find:r=>{const a=e.getItem(t+r);return a?JSON.parse(a):void 0},set:(r,a)=>{e.setItem(t+r,JSON.stringify(a))},remove:r=>{e.removeItem(t+r)}})}})(),a})()}));
!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()}("undefined"!=typeof self?self:this,(function(){return(()=>{var e={549:(e,t)=>{var r,a;r=t,a=Symbol("fast-defer"),r.deferred=function(){var e,t,r=new Promise((function(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]}},246:(e,t)=>{var r;(r=t).transform=function(e){var t=typeof e;if("object"===t&&e){if(e instanceof Date)return"#"+e.getTime();if(e instanceof RegExp)return"#"+e.toString();var a=Array.isArray(e)?[]:{};for(var n in e)a[n]=r.transform(e[n]);return"#"+String(e.constructor)+JSON.stringify(a,Object.keys(a).sort())}return t+String(e)+("symbol"===t?Math.random():"")},r.code=function(e){e=r.transform(e);for(var t=7,a=0;a<e.length;)t=31*t+e.charCodeAt(a++)&9007199254740991;return t}}},t={};function r(a){var n=t[a];if(void 0!==n)return n.exports;var i=t[a]={exports:{}};return e[a](i,i.exports,r),i.exports}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})};var a={};return(()=>{"use strict";r.r(a),r.d(a,{Header:()=>i,buildKeyGenerator:()=>C,buildMemoryStorage:()=>x,buildStorage:()=>b,buildWebStorage:()=>j,createCacheResponse:()=>l,createValidateStatus:()=>c,defaultHeaderInterpreter:()=>o,defaultKeyGenerator:()=>I,defaultRequestInterceptor:()=>h,defaultResponseInterceptor:()=>m,isMethodIn:()=>u,isStorage:()=>y,setupCache:()=>A,testCachePredicate:()=>g,updateCache:()=>p,updateStaleRequest:()=>f});var e=Symbol("cache-parser");function t(e){return("string"==typeof e||"number"==typeof e)&&(e=Number(e))>=0&&e<1/0}function n(e){return"number"==typeof e||!0===e||"string"==typeof e&&"false"!==e}const i=Object.freeze({IfModifiedSince:"if-modified-since",LastModified:"last-modified",IfNoneMatch:"if-none-match",CacheControl:"cache-control",ETag:"etag",Expires:"expires",Age:"age",ContentType:"content-type",XAxiosCacheEtag:"x-axios-cache-etag",XAxiosCacheLastModified:"x-axios-cache-last-modified",XAxiosCacheStaleIfError:"x-axios-cache-stale-if-error"}),o=r=>{if(!r)return"not enough headers";const a=r[i.CacheControl];if(a){const{noCache:o,noStore:s,mustRevalidate:d,maxAge:c,immutable:u}=function(r){var a=Object.defineProperty({},e,{enumerable:!1,value:1});if(!r||"string"!=typeof r)return a;var i=function(e){var t=e.toLowerCase().replace(/\s+/g,"").split(","),r={};for(var a in t){var n=t[a].split("=",2);r[n[0]]=1===n.length||n[1]}return r}(r);return n(i.immutable)&&(a.immutable=!0),t(i["max-age"])&&(a.maxAge=Number(i["max-age"])),t(i["max-stale"])&&(a.maxStale=Number(i["max-stale"])),t(i["min-fresh"])&&(a.minFresh=Number(i["min-fresh"])),n(i["must-revalidate"])&&(a.mustRevalidate=!0),n(i["must-understand"])&&(a.mustUnderstand=!0),n(i["no-cache"])&&(a.noCache=!0),n(i["no-store"])&&(a.noStore=!0),n(i["no-transform"])&&(a.noTransform=!0),n(i["only-if-cached"])&&(a.onlyIfCached=!0),n(i.private)&&(a.private=!0),n(i["proxy-revalidate"])&&(a.proxyRevalidate=!0),n(i.public)&&(a.public=!0),t(i["s-maxage"])&&(a.sMaxAge=Number(i["s-maxage"])),t(i["stale-if-error"])&&(a.staleIfError=Number(i["stale-if-error"])),t(i["stale-while-revalidate"])&&(a.staleWhileRevalidate=Number(i["stale-while-revalidate"])),a}(String(a));if(o||s)return"dont cache";if(u)return 31536e6;if(d)return 0;if(c){const e=r[i.Age];return e?1e3*(c-Number(e)):1e3*c}}const o=r[i.Expires];if(o){const e=Date.parse(String(o))-Date.now();return e>=0?e:"dont cache"}return"not enough headers"};function s(e,t,r,a){return new(r||(r=Promise))((function(n,i){function o(e){try{d(a.next(e))}catch(e){i(e)}}function s(e){try{d(a.throw(e))}catch(e){i(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,s)}d((a=a.apply(e,t||[])).next())}))}Object.create;Object.create;var d=r(549);function c(e){return e?t=>e(t)||304===t:e=>e>=200&&e<300||304===e}function u(e="get",t=[]){e=e.toLowerCase();for(const r of t)if(r.toLowerCase()===e)return!0;return!1}function f(e,t){var r;t.headers||(t.headers={});const{etag:a,modifiedSince:n}=t.cache;if(a){const n=!0===a?null===(r=e.data)||void 0===r?void 0:r.headers[i.ETag]:a;n&&(t.headers[i.IfNoneMatch]=n)}n&&(t.headers[i.IfModifiedSince]=!0===n?e.data.headers[i.LastModified]||new Date(e.createdAt).toUTCString():n.toUTCString())}function l(e,t){return 304===e.status&&t?(e.cached=!0,e.data=t.data,e.status=t.status,e.statusText=t.statusText,e.headers=Object.assign(Object.assign({},t.headers),e.headers),t):{data:e.data,status:e.status,statusText:e.statusText,headers:e.headers}}function h(e){const t=t=>s(this,void 0,void 0,(function*(){var r;if(!1===t.cache)return t;if(t.cache=Object.assign(Object.assign({},e.defaults.cache),t.cache),!u(t.method,t.cache.methods))return t;const a=t.id=e.generateKey(t);let n,i=yield e.storage.get(a);e:if("empty"===i.state||"stale"===i.state){if(e.waiting[a]){i=yield e.storage.get(a);break e}return e.waiting[a]=(0,d.deferred)(),null===(r=e.waiting[a])||void 0===r||r.catch((()=>{})),yield e.storage.set(a,{state:"loading",previous:i.state,data:i.data,createdAt:i.createdAt}),"stale"===i.state&&f(i,t),t.validateStatus=c(t.validateStatus),t}if("loading"===i.state){const r=e.waiting[a];if(!r)return yield e.storage.remove(a),t;try{n=yield r}catch(e){return t}}else n=i.data;return t.adapter=()=>Promise.resolve({config:t,data:n.data,headers:n.headers,status:n.status,statusText:n.statusText,cached:!0,id:a}),t}));return{onFulfilled:t,apply:()=>e.interceptors.request.use(t)}}function g(e,t){var r;return s(this,void 0,void 0,(function*(){if("function"==typeof t)return t(e);const{statusCheck:a,responseMatch:n,containsHeaders:i}=t;if(a&&!(yield a(e.status))||n&&!(yield n(e)))return!1;if(i)for(const t in i){const a=i[t];if(a&&!(yield a(null!==(r=e.headers[t.toLowerCase()])&&void 0!==r?r:e.headers[t])))return!1}return!0}))}function p(e,t,r){return s(this,void 0,void 0,(function*(){for(const a in r){const n=r[a];if("delete"===n){yield e.remove(a);continue}const i=yield e.get(a);if("loading"===i.state)continue;const o=yield n(i,t);"delete"!==o?"ignore"!==o&&(yield e.set(a,o)):yield e.remove(a)}}))}function m(e){const t=t=>s(this,void 0,void 0,(function*(){var r;yield e.storage.remove(t),null===(r=e.waiting[t])||void 0===r||r.reject(null),delete e.waiting[t]})),r=r=>s(this,void 0,void 0,(function*(){var a,n,o,s;if(r.id=null!==(a=(s=r.config).id)&&void 0!==a?a:s.id=e.generateKey(r.config),null!==(n=r.cached)&&void 0!==n||(r.cached=!1),r.cached)return r;if(!r.config.cache)return Object.assign(Object.assign({},r),{cached:!1});const d=r.config.cache,c=yield e.storage.get(r.id);if("stale"===c.state||"empty"===c.state||"cached"===c.state)return r;if(!c.data&&!(yield g(r,d.cachePredicate)))return yield t(r.id),r;for(const e in i)e.startsWith("XAxiosCache")&&delete r.headers[e];d.etag&&!0!==d.etag&&(r.headers[i.XAxiosCacheEtag]=d.etag),d.modifiedSince&&(r.headers[i.XAxiosCacheLastModified]=!0===d.modifiedSince?"use-cache-timestamp":d.modifiedSince.toUTCString());let u=d.ttl||-1;if(null==d?void 0:d.interpretHeader){const a=e.headerInterpreter(r.headers);if("dont cache"===a)return yield t(r.id),r;u="not enough headers"===a?u:a}const f=l(r,c.data);"function"==typeof u&&(u=yield u(r)),d.staleIfError&&(r.headers[i.XAxiosCacheStaleIfError]=String(u)),(null==d?void 0:d.update)&&(yield p(e.storage,r,d.update));const h={state:"cached",ttl:u,createdAt:Date.now(),data:f};return null===(o=e.waiting[r.id])||void 0===o||o.resolve(h.data),delete e.waiting[r.id],yield e.storage.set(r.id,h),r})),a=r=>s(this,void 0,void 0,(function*(){var a;const n=r.config;if(!n||!1===n.cache||!n.id)throw r;const i=yield e.storage.get(n.id),o=n.cache;if("loading"!==i.state||"stale"!==i.previous)throw yield t(n.id),r;if(null==o?void 0:o.staleIfError){const t="function"==typeof o.staleIfError?yield o.staleIfError(r.response,i,r):o.staleIfError;if(!0===t||"number"==typeof t&&i.createdAt+t>Date.now())return null===(a=e.waiting[n.id])||void 0===a||a.resolve(i.data),delete e.waiting[n.id],yield e.storage.set(n.id,{state:"stale",createdAt:Date.now(),data:i.data}),{cached:!0,config:n,id:n.id,data:i.data.data,headers:i.data.headers,status:i.data.status,statusText:i.data.statusText}}throw r}));return{onFulfilled:r,onRejected:a,apply:()=>e.interceptors.response.use(r,a)}}const v=Symbol(),y=e=>!!e&&!!e[v];function b({set:e,find:t,remove:r}){return{[v]:1,set:e,remove:r,get:a=>s(this,void 0,void 0,(function*(){const n=yield t(a);if(!n)return{state:"empty"};if("cached"!==n.state||n.createdAt+n.ttl>Date.now())return n;if(n.data.headers&&(i.ETag in n.data.headers||i.LastModified in n.data.headers||i.XAxiosCacheEtag in n.data.headers||i.XAxiosCacheStaleIfError in n.data.headers||i.XAxiosCacheLastModified in n.data.headers)){const t={state:"stale",createdAt:n.createdAt,data:n.data};return yield e(a,t),t}return yield r(a),{state:"empty"}}))}}function x(){const e={},t=b({find:t=>e[t],set:(t,r)=>{e[t]=r},remove:t=>{delete e[t]}});return Object.assign(Object.assign({},t),{data:e})}var S=r(246);const w=/^\/|\/$/g;function C(e,t){return r=>{if(r.id)return r.id;r.baseURL&&(r.baseURL=r.baseURL.replace(w,"")),r.url&&(r.url=r.url.replace(w,"")),r.method&&(r.method=r.method.toLowerCase());const a=t(r);return e?(0,S.code)(a).toString():a}}const I=C(!0,(({baseURL:e="",url:t="",method:r="get",params:a,data:n})=>({url:e+(e&&t?"/":"")+t,method:r,params:a,data:n})));function A(e,t={}){var r,a,n,i,s;const d=e;if(d.storage=t.storage||x(),!y(d.storage))throw new Error("Use buildStorage() function");return d.generateKey=t.generateKey||I,d.waiting=t.waiting||{},d.headerInterpreter=t.headerInterpreter||o,d.requestInterceptor=t.requestInterceptor||h(d),d.responseInterceptor=t.responseInterceptor||m(d),d.defaults.cache={ttl:null!==(r=t.ttl)&&void 0!==r?r:3e5,interpretHeader:null!==(a=t.interpretHeader)&&void 0!==a&&a,methods:t.methods||["get"],cachePredicate:t.cachePredicate||{statusCheck:e=>e>=200&&e<400},etag:null!==(n=t.etag)&&void 0!==n&&n,modifiedSince:null!==(i=t.modifiedSince)&&void 0!==i&&i,staleIfError:null!==(s=t.staleIfError)&&void 0!==s&&s,update:t.update||{}},d.requestInterceptor.apply(),d.responseInterceptor.apply(),d}function j(e,t=""){return b({find:r=>{const a=e.getItem(t+r);return a?JSON.parse(a):void 0},set:(r,a)=>{e.setItem(t+r,JSON.stringify(a))},remove:r=>{e.removeItem(t+r)}})}})(),a})()}));
//# sourceMappingURL=es6.map

@@ -1,2 +0,2 @@

!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()}("undefined"!=typeof self?self:this,(function(){return(()=>{var e={549:(e,t)=>{var a,r;a=t,r=Symbol("fast-defer"),a.deferred=function(){var e,t,a=new Promise((function(a,r){e=a,t=r}));return a.resolve=e,a.reject=t,a[r]=1,a},a.isDeferred=function(e){return!!e&&!!e[r]}},246:(e,t)=>{var a;(a=t).transform=function(e){var t=typeof e;if("object"===t&&e){if(e instanceof Date)return"#"+e.getTime();if(e instanceof RegExp)return"#"+e.toString();var r=Array.isArray(e)?[]:{};for(var n in e)r[n]=a.transform(e[n]);return"#"+String(e.constructor)+JSON.stringify(r,Object.keys(r).sort())}return t+String(e)+("symbol"===t?Math.random():"")},a.code=function(e){e=a.transform(e);for(var t=7,r=0;r<e.length;)t=31*t+e.charCodeAt(r++)&9007199254740991;return t}}},t={};function a(r){var n=t[r];if(void 0!==n)return n.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,a),i.exports}a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";a.r(r),a.d(r,{Header:()=>i,buildKeyGenerator:()=>S,buildMemoryStorage:()=>b,buildStorage:()=>y,buildWebStorage:()=>A,createCacheResponse:()=>f,createValidateStatus:()=>c,defaultHeaderInterpreter:()=>o,defaultKeyGenerator:()=>C,defaultRequestInterceptor:()=>l,defaultResponseInterceptor:()=>p,isMethodIn:()=>d,isStorage:()=>v,setRevalidationHeaders:()=>u,setupCache:()=>I,testCachePredicate:()=>h,updateCache:()=>g});var e=Symbol("cache-parser");function t(e){return("string"==typeof e||"number"==typeof e)&&(e=Number(e))>=0&&e<1/0}function n(e){return"number"==typeof e||!0===e||"string"==typeof e&&"false"!==e}const i={IfModifiedSince:"if-modified-since",LastModified:"last-modified",IfNoneMatch:"if-none-match",CacheControl:"cache-control",ETag:"etag",Expires:"expires",Age:"age",ContentType:"content-type",XAxiosCacheEtag:"x-axios-cache-etag",XAxiosCacheLastModified:"x-axios-cache-last-modified"},o=a=>{if(!a)return"not enough headers";const r=a[i.CacheControl];if(r){const{noCache:o,noStore:s,mustRevalidate:c,maxAge:d,immutable:u}=function(a){var r=Object.defineProperty({},e,{enumerable:!1,value:1});if(!a||"string"!=typeof a)return r;var i=function(e){var t=e.toLowerCase().replace(/\s+/g,"").split(","),a={};for(var r in t){var n=t[r].split("=",2);a[n[0]]=1===n.length||n[1]}return a}(a);return n(i.immutable)&&(r.immutable=!0),t(i["max-age"])&&(r.maxAge=Number(i["max-age"])),t(i["max-stale"])&&(r.maxStale=Number(i["max-stale"])),t(i["min-fresh"])&&(r.minFresh=Number(i["min-fresh"])),n(i["must-revalidate"])&&(r.mustRevalidate=!0),n(i["must-understand"])&&(r.mustUnderstand=!0),n(i["no-cache"])&&(r.noCache=!0),n(i["no-store"])&&(r.noStore=!0),n(i["no-transform"])&&(r.noTransform=!0),n(i["only-if-cached"])&&(r.onlyIfCached=!0),n(i.private)&&(r.private=!0),n(i["proxy-revalidate"])&&(r.proxyRevalidate=!0),n(i.public)&&(r.public=!0),t(i["s-maxage"])&&(r.sMaxAge=Number(i["s-maxage"])),t(i["stale-if-error"])&&(r.staleIfError=Number(i["stale-if-error"])),t(i["stale-while-revalidate"])&&(r.staleWhileRevalidate=Number(i["stale-while-revalidate"])),r}(r);if(o||s)return"dont cache";if(u)return 31536e6;if(c)return 0;if(d){const e=a[i.Age];return e?1e3*(d-Number(e)):1e3*d}}const o=a[i.Expires];if(o){const e=Date.parse(o)-Date.now();return e>=0?e:"dont cache"}return"not enough headers"};var s=a(549);function c(e){return e?t=>e(t)||304===t:e=>e>=200&&e<300||304===e}function d(e="get",t=[]){e=e.toLowerCase();for(const a of t)if(a.toLowerCase()===e)return!0;return!1}function u(e,t){var a;t.headers||(t.headers={});const{etag:r,modifiedSince:n}=t.cache;if(r){const n=!0===r?null===(a=e.data)||void 0===a?void 0:a.headers[i.ETag]:r;n&&(t.headers[i.IfNoneMatch]=n)}n&&(t.headers[i.IfModifiedSince]=!0===n?e.data.headers[i.LastModified]||new Date(e.createdAt).toUTCString():n.toUTCString())}function f(e,t){return 304===e.status&&t?(e.cached=!0,e.data=t.data,e.status=t.status,e.statusText=t.statusText,e.headers=Object.assign(Object.assign({},t.headers),e.headers),t):{data:e.data,status:e.status,statusText:e.statusText,headers:e.headers}}function l(e){const t=async t=>{var a;if(!1===t.cache)return t;if(t.cache=Object.assign(Object.assign({},e.defaults.cache),t.cache),!d(t.method,t.cache.methods))return t;const r=t.id=e.generateKey(t);let n,i=await e.storage.get(r);e:if("empty"===i.state||"stale"===i.state){if(e.waiting[r]){i=await e.storage.get(r);break e}return e.waiting[r]=(0,s.deferred)(),null===(a=e.waiting[r])||void 0===a||a.catch((()=>{})),await e.storage.set(r,{state:"loading",data:i.data}),"stale"===i.state&&u(i,t),t.validateStatus=c(t.validateStatus),t}if("loading"===i.state){const a=e.waiting[r];if(!a)return await e.storage.remove(r),t;try{n=await a}catch(e){return t}}else n=i.data;return t.adapter=()=>Promise.resolve({config:t,data:n.data,headers:n.headers,status:n.status,statusText:n.statusText,cached:!0,id:r}),t};return{onFulfilled:t,apply:()=>e.interceptors.request.use(t)}}async function h(e,t){var a;if("function"==typeof t)return t(e);const{statusCheck:r,responseMatch:n,containsHeaders:i}=t;if(r&&!await r(e.status)||n&&!await n(e))return!1;if(i)for(const t in i){const r=i[t];if(r&&!await r(null!==(a=e.headers[t.toLowerCase()])&&void 0!==a?a:e.headers[t]))return!1}return!0}async function g(e,t,a){for(const r in a){const n=a[r];if("delete"===n){await e.remove(r);continue}const i=await e.get(r);if("loading"===i.state)continue;const o=await n(i,t);"delete"!==o?"ignore"!==o&&await e.set(r,o):await e.remove(r)}}function p(e){const t=async({storage:e,waiting:t},a)=>{var r;await e.remove(a),null===(r=t[a])||void 0===r||r.reject(null),delete t[a]},a=async a=>{var r,n,o;if(a.id=null!==(r=(o=a.config).id)&&void 0!==r?r:o.id=e.generateKey(a.config),null!==(n=a.cached)&&void 0!==n||(a.cached=!1),a.cached)return a;if(!a.config.cache)return Object.assign(Object.assign({},a),{cached:!1});const s=a.config.cache,c=await e.storage.get(a.id);if("stale"===c.state||"empty"===c.state||"cached"===c.state)return a;if(!c.data&&!await h(a,s.cachePredicate))return await t(e,a.id),a;delete a.headers[i.XAxiosCacheEtag],delete a.headers[i.XAxiosCacheLastModified],s.etag&&!0!==s.etag&&(a.headers[i.XAxiosCacheEtag]=s.etag),s.modifiedSince&&(a.headers[i.XAxiosCacheLastModified]=!0===s.modifiedSince?"use-cache-timestamp":s.modifiedSince.toUTCString());let d=s.ttl||-1;if(null==s?void 0:s.interpretHeader){const r=e.headerInterpreter(a.headers);if("dont cache"===r)return await t(e,a.id),a;d="not enough headers"===r?d:r}const u=f(a,c.data);"function"==typeof d&&(d=await d(a));const l={state:"cached",ttl:d,createdAt:Date.now(),data:u};(null==s?void 0:s.update)&&await g(e.storage,a,s.update);const p=e.waiting[a.id];return null==p||p.resolve(l.data),delete e.waiting[a.id],await e.storage.set(a.id,l),a};return{onFulfilled:a,apply:()=>e.interceptors.response.use(a)}}const m=Symbol(),v=e=>!!e&&!!e[m];function y({set:e,find:t,remove:a}){return{[m]:1,set:e,remove:a,get:async r=>{const n=await t(r);if(!n)return{state:"empty"};if("cached"!==n.state||n.createdAt+n.ttl>Date.now())return n;if(n.data.headers&&(i.ETag in n.data.headers||i.LastModified in n.data.headers||i.XAxiosCacheEtag in n.data.headers||i.XAxiosCacheLastModified in n.data.headers)){const t={data:n.data,state:"stale",createdAt:n.createdAt};return await e(r,t),t}return await a(r),{state:"empty"}}}}function b(){const e={},t=y({find:t=>e[t],set:(t,a)=>{e[t]=a},remove:t=>{delete e[t]}});return Object.assign(Object.assign({},t),{data:e})}var w=a(246);const x=/^\/|\/$/g;function S(e,t){return a=>{if(a.id)return a.id;a.baseURL&&(a.baseURL=a.baseURL.replace(x,"")),a.url&&(a.url=a.url.replace(x,"")),a.method&&(a.method=a.method.toLowerCase());const r=t(a);return e?(0,w.code)(r).toString():r}}const C=S(!0,(({baseURL:e="",url:t="",method:a="get",params:r,data:n})=>({url:e+(e&&t?"/":"")+t,method:a,params:r,data:n})));function I(e,t={}){var a,r,n,i;const s=e;if(s.storage=t.storage||b(),!v(s.storage))throw new Error("Use buildStorage() function");return s.generateKey=t.generateKey||C,s.waiting=t.waiting||{},s.headerInterpreter=t.headerInterpreter||o,s.requestInterceptor=t.requestInterceptor||l(s),s.responseInterceptor=t.responseInterceptor||p(s),s.defaults=Object.assign(Object.assign({},e.defaults),{cache:{ttl:null!==(a=t.ttl)&&void 0!==a?a:3e5,interpretHeader:null!==(r=t.interpretHeader)&&void 0!==r&&r,methods:t.methods||["get"],cachePredicate:t.cachePredicate||{statusCheck:e=>e>=200&&e<400},etag:null!==(n=t.etag)&&void 0!==n&&n,modifiedSince:null!==(i=t.modifiedSince)&&void 0!==i&&i,update:t.update||{}}}),s.requestInterceptor.apply(),s.responseInterceptor.apply(),s}function A(e,t=""){return y({find:a=>{const r=e.getItem(t+a);return r?JSON.parse(r):void 0},set:(a,r)=>{e.setItem(t+a,JSON.stringify(r))},remove:a=>{e.removeItem(t+a)}})}})(),r})()}));
!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()}("undefined"!=typeof self?self:this,(function(){return(()=>{var e={549:(e,t)=>{var a,r;a=t,r=Symbol("fast-defer"),a.deferred=function(){var e,t,a=new Promise((function(a,r){e=a,t=r}));return a.resolve=e,a.reject=t,a[r]=1,a},a.isDeferred=function(e){return!!e&&!!e[r]}},246:(e,t)=>{var a;(a=t).transform=function(e){var t=typeof e;if("object"===t&&e){if(e instanceof Date)return"#"+e.getTime();if(e instanceof RegExp)return"#"+e.toString();var r=Array.isArray(e)?[]:{};for(var n in e)r[n]=a.transform(e[n]);return"#"+String(e.constructor)+JSON.stringify(r,Object.keys(r).sort())}return t+String(e)+("symbol"===t?Math.random():"")},a.code=function(e){e=a.transform(e);for(var t=7,r=0;r<e.length;)t=31*t+e.charCodeAt(r++)&9007199254740991;return t}}},t={};function a(r){var n=t[r];if(void 0!==n)return n.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,a),i.exports}a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";a.r(r),a.d(r,{Header:()=>i,buildKeyGenerator:()=>S,buildMemoryStorage:()=>w,buildStorage:()=>y,buildWebStorage:()=>A,createCacheResponse:()=>f,createValidateStatus:()=>d,defaultHeaderInterpreter:()=>o,defaultKeyGenerator:()=>C,defaultRequestInterceptor:()=>l,defaultResponseInterceptor:()=>p,isMethodIn:()=>c,isStorage:()=>v,setupCache:()=>I,testCachePredicate:()=>h,updateCache:()=>g,updateStaleRequest:()=>u});var e=Symbol("cache-parser");function t(e){return("string"==typeof e||"number"==typeof e)&&(e=Number(e))>=0&&e<1/0}function n(e){return"number"==typeof e||!0===e||"string"==typeof e&&"false"!==e}const i=Object.freeze({IfModifiedSince:"if-modified-since",LastModified:"last-modified",IfNoneMatch:"if-none-match",CacheControl:"cache-control",ETag:"etag",Expires:"expires",Age:"age",ContentType:"content-type",XAxiosCacheEtag:"x-axios-cache-etag",XAxiosCacheLastModified:"x-axios-cache-last-modified",XAxiosCacheStaleIfError:"x-axios-cache-stale-if-error"}),o=a=>{if(!a)return"not enough headers";const r=a[i.CacheControl];if(r){const{noCache:o,noStore:s,mustRevalidate:d,maxAge:c,immutable:u}=function(a){var r=Object.defineProperty({},e,{enumerable:!1,value:1});if(!a||"string"!=typeof a)return r;var i=function(e){var t=e.toLowerCase().replace(/\s+/g,"").split(","),a={};for(var r in t){var n=t[r].split("=",2);a[n[0]]=1===n.length||n[1]}return a}(a);return n(i.immutable)&&(r.immutable=!0),t(i["max-age"])&&(r.maxAge=Number(i["max-age"])),t(i["max-stale"])&&(r.maxStale=Number(i["max-stale"])),t(i["min-fresh"])&&(r.minFresh=Number(i["min-fresh"])),n(i["must-revalidate"])&&(r.mustRevalidate=!0),n(i["must-understand"])&&(r.mustUnderstand=!0),n(i["no-cache"])&&(r.noCache=!0),n(i["no-store"])&&(r.noStore=!0),n(i["no-transform"])&&(r.noTransform=!0),n(i["only-if-cached"])&&(r.onlyIfCached=!0),n(i.private)&&(r.private=!0),n(i["proxy-revalidate"])&&(r.proxyRevalidate=!0),n(i.public)&&(r.public=!0),t(i["s-maxage"])&&(r.sMaxAge=Number(i["s-maxage"])),t(i["stale-if-error"])&&(r.staleIfError=Number(i["stale-if-error"])),t(i["stale-while-revalidate"])&&(r.staleWhileRevalidate=Number(i["stale-while-revalidate"])),r}(String(r));if(o||s)return"dont cache";if(u)return 31536e6;if(d)return 0;if(c){const e=a[i.Age];return e?1e3*(c-Number(e)):1e3*c}}const o=a[i.Expires];if(o){const e=Date.parse(String(o))-Date.now();return e>=0?e:"dont cache"}return"not enough headers"};var s=a(549);function d(e){return e?t=>e(t)||304===t:e=>e>=200&&e<300||304===e}function c(e="get",t=[]){e=e.toLowerCase();for(const a of t)if(a.toLowerCase()===e)return!0;return!1}function u(e,t){var a;t.headers||(t.headers={});const{etag:r,modifiedSince:n}=t.cache;if(r){const n=!0===r?null===(a=e.data)||void 0===a?void 0:a.headers[i.ETag]:r;n&&(t.headers[i.IfNoneMatch]=n)}n&&(t.headers[i.IfModifiedSince]=!0===n?e.data.headers[i.LastModified]||new Date(e.createdAt).toUTCString():n.toUTCString())}function f(e,t){return 304===e.status&&t?(e.cached=!0,e.data=t.data,e.status=t.status,e.statusText=t.statusText,e.headers=Object.assign(Object.assign({},t.headers),e.headers),t):{data:e.data,status:e.status,statusText:e.statusText,headers:e.headers}}function l(e){const t=async t=>{var a;if(!1===t.cache)return t;if(t.cache=Object.assign(Object.assign({},e.defaults.cache),t.cache),!c(t.method,t.cache.methods))return t;const r=t.id=e.generateKey(t);let n,i=await e.storage.get(r);e:if("empty"===i.state||"stale"===i.state){if(e.waiting[r]){i=await e.storage.get(r);break e}return e.waiting[r]=(0,s.deferred)(),null===(a=e.waiting[r])||void 0===a||a.catch((()=>{})),await e.storage.set(r,{state:"loading",previous:i.state,data:i.data,createdAt:i.createdAt}),"stale"===i.state&&u(i,t),t.validateStatus=d(t.validateStatus),t}if("loading"===i.state){const a=e.waiting[r];if(!a)return await e.storage.remove(r),t;try{n=await a}catch(e){return t}}else n=i.data;return t.adapter=()=>Promise.resolve({config:t,data:n.data,headers:n.headers,status:n.status,statusText:n.statusText,cached:!0,id:r}),t};return{onFulfilled:t,apply:()=>e.interceptors.request.use(t)}}async function h(e,t){var a;if("function"==typeof t)return t(e);const{statusCheck:r,responseMatch:n,containsHeaders:i}=t;if(r&&!await r(e.status)||n&&!await n(e))return!1;if(i)for(const t in i){const r=i[t];if(r&&!await r(null!==(a=e.headers[t.toLowerCase()])&&void 0!==a?a:e.headers[t]))return!1}return!0}async function g(e,t,a){for(const r in a){const n=a[r];if("delete"===n){await e.remove(r);continue}const i=await e.get(r);if("loading"===i.state)continue;const o=await n(i,t);"delete"!==o?"ignore"!==o&&await e.set(r,o):await e.remove(r)}}function p(e){const t=async t=>{var a;await e.storage.remove(t),null===(a=e.waiting[t])||void 0===a||a.reject(null),delete e.waiting[t]},a=async a=>{var r,n,o,s;if(a.id=null!==(r=(s=a.config).id)&&void 0!==r?r:s.id=e.generateKey(a.config),null!==(n=a.cached)&&void 0!==n||(a.cached=!1),a.cached)return a;if(!a.config.cache)return Object.assign(Object.assign({},a),{cached:!1});const d=a.config.cache,c=await e.storage.get(a.id);if("stale"===c.state||"empty"===c.state||"cached"===c.state)return a;if(!c.data&&!await h(a,d.cachePredicate))return await t(a.id),a;for(const e in i)e.startsWith("XAxiosCache")&&delete a.headers[e];d.etag&&!0!==d.etag&&(a.headers[i.XAxiosCacheEtag]=d.etag),d.modifiedSince&&(a.headers[i.XAxiosCacheLastModified]=!0===d.modifiedSince?"use-cache-timestamp":d.modifiedSince.toUTCString());let u=d.ttl||-1;if(null==d?void 0:d.interpretHeader){const r=e.headerInterpreter(a.headers);if("dont cache"===r)return await t(a.id),a;u="not enough headers"===r?u:r}const l=f(a,c.data);"function"==typeof u&&(u=await u(a)),d.staleIfError&&(a.headers[i.XAxiosCacheStaleIfError]=String(u)),(null==d?void 0:d.update)&&await g(e.storage,a,d.update);const p={state:"cached",ttl:u,createdAt:Date.now(),data:l};return null===(o=e.waiting[a.id])||void 0===o||o.resolve(p.data),delete e.waiting[a.id],await e.storage.set(a.id,p),a},r=async a=>{var r;const n=a.config;if(!n||!1===n.cache||!n.id)throw a;const i=await e.storage.get(n.id),o=n.cache;if("loading"!==i.state||"stale"!==i.previous)throw await t(n.id),a;if(null==o?void 0:o.staleIfError){const t="function"==typeof o.staleIfError?await o.staleIfError(a.response,i,a):o.staleIfError;if(!0===t||"number"==typeof t&&i.createdAt+t>Date.now())return null===(r=e.waiting[n.id])||void 0===r||r.resolve(i.data),delete e.waiting[n.id],await e.storage.set(n.id,{state:"stale",createdAt:Date.now(),data:i.data}),{cached:!0,config:n,id:n.id,data:i.data.data,headers:i.data.headers,status:i.data.status,statusText:i.data.statusText}}throw a};return{onFulfilled:a,onRejected:r,apply:()=>e.interceptors.response.use(a,r)}}const m=Symbol(),v=e=>!!e&&!!e[m];function y({set:e,find:t,remove:a}){return{[m]:1,set:e,remove:a,get:async r=>{const n=await t(r);if(!n)return{state:"empty"};if("cached"!==n.state||n.createdAt+n.ttl>Date.now())return n;if(n.data.headers&&(i.ETag in n.data.headers||i.LastModified in n.data.headers||i.XAxiosCacheEtag in n.data.headers||i.XAxiosCacheStaleIfError in n.data.headers||i.XAxiosCacheLastModified in n.data.headers)){const t={state:"stale",createdAt:n.createdAt,data:n.data};return await e(r,t),t}return await a(r),{state:"empty"}}}}function w(){const e={},t=y({find:t=>e[t],set:(t,a)=>{e[t]=a},remove:t=>{delete e[t]}});return Object.assign(Object.assign({},t),{data:e})}var b=a(246);const x=/^\/|\/$/g;function S(e,t){return a=>{if(a.id)return a.id;a.baseURL&&(a.baseURL=a.baseURL.replace(x,"")),a.url&&(a.url=a.url.replace(x,"")),a.method&&(a.method=a.method.toLowerCase());const r=t(a);return e?(0,b.code)(r).toString():r}}const C=S(!0,(({baseURL:e="",url:t="",method:a="get",params:r,data:n})=>({url:e+(e&&t?"/":"")+t,method:a,params:r,data:n})));function I(e,t={}){var a,r,n,i,s;const d=e;if(d.storage=t.storage||w(),!v(d.storage))throw new Error("Use buildStorage() function");return d.generateKey=t.generateKey||C,d.waiting=t.waiting||{},d.headerInterpreter=t.headerInterpreter||o,d.requestInterceptor=t.requestInterceptor||l(d),d.responseInterceptor=t.responseInterceptor||p(d),d.defaults.cache={ttl:null!==(a=t.ttl)&&void 0!==a?a:3e5,interpretHeader:null!==(r=t.interpretHeader)&&void 0!==r&&r,methods:t.methods||["get"],cachePredicate:t.cachePredicate||{statusCheck:e=>e>=200&&e<400},etag:null!==(n=t.etag)&&void 0!==n&&n,modifiedSince:null!==(i=t.modifiedSince)&&void 0!==i&&i,staleIfError:null!==(s=t.staleIfError)&&void 0!==s&&s,update:t.update||{}},d.requestInterceptor.apply(),d.responseInterceptor.apply(),d}function A(e,t=""){return y({find:a=>{const r=e.getItem(t+a);return r?JSON.parse(r):void 0},set:(a,r)=>{e.setItem(t+a,JSON.stringify(r))},remove:a=>{e.removeItem(t+a)}})}})(),r})()}));
//# sourceMappingURL=index.map

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

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

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

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

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

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

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

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

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

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

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