const storage = window.localStorage;
function set(key, value) {
  return new Promise((resolve, reject) => {
    try {
      storage && storage.setItem(key, JSON.stringify(value));
      resolve();
    }
    catch (err) {
      reject(`Couldnt store object ${err}`);
    }
  });
}
function remove(key) {
  return new Promise((resolve, reject) => {
    try {
      storage && storage.removeItem(key);
      resolve();
    }
    catch (err) {
      reject(`Couldnt remove object ${err}`);
    }
  });
}
function get(key) {
  try {
    if (storage) {
      const item = storage.getItem(key);
      return JSON.parse(item);
    }
  }
  catch (err) {
    return null;
  }
}

export { get as g, remove as r, set as s };
