enhanced-web-storage

1.0.0 • Public • Published

enhanced-web-storage

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

Version License

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

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

Readme

Keywords

none

Package Sidebar

Install

npm i enhanced-web-storage

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

9.15 kB

Total Files

8

Last publish

Collaborators

  • rudeus_greyrat