https://github.com/simonsmith/storage-wrap
Simple wrapper for local/sessionStorage
https://github.com/simonsmith/storage-wrap
Last synced: about 1 year ago
JSON representation
Simple wrapper for local/sessionStorage
- Host: GitHub
- URL: https://github.com/simonsmith/storage-wrap
- Owner: simonsmith
- Created: 2013-12-22T20:17:03.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-01-13T14:52:53.000Z (over 12 years ago)
- Last Synced: 2025-04-12T08:54:06.749Z (about 1 year ago)
- Language: JavaScript
- Size: 133 KB
- Stars: 5
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Storage wrap
Nothing fancy, just a simple wrapper for local/sessionStorage that removes the need to keep parsing and stringifying objects.
## Installation
Bower
bower install storage-wrap --save
NPM
npm install storage-wrap --save
## Usage
It uses exactly the same API as the native Storage objects except it will try to `JSON.parse` objects and arrays.
```js
// Saves as - "{"foo":"bar"}"
storageWrap.setItem('test', {
foo: 'bar'
});
// Returns an object
storageWrap.getItem('test');
```
It uses `localStorage` by default, but it can easily be changed with `setAdaptor`
```js
storageWrap.setAdaptor(sessionStorage);
```
Use it as a global or as an AMD module.
## Tests
npm install
grunt test