fix breaking change on 1.6.0

This commit is contained in:
Arthur Fiorette 2024-10-18 10:52:31 -03:00
parent 1c3628b1da
commit 2633b9cbe0
No known key found for this signature in database
GPG Key ID: 79FA8EC214FA0233
3 changed files with 21 additions and 14 deletions

View File

@ -38,7 +38,10 @@ For long running processes, you can avoid memory leaks by using playing with the
```ts
import Axios from 'axios';
import { setupCache, buildMemoryStorage } from 'axios-cache-interceptor';
import {
setupCache,
buildMemoryStorage
} from 'axios-cache-interceptor';
setupCache(axios, {
// You don't need to to that, as it is the default option.
@ -140,7 +143,8 @@ simple object to build the storage. It has 3 methods:
storage or `undefined` if not found.
- `clear() => MaybePromise<void>`:
Clears all data from storage.
Clears all data from storage. **This method isn't used by the interceptor itself**, instead, its
here for you to use it programmatically.
## Third Party Storages
@ -240,7 +244,7 @@ const indexedDbStorage = buildStorage({
### Node Cache
This example implementation uses [node-cache](https://github.com/node-cache/node-cache) as a storage method. Do note
This example implementation uses [node-cache](https://github.com/node-cache/node-cache) as a storage method. Do note
that this library is somewhat old, however it appears to work at the time of writing.
```ts

View File

@ -1,13 +1,20 @@
import type { CacheRequestConfig } from '../cache/axios.js';
import { Header } from '../header/headers.js';
import type { MaybePromise } from '../util/types.js';
import type { AxiosStorage, CachedStorageValue, StaleStorageValue, StorageValue } from './types.js';
import type {
AxiosStorage,
CachedStorageValue,
StaleStorageValue,
StorageValue
} from './types.js';
/** Returns true if the provided object was created from {@link buildStorage} function. */
export const isStorage = (obj: unknown): obj is AxiosStorage =>
!!obj && !!(obj as Record<string, boolean>)['is-storage'];
function hasUniqueIdentifierHeader(value: CachedStorageValue | StaleStorageValue): boolean {
function hasUniqueIdentifierHeader(
value: CachedStorageValue | StaleStorageValue
): boolean {
const headers = value.data.headers;
return (
@ -65,13 +72,6 @@ export interface BuildStorage extends Omit<AxiosStorage, 'get'> {
key: string,
currentRequest?: CacheRequestConfig
) => MaybePromise<StorageValue | undefined>;
/**
* Deletes all values from the storage.
*
* @see https://axios-cache-interceptor.js.org/guide/storages#buildstorage
*/
clear: () => MaybePromise<void>;
}
/**

View File

@ -136,9 +136,12 @@ export interface AxiosStorage {
get: (key: string, currentRequest?: CacheRequestConfig) => MaybePromise<StorageValue>;
/**
* Deletes all values from the storage.
* Deletes all values from the storage, this method isn't used by the interceptor
* and is here just for convenience.
*
* **All native storages implement them, but it's not required.**
*
* @see https://axios-cache-interceptor.js.org/guide/storages#buildstorage
*/
clear: () => MaybePromise<void>;
clear?: () => MaybePromise<void>;
}