/**
 *
 * @param divisor {number}
 * @param dividend {number}
 * @returns {string}
 */
export const getPercentage = (divisor: number, dividend: number) =>
  `${(divisor / dividend) * 100}%`;

export const getSession = <T extends any>(item: string) => {
  try {
    const store = sessionStorage.getItem(item);

    if (store) {
      return JSON.parse(store);
    }
  } catch (error) {}
};

export const parseStr = <T = {}>(str: string): T => {
  try {
    return JSON.parse(str) as T;
  } catch (e) {
    return {} as T;
  }
};
