1.0.0 • Published 3 years ago

enhanced-web-storage v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

enhanced-web-storage

A enhanced web storage with env support, expire time control, change callback and LRU storage clear strategy.

How to Start

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

Methods on instance

NameParamReturnDesc
setItem@param key @param valueundefinedSet given value to given key
getItemstringanyReturn value of key in storage if any
removeItemstringundefinedRemove key value pair from storage
changeItem@param key @param callback @param default valueundefinedChange value of given key based on callback
getKeysnullstring []Obtain all stored keys
getValuesnullany []Obtain all stored values
sizenullnumberObtain size of currently used storage
hasItemstringbooleanCheck If given key is stored or not
clearAllnullundefinedClear all storage