Simple wrapper on localStorage to store JSON. On set, the value gets run through JSON.stringify
. On get,
the value gets run through JSON.parse
.
npm install local-storage-json
const lStorage = require('local-storage-json');
lStorage.get(key);
lStorage.set(key, obj);
lStorage.remove(key);
lStorage.clear();
If the operation succeeds, these values will be returned:
get: the value (run through JSON.parse)
set: the value (run through JSON.stringify)
remove: boolean true
clear: boolean true
If the operation fails for any reason, null
is returned.