Universal Storage
Universal Storage Utilities inspired by @nuxt-community/universal-storage-module
Setup
- Add
@eolme/universal-storage
dependency using yarn or npm to your project
yarn add @eolme/universal-storage
OR
npm install @eolme/universal-storage --save
Usage
Options
Options are defined as following:
{
cookie, // set false to disable
localStorage, // set false to disable
initialState, // plain object (optional)
ignoreExceptions
}
and default to the following values:
{
cookie: {
prefix: '',
options: {
path: '/'
}
},
localStorage: {
prefix: ''
},
ignoreExceptions: false
}
Api
-
storage.getUniversal(key)
-
storage.setUniversal(key, value)
-
storage.syncUniversal(key, defaultValue)
-
storage.removeUniversal(key)
-
storage.getState(key)
-
storage.setState(key, value)
-
storage.removeState(key)
-
storage.getLocalStorage(key)
-
storage.setLocalStorage(key, value)
-
storage.removeLocalStorage(key)
-
storage.getCookies()
-
storage.getCookie(key)
-
storage.setCookie(key, value)
-
storage.removeCookie(key)
Roadmap
- TypeScript support
- Tests