Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alrico88/storage-helper-functions
Functions to help usage of localStorage or sessionStorage
https://github.com/alrico88/storage-helper-functions
browser localstorage sessionstorage
Last synced: about 1 month ago
JSON representation
Functions to help usage of localStorage or sessionStorage
- Host: GitHub
- URL: https://github.com/alrico88/storage-helper-functions
- Owner: alrico88
- Created: 2020-07-27T13:53:17.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-01-28T09:22:49.000Z (almost 4 years ago)
- Last Synced: 2024-12-09T05:39:52.762Z (about 1 month ago)
- Topics: browser, localstorage, sessionstorage
- Language: JavaScript
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## StorageHelper
**Kind**: global class
- [StorageHelper](#StorageHelper)
- [new StorageHelper()](#new_StorageHelper_new)
- [.module.exports](#StorageHelper.module.exports)
- [new module.exports(storageProvider, [compressed])](#new_StorageHelper.module.exports_new)
- [.store(key, data, [format])](#StorageHelper.store) ⇒void
- [.get(key, [format])](#StorageHelper.get) ⇒any
### new StorageHelper()
StorageHelper class
### StorageHelper.module.exports
**Kind**: static class of [
StorageHelper
](#StorageHelper)#### new module.exports(storageProvider, [compressed])
Creates an instance of StorageHelper.
| Param | Type | Default | Description |
| --------------- | -------------------------------------------------------- | ------------------ | ------------------------------------------------ |
| storageProvider |localStorage
\|sessionStorage
| | Storage provider, localStorage or sessionStorage |
| [compressed] |boolean
|false
| Option to use compression for strings |### StorageHelper.store(key, data, [format]) ⇒
void
Stores data to storageProvider
**Kind**: static method of [
StorageHelper
](#StorageHelper)| Param | Type | Default | Description |
| -------- | -------------------------------------------------------------- | ----------------------------- | ------------------------------- |
| key |string
| | Key used to identify saved item |
| data |string
\|object
| | Data to save |
| [format] |'text'
\|'json'
|"text"
| Data format |### StorageHelper.get(key, [format]) ⇒
any
Gets key from storageProvider
**Kind**: static method of [
StorageHelper
](#StorageHelper)
**Returns**:any
- - The value of said key| Param | Type | Default | Description |
| -------- | -------------------------------------------------------------- | ----------------------------- | ---------------------------- |
| key |string
| | Key to retrieve from storage |
| [format] |'text'
\|'json'
|"text"
| Format of stored data |