Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andrew--r/astorage
A tiny API wrapper for localStorage
https://github.com/andrew--r/astorage
api-wrapper localstorage microjs
Last synced: about 6 hours ago
JSON representation
A tiny API wrapper for localStorage
- Host: GitHub
- URL: https://github.com/andrew--r/astorage
- Owner: andrew--r
- Created: 2015-06-26T12:52:25.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-07-21T09:13:29.000Z (over 9 years ago)
- Last Synced: 2024-11-10T01:57:42.459Z (9 days ago)
- Topics: api-wrapper, localstorage, microjs
- Language: JavaScript
- Size: 119 KB
- Stars: 101
- Watchers: 8
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ASTORAGE
A tiny API wrapper for `localStorage` that lets you safely save numbers, arrays, objects and other data types.## Installation
Astorage is available via npm or bower.```bash
npm install astorage
```or
```bash
bower install astorage
```Otherwise you can directly [download zip](https://github.com/andrew--r/astorage/archive/master.zip).
## Usage and API
```javascript
// define some data
var users = [
{
name: 'John Doe',
age: 21
},
{
name: 'Alex Smith',
age: 35
}
];// save data into localStorage.
// API: astorage.set(key, value)
// key — string
// value — string, number, array, object or anything else
astorage.set('users', users);// get value from localStorage by key.
// API: astorage.get(key)
// key — string
astorage.get('users');
> [{name: 'John Doe', age: 21}, {name: 'Alex Smith', age: 35}]// remove item from localStorage
astorage.remove('users');// or empty localStorage
astorage.clear();// get localStorage items count
astorage.length
> 0
```## LICENSE
Released under the MIT license.```
The MIT License (MIT)Copyright © 2015 Andrew Romanov, Kiril Osiyuk
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
```