UNPKG

enkanetwork

Version:

API wrapper for enka.network written on TypeScript which provides localization, caching and convenience

43 lines (42 loc) 1.42 kB
import type { IAssetAdapter } from "./types"; export interface IFileSystemAdapterOptions { directory?: string; pathPrefix?: string; baseUrl?: string; extension?: string; fallbackToOrigin?: boolean; userAgent?: string | false; concurrency?: number; } /** * Caches image assets on the local filesystem. On `resolve`: * - if the file is already cached, returns a local reference; * - otherwise enqueues a deduplicated background download and (by default) returns the * origin URL until the file is available, after which subsequent calls return the * local reference. * * Downloads are best-effort and never throw out of `resolve`. Use `flush` to await all * pending downloads (e.g. to warm the cache before rendering). */ export declare class FileSystemAdapter implements IAssetAdapter { directory: string; pathPrefix: string; baseUrl: string; extension: string; fallbackToOrigin: boolean; userAgent: string | false; concurrency: number; private cached; private pending; private queue; private active; constructor({ directory, pathPrefix, baseUrl, extension, fallbackToOrigin, userAgent, concurrency, }?: IFileSystemAdapterOptions); init(): void; private localRef; private originUrl; private fetchToDisk; private next; private schedule; resolve(filename: string): string; flush(): Promise<void>; }