Skip to content

akinolu52/es-storage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

es-storage

Access client storage

Installation

Use the package manager npm to install es-storage.

npm install es-storage

Usage

import { localStorage, sessionStorage } from 'es-storage';


sessionStorage.set('key', null)
sessionStorage.get('key') # returns null
//passing an default value to be returned when then the value is not found
sessionStorage.get('key', 'default-value') # returns 'default-value'

sessionStorage.set('key', 'value')
sessionStorage.get('key') # returns 'value'

sessionStorage.setObject('details', null)
sessionStorage.getObject('details') # returns null
//passing an default value to be returned when then the value is not found
sessionStorage.getObject('details', { key: 'x', value: 'y' }) # returns { key: 'x', value: 'y' }

sessionStorage.clear()  # this will clear all the data on the sessionstorage
sessionStorage.remove('key') # this will delete the key from the sessionstorage


localStorage.set('key', null)
localStorage.get('key') # returns null
//passing an default value to be returned when then the value is not found
localStorage.get('key', 'default-value') # returns 'default-value'

localStorage.set('key', 'value')
localStorage.get('key') # returns 'value'

localStorage.setObject('details', null)
localStorage.getObject('details') # returns null
//passing an default value to be returned when then the value is not found
localStorage.getObject('details', { key: 'x', value: 'y' }) # returns { key: 'x', value: 'y' }

localStorage.clear()  # this will clear all the data on the localstorage
localStorage.remove('key') # this will delete the key from the localstorage

Usage

it'll return false if localStorage or sessionStorage is not available

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

GNU

About

Access client storage

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published