# localstorage-ns

> Namespaced key/value store backed by localStorage with events and default value loading.

Latest version **1.0.2** (published 2015-10-07) · MIT license · 0 weekly downloads

## Install

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

## 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 | 1.0.2 |
| Published | 2015-10-07 |
| First published | 2015-10-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Kevin Neff |
| Maintainers | kvnneff |
| Keywords | browser, localstorage |

## Links

- npm: https://www.npmjs.com/package/localstorage-ns
- Repository: https://github.com/kvnneff/localstorage-ns
- Homepage: https://github.com/kvnneff/localstorage-ns#readme
- Issues: https://github.com/kvnneff/localstorage-ns/issues
- npm.io page: https://npm.io/package/localstorage-ns

## Dependencies (2)

- [component-clone](https://npm.io/package/component-clone.md) ^0.2.2
- [component-emitter](https://npm.io/package/component-emitter.md) ^1.2.0

## 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

- 1.0.2 (latest) — 2015-10-07
- 1.0.1 — 2015-10-07
- 1.0.0 — 2015-10-07

## README

# localStorage-ns [![travis ci](https://travis-ci.org/kvnneff/localstorage-ns.svg)](https://travis-ci.org/kvnneff/localstorage-ns)

Namespaced key/value store backed by localStorage with events and default value loading.

## Example:
```js
import Store from 'localStorage-ns'

let foo = Store('foo', {age: 34})
let bar = Store('bar', {age: 29})

foo.set('name', 'Kevin')
bar.set('name', 'Charlie')

foo.get('name') //=> 'Kevin'
foo.get('age') //=> '34'

bar.get('name') //=> 'Charlie'
bar.get('age') //=> '29'
```

## API

### Store(name, [defaults])

Create a new namespaced store with `name` and optional `defaults`.

### store#set(key, value)

Set `key` to `value`.

### store#get(key)

Return value of `key`.

### store#clear()

Clear the namespaced store.

### store#on(event, fn)

Listen for the given `event` and execute callback `fn`.  Available events are:

- **set**: Emitted whenever a `key` is being set.  Both the `key` being set and the `value` of `key` will be passed to the callback.
- **change**: Emitted on any change.  No values are passed to the callback.
- **clear**: Emitted when the store is cleared. No values are passed to the callback.

## License

MIT

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