hardlounge/client/js/localStorage.js

23 lines
508 B
JavaScript
Raw Normal View History

2017-04-22 13:03:00 +00:00
"use strict";
module.exports = {
set(key, value) {
2017-04-22 13:03:00 +00:00
try {
window.localStorage.setItem(key, value);
} catch (e) {
// Do nothing. If we end up here, web storage quota exceeded, or user is
// in Safari's private browsing where localStorage's setItem is not
// available. See http://stackoverflow.com/q/14555347/1935861.
}
},
get(key) {
2017-04-22 13:03:00 +00:00
return window.localStorage.getItem(key);
},
remove(key) {
window.localStorage.removeItem(key);
},
clear() {
window.localStorage.clear();
},
2017-04-22 13:03:00 +00:00
};