A enhanced web storage with env support, expire time control, change callback and LRU storage clear strategy.
import CustomStorage from 'enhanced-web-storage'
// obtain a CustomStorage instance
const storage = new CustomStorage()
// set instance bootStrap config
storage.bootStrap({
// web storage mode, support local or session
mode:'local',
// expired time in milliseconds
timeout:5000
})
Name | Param | Return | Desc |
---|---|---|---|
setItem | @param key @param value |
undefined | Set given value to given key |
getItem | string | any | Return value of key in storage if any |
removeItem | string | undefined | Remove key value pair from storage |
changeItem | @param key @param callback @param default value |
undefined | Change value of given key based on callback |
getKeys | null | string [] | Obtain all stored keys |
getValues | null | any [] | Obtain all stored values |
size | null | number | Obtain size of currently used storage |
hasItem | string | boolean | Check If given key is stored or not |
clearAll | null | undefined | Clear all storage |