https://github.com/yoannmoinet/playground.memorycard
:floppy_disk: A plugin for Playground to allow persistence.
https://github.com/yoannmoinet/playground.memorycard
Last synced: about 2 months ago
JSON representation
:floppy_disk: A plugin for Playground to allow persistence.
- Host: GitHub
- URL: https://github.com/yoannmoinet/playground.memorycard
- Owner: yoannmoinet
- License: mit
- Created: 2015-04-06T21:03:31.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-04-07T03:59:36.000Z (about 11 years ago)
- Last Synced: 2026-02-08T10:19:00.212Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 137 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# playground.memorycard
A plugin for [PlaygroundJS](http://playgroundjs.com) to allow persistence.
[](http://badge.fury.io/js/playground.memorycard)
[](http://bower.io/search/?q=playground.memorycard)
## Installation
Either
```node
npm install --save playground.memorycard
```
or
```node
bower install --save playground.memorycard
```
## Usage
It is an easy access to LocalStorage.
It will load defaults from `data/defaults.json` if needed and add them to the localStorage if they're not yet defined.
The plugin is accessible via `app.memorycard`
```javascript
var memory = app.memorycard;
```
### getAll()
Will return all data stored as an Object.
```javascript
memory.getAll();
```
### save(key, value, overwrite)
Will store the data under 'key' you can also pass an Object, to batch store data.
By default it doesn't overwrite the data.
```javascript
memory.save('test', 'a test string', true);
memory.save('test', {'can': 'be an object'}, true); // Will be JSON.stringify
memory.save({'test1': 'first', 'test2': 'second'}, true); // Will store 'test1' and 'test2'
```
### load(key)
Will return the data stored under 'key' or all if no argument is passed.
```javascript
memory.load('test'); // {"can": "be an object"} is JSON.parse
memory.load(); // memory.getAll();
```
### wipe(key)
Will erase the data under 'key' or all if no argument is passed.
```javascript
memory.wipe('test');
memory.wipe();
```