# humble-localstorage

> wraps localStorage and adds .getObject(), .setObject(), .isPersistent

Latest version **2.0.0** (published 2018-11-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install humble-localstorage
pnpm add humble-localstorage
yarn add humble-localstorage
bun add humble-localstorage
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2018-11-20 |
| First published | 2015-01-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 48.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Gregor Martynus |
| Maintainers | gr2m |
| Keywords | localstorage, browser, data |

## Links

- npm: https://www.npmjs.com/package/humble-localstorage
- Repository: https://github.com/gr2m/humble-localstorage
- Homepage: http://gr2m.github.io/humble-localstorage/
- Issues: http://github.com/gr2m/humble-localstorage/issues
- npm.io page: https://npm.io/package/humble-localstorage

## Dependencies (2)

- [has-localstorage](https://npm.io/package/has-localstorage.md) ^1.0.1
- [localstorage-memory](https://npm.io/package/localstorage-memory.md) ^1.0.2

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2018-11-20
- 1.4.2 — 2015-09-02
- 1.4.1 — 2015-02-09
- 1.4.0 — 2015-02-09
- 1.3.0 — 2015-02-09
- 1.2.0 — 2015-02-09
- 1.1.4 — 2015-02-08
- 1.1.3 — 2015-02-08
- 1.1.2 — 2015-02-08
- 1.1.1 — 2015-02-08
- 1.1.0 — 2015-02-08
- 1.0.1 — 2015-01-03
- 1.0.0 — 2015-01-03

## README

# humble-localstorage

> wraps localStorage and adds .getObject(), .setObject(), .isPersistent

[![Build Status](https://travis-ci.org/gr2m/humble-localstorage.png?branch=master)](https://travis-ci.org/gr2m/humble-localstorage/)
[![Dependencies Status](https://david-dm.org/gr2m/humble-localstorage.svg)](https://david-dm.org/gr2m/humble-localstorage)
[![devDependency Status](https://david-dm.org/gr2m/humble-localstorage/dev-status.svg)](https://david-dm.org/gr2m/humble-localstorage#info=devDependencies) [![Greenkeeper badge](https://badges.greenkeeper.io/gr2m/humble-localstorage.svg)](https://greenkeeper.io/)

`localStorage` is a simple key/value store API for browsers, perfectly
suited to store little amount of data like configurations.

`humbleLocalStorage` provides additional APIs to store / retrieve
JSON objects, and also handles several circumstances in which Browsers
do not support or persist localStorage (e.g. private modes,
Cookies disabled, etc).

In case data cannot be persisted in localStorage,  `humbleLocalStorage`
falls back to in-memory storage. To determine if data is being persisted,
use `humbleLocalStorage.isPersistent` property.


## Installation

- Download: https://github.com/gr2m/humble-localstorage/releases
- or: install via Bower: `bower install -S humble-localstorage`
- or: install via npm: `npm install -S humble-localstorage`


## Usage

```js
humbleLocalStorage.getItem('mykey') // string value or null
humbleLocalStorage.setItem('mykey', 123) // stored as '123'
humbleLocalStorage.removeItem('mykey')
humbleLocalStorage.clear() // removes all data
humbleLocalStorage.key(0) // name of key by numeric index, or null
humbleLocalStorage.length // number of stored keys

humbleLocalStorage.getObject('mykey') // JSON value or null
humbleLocalStorage.setObject('mykey', {foo: 'bar'}) // stored as '{"foo": "bar"}'
humbleLocalStorage.isPersistent // true if data persists page reload, false if not
```


## Run tests

```
# see all available tasks
npm run

# run unit & integration tests
# note: selenium must be running
npm test
```

## License

MIT

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