@types/node-fetch-cache
Version:
TypeScript definitions for node-fetch-cache
64 lines (49 loc) • 1.95 kB
Markdown
# Installation
> `npm install --save @types/node-fetch-cache`
# Summary
This package contains type definitions for node-fetch-cache (https://github.com/mistval/node-fetch-cache#readme).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node-fetch-cache.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node-fetch-cache/index.d.ts)
````ts
import fetch = require("node-fetch");
declare class NFCResponse extends fetch.Response {
ejectFromCache(): Promise<void>;
}
interface Cache {
get(key: string): Promise<any>;
remove(key: string): Promise<void>;
set(key: string, bodyStream: fetch.Response["body"], metaData: any): Promise<any>;
}
interface MemoryCacheOptions {
ttl?: number;
}
export class MemoryCache implements Cache {
constructor(options?: MemoryCacheOptions);
get(key: string): Promise<any>;
remove(key: string): Promise<void>;
set(key: string, bodyStream: fetch.Response["body"], metaData: any): Promise<any>;
}
interface FileSystemCacheOptions {
ttl?: number;
cacheDirectory?: string;
}
export class FileSystemCache implements Cache {
constructor(options?: FileSystemCacheOptions);
get(key: string): Promise<any>;
remove(key: string): Promise<void>;
set(key: string, bodyStream: fetch.Response["body"], metaData: any): Promise<any>;
}
type FetchBuilder = (cache: Cache) => FetchCache;
type FetchCache = ((...args: Parameters<typeof fetch>) => Promise<NFCResponse>) & {
withCache: FetchBuilder;
};
declare const defaultFetch: FetchCache;
export default defaultFetch;
export const fetchBuilder: FetchCache;
````
### Additional Details
* Last updated: Tue, 16 Jan 2024 23:07:00 GMT
* Dependencies: [@types/node-fetch](https://npmjs.com/package/@types/node-fetch)
# Credits
These definitions were written by [Yusuke Fujiki](https://github.com/fujikky).