Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/susisu/catcher
fetcher with cache
https://github.com/susisu/catcher
Last synced: 2 days ago
JSON representation
fetcher with cache
- Host: GitHub
- URL: https://github.com/susisu/catcher
- Owner: susisu
- License: mit
- Created: 2019-11-28T15:45:31.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-04-03T17:30:11.000Z (9 months ago)
- Last Synced: 2024-12-06T07:05:54.325Z (21 days ago)
- Language: TypeScript
- Homepage:
- Size: 506 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @susisu/catcher
[![CI](https://github.com/susisu/catcher/workflows/CI/badge.svg)](https://github.com/susisu/catcher/actions?query=workflow%3ACI)
``` shell
# npm
npm i @susisu/catcher
# yarn
yarn add @susisu/catcher
# pnpm
pnpm add @susisu/catcher
```## Usage
``` typescript
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();
```## License
[MIT License](http://opensource.org/licenses/mit-license.php)
## Author
Susisu ([GitHub](https://github.com/susisu), [Twitter](https://twitter.com/susisu2413))