@susisu/catcher
v0.7.1
Published
cached fetcher
Downloads
237
Readme
@susisu/catcher
# npm
npm i @susisu/catcher
# yarn
yarn add @susisu/catcher
# pnpm
pnpm add @susisu/catcher
Usage
import { Catcher } from "@susisu/catcher";
const catcher = new Catcher({
fetcher: () => fetchFromSource(params),
});
// data1 = data fetched from the source
const data1 = await catcher.fetch();
// data2 = cached data equal to data1
const data2 = await catcher.fetch();
// expire the cache
catcher.expire();
// data3 = refetched data from the source
const data3 = await catcher.fetch();