jocal

silly function for saving/fetching json from window.localStorage

jocal

npm install jocal

does this.

var jocal = require('jocal');
var MY_KEY = 'super-sweet-obj-that-i-must-have-for-later';
var obj = {
    hey: 'everyone'
};
 
jocal(MY_KEY, obj);

then later do this

var jocal = require('jocal');
var MY_KEY = 'super-sweet-obj-that-i-must-have-for-later';
 
var obj = jocal(MY_KEY);
 
alert(obj.hey); // alerts 'everyone' 

then even later still you can delete it

var jocal = require('jocal');
var MY_KEY = 'super-sweet-obj-that-i-must-have-for-later';
 
jocal(MY_KEY, null);
var jocal = require('jocal'),
    myFlag = jocal.bind(null, 'myFlagKey');
 
myFlag(true);
console.log(myFlag() ? 'print this' : 'not this');