0.0.3 • Published 4 years ago

kcachable v0.0.3

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

kcachable

Easily create cachable values of any type that can be saved/loaded at any times

Install

npm i kcachable

Usage

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()