Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kkristof200/ts-cachable
https://github.com/kkristof200/ts-cachable
Last synced: 10 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/kkristof200/ts-cachable
- Owner: kkristof200
- License: mit
- Created: 2020-09-27T09:41:05.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-11-26T13:47:10.000Z (almost 4 years ago)
- Last Synced: 2024-10-27T22:31:42.332Z (19 days ago)
- Language: TypeScript
- Size: 3.91 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# kcachable
Easily create cachable values of any type that can be saved/loaded at any times
## Install
```bash
npm i kcachable
```## Usage
```typescript
import { Cachable } from 'kcachable'const value: string = null // Value to init with (optional)
const defaultValue = 'string' // Value to use if init-value is null and there is no value saved yet
const saveIfNotExists = false // save enw value (init-value or defaultValue) there is no value saved yet
const cVal = new Cachable('myVal.json', value, defaultValue, saveIfNotExists)console.log(cVal.value)
cVal.value = 'newString'
cVal.save()
```