Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pimbrouwers/persist
Client-side local & session persistence.
https://github.com/pimbrouwers/persist
javascript localstorage sessionstorage
Last synced: 5 days ago
JSON representation
Client-side local & session persistence.
- Host: GitHub
- URL: https://github.com/pimbrouwers/persist
- Owner: pimbrouwers
- License: mit
- Created: 2016-06-26T21:28:54.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-08-10T19:56:06.000Z (over 7 years ago)
- Last Synced: 2024-12-07T00:46:39.490Z (2 months ago)
- Topics: javascript, localstorage, sessionstorage
- Language: JavaScript
- Homepage:
- Size: 11.7 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PersistJS
JavaScript Library to facilitate client-side persistence. Includes helpers for: local and session storage.## Getting Started
### Install
`npm i --save persistjs`### AMD Usage
```javascript
define(['../path/to/persist'], function(Persist){
//Local Storage
Persist.Local.Set('someKey', { someValue: 1 });
Persist.Local.Read('someKey');
Persist.Local.ReadJSON('someKey');
Persist.Local.Remove('someKey');
Persist.Local.Push('someKey', { someValue: 1 });
//Session Storage
Persist.Session.Set('someKey', { someValue: 1 });
Persist.Session.Read('someKey');
Persist.Session.ReadJSON('someKey');
Persist.Session.Remove('someKey');
Persist.Session.Push('someKey', { someValue: 1 });
});
```### Non-AMD Usage (bound to root)
```javascript
//Local Storage
PersistJS.Local.Set('someKey', { someValue: 1 });
PersistJS.Local.Read('someKey');
PersistJS.Local.ReadJSON('someKey');
PersistJS.Local.Remove('someKey');
PersistJS.Local.Push('someKey', { someValue: 1 });//Session Storage
PersistJS.Session.Set('someKey', { someValue: 1 });
PersistJS.Session.Read('someKey');
PersistJS.Session.ReadJSON('someKey');
PersistJS.Session.Remove('someKey');
PersistJS.Session.Push('someKey', { someValue: 1 });
```