@types/node-fetch-cache
TypeScript icon, indicating that this package has built-in type declarations

3.0.5 • Public • Published

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

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

Credits

These definitions were written by Yusuke Fujiki.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/node-fetch-cache

Weekly Downloads

886

Version

3.0.5

License

MIT

Unpacked Size

5.2 kB

Total Files

5

Last publish

Collaborators

  • types