@eolme/universal-storage
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

Universal Storage

npm (scoped with tag)

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

License

MIT License

/@eolme/universal-storage/

    Package Sidebar

    Install

    npm i @eolme/universal-storage

    Weekly Downloads

    1

    Version

    2.0.2

    License

    MIT

    Unpacked Size

    16.3 kB

    Total Files

    12

    Last publish

    Collaborators

    • eolme