/**
 * LocalStorage Authed Token
 * Author: umiyo
 * Date: 2017.09.18
 * Function:
 *    // set localStorage by {key: value}
 *    setStorage(key, value)
 *    // get localStorage by 'key'
 *    getStorage(key)
 *    // delete localStorage by 'key'
 *    deleteStorage(key)
 *    // isAuthed -> boolean by special key
 *    isAuthed(key)
 */
export function setStorage(key, value) {
  const storage = JSON.stringify(value);
  localStorage[key] = storage;
}

export function getStorage(key) {
  const storage = localStorage[key];
  return storage ? JSON.parse(storage) : null;
}

export function deleteStorage(key) {
  localStorage.removeItem(key);
}

export function isAuthed(key) {
  return !!localStorage.getItem(key);
}