# @eolme/universal-storage

> [![npm (scoped with tag)](https://img.shields.io/npm/v/@eolme/universal-storage/latest.svg?style=flat-square)](https://npmjs.com/package/@nuxtjs/universal-storage)

Latest version **2.0.2** (published 2020-09-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install @eolme/universal-storage
pnpm add @eolme/universal-storage
yarn add @eolme/universal-storage
bun add @eolme/universal-storage
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2020-09-28 |
| First published | 2020-03-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 15.9 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Anton Petrov |
| Maintainers | eolme |
| Keywords | storage, localstorage, cookie |

## Links

- npm: https://www.npmjs.com/package/@eolme/universal-storage
- Homepage: https://github.com/eolme/universal-storage/blob/master/README.md
- Issues: https://github.com/eolme/universal-storage/issues
- npm.io page: https://npm.io/package/@eolme/universal-storage

## Dependencies (8)

- [cookie](https://npm.io/package/cookie.md) ^0.4.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.20
- [@types/node](https://npm.io/package/@types/node.md) ^14.11.2
- [@types/cookie](https://npm.io/package/@types/cookie.md) ^0.4.0
- [@types/lodash](https://npm.io/package/@types/lodash.md) ^4.14.161
- [json-date-parser](https://npm.io/package/json-date-parser.md) ^1.0.1
- [secure-json-parse](https://npm.io/package/secure-json-parse.md) ^2.1.0
- [@types/secure-json-parse](https://npm.io/package/@types/secure-json-parse.md) ^1.0.2

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 2.0.2 (latest) — 2020-09-28
- 1.2.0 — 2020-04-11
- 1.1.0 — 2020-04-11
- 1.0.0 — 2020-03-31

## README

# Universal Storage

[![npm (scoped with tag)](https://img.shields.io/npm/v/@eolme/universal-storage/latest.svg?style=flat-square)](https://npmjs.com/package/@nuxtjs/universal-storage)

> Universal Storage Utilities inspired by [@nuxt-community/universal-storage-module](https://github.com/nuxt-community/universal-storage-module)

## Setup

- Add `@eolme/universal-storage` dependency using yarn or npm to your project

```sh
yarn add @eolme/universal-storage
```

OR

```sh
npm install @eolme/universal-storage --save
```

## Usage

### Options

Options are defined as following:

```js
{
  cookie, // set false to disable
  localStorage, // set false to disable
  initialState, // plain object (optional)
  ignoreExceptions
}
```

and default to the following values:

```js
{
  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](./LICENSE)

---
_Source: https://npm.io/package/@eolme/universal-storage · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
