An open API service indexing awesome lists of open source software.

https://github.com/sonukr/store

A tiny localStorage Wrapper.
https://github.com/sonukr/store

javascript localdb localstorage localstorage-api storage

Last synced: over 1 year ago
JSON representation

A tiny localStorage Wrapper.

Awesome Lists containing this project

README

          

# Store
A tiny API wrapper for `localStorage` that lets you safely save numbers, arrays, objects and other data types.

## Usage and API

#### Include the store.min.js

```javascript

```

#### Usage

```javascript

// define some data
var Array = [
{
name: 'Objects 1',
count: 10
},
{
name: 'Objects 2',
count: 11
}
];

var String = 'This is a text and i will save in store.';

// You can pas any kind of data type in value field like, array, object, string etc.
// save data into localStorage.
// API: store.set(key, value)
// key — string
// value - array
store.set('Array', Array);

// save data into localStorage.
// API: store.set(key, value)
// key — string
// value - string
store.set('String', String);

// get value from localStorage by key.
// API: store.get(key)
// key — string
store.get('Array');
> [{name: 'Objects 1',count: 10},{name: 'Objects 2',count: 11}]

// get value from localStorage by key.
// API: store.get(key)
// key — string
store.get('String');
> 'This is a text and i will save in store.';

// remove item from localStorage
store.remove('Array');
store.remove('String');

//get entire localStorage object
store.all
> Storage {
Array: "[{"name":"Objects 1","count":10},{"name":"Objects 2","count":11}]",
String: ""This is a text and i will save in store."", length: 2
}

// get localStorage items count
store.length
> 2

// or empty localStorage
store.clear();

```