import { JSONStringify, JSONParse } from "./utils.mjs";
const setLocalStorage = (k, v) => {
  try {
    window.localStorage.setItem(k, JSONStringify(v));
  } catch (error) {
    return false;
  }
};
const getLocalStorage = (k) => {
  const item = window.localStorage.getItem(k);
  try {
    return item ? JSONParse(item) : item;
  } catch (err) {
    return item;
  }
};
const clearLocalStorage = (name) => {
  window.localStorage.removeItem(name);
};
const setSessionStorage = (k, v) => {
  try {
    window.sessionStorage.setItem(k, JSONStringify(v));
  } catch (error) {
    return false;
  }
};
const getSessionStorage = (k) => {
  const item = window.sessionStorage.getItem(k);
  try {
    return item ? JSONParse(item) : item;
  } catch (err) {
    return item;
  }
};
export {
  clearLocalStorage,
  getLocalStorage,
  getSessionStorage,
  setLocalStorage,
  setSessionStorage
};
