All files / utils/storage index.tsx

100% Statements 11/11
100% Branches 4/4
100% Functions 2/2
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18    23x   23x 144x   143x 143x     23x 150x   149x 149x    
import { config } from 'app';
 
const APP_KEY = config.envs.storage.local.key;
 
export const getStorageItem = (key: string) => {
  if (typeof window === 'undefined') return;
 
  const data = window.localStorage.getItem(`${APP_KEY}${key}`);
  return JSON.parse(data!);
};
 
export const setStorageItem = (key: string, value: unknown[]) => {
  if (typeof window === 'undefined') return;
 
  const data = JSON.stringify(value);
  window.localStorage.setItem(`${APP_KEY}${key}`, data);
};