p5-analysis
Version:
API to find, create, and analyze p5.js sketch files.
26 lines (25 loc) • 909 B
TypeScript
/** Wrapper for node-fetch that looks in a cache directory before fetching from
* the network. If the cache is missing, it will be created. If the file is
* missing, it will be fetched from the network and saved to the cache. If the
* file is present, it will be read from the cache.
*
* Usage: const fetch = require('node-fetch-cache'); const res = await
* fetch('https://example.com/file.json'); console.log(res.text());
*
* const fetch = require('node-fetch-cache')('/path/to/cache/dir'); const res =
* await fetch('https://example.com/file.json'); console.log(res.text());
*/
export declare function cachedFetch(url: string): Promise<Response>;
declare type Response = {
headers: {
[key: string]: string;
};
ok: boolean;
redirected: boolean;
status: number;
statusText: string;
text: () => Promise<string>;
type: string;
url: string;
};
export {};