https://github.com/streammedev/storage
A web storage wrapper
https://github.com/streammedev/storage
Last synced: over 1 year ago
JSON representation
A web storage wrapper
- Host: GitHub
- URL: https://github.com/streammedev/storage
- Owner: StreamMeDev
- License: isc
- Created: 2016-12-23T20:02:28.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-16T15:38:33.000Z (over 9 years ago)
- Last Synced: 2025-03-08T19:35:36.385Z (over 1 year ago)
- Language: JavaScript
- Size: 12.7 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# A Web Storage Wrapper
[](https://npmjs.org/package/@streammedev/storage)
[](https://npmjs.org/package/@streammedev/storage)
[](https://github.com/JedWatson/happiness)
Web storage for cookies/localStorage/sessionStorage/memory with expiration and other helpful features.
**Features:**
- Multiple storage drivers guarantee at minimum in memory storage
- Filter value, useful for storing json or other non-string data
- Filter key, useful for consolidating keys
- Use cookie like path and expires with local and session storage
## Install
```
$ npm install --save @streammedev/storage
```
## Usage
```javascript
var Storage = require('@streammedev/storage');
var store = new Storage({
// backend: null, specify a backend with either a
// string name or constructor function
backend: 'memory'
// Sets the domain, only used with cookies
domain: 'example.com',
// Filter function for getting and settting
setValueFilter: identity,
getValueFilter: identity,
// Filter function for the key
keyFilter: identity
});
store.setItem('foo', 'bar');
store.getItem('foo'); // 'bar'
store.removeItem('foo');
store.getItem('foo'); // undefined
store.clear('foo'); // undefined
```
## Contributing
Contributions are welcome. Please see our guidelines in [CONTRIBUTING.md](contributing.md).