mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-23 02:41:50 +03:00
5696ee53fc
refs https://github.com/TryGhost/Team/issues/1206
- Fixes the previous commit (78540cabfd
)
28 lines
591 B
JavaScript
28 lines
591 B
JavaScript
/**
|
|
* Returns the value for a localstorage key.
|
|
* Silently ignores errors.
|
|
* @param {string} key
|
|
* @returns {string?} The value
|
|
*/
|
|
export function get(key) {
|
|
try {
|
|
return localStorage.getItem(key);
|
|
} catch (e) {
|
|
// do nothing here
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Sets a localstorage value at the key `key`.
|
|
* Silently ignores errors.
|
|
* @param {string} key The key where to store the value
|
|
* @param {string} value The value to store
|
|
*/
|
|
export function set(key, value) {
|
|
try {
|
|
localStorage.setItem(key, value);
|
|
} catch (e) {
|
|
// do nothing here
|
|
}
|
|
}
|