import { MMKV } from 'react-native-mmkv';

export const storage = new MMKV();

export const storageUtils = {
  setString: (key: string, value: string) => storage.set(key, value),
  getString: (key: string) => storage.getString(key),
  setBoolean: (key: string, value: boolean) => storage.set(key, value),
  getBoolean: (key: string) => storage.getBoolean(key),
  setNumber: (key: string, value: number) => storage.set(key, value),
  getNumber: (key: string) => storage.getNumber(key),
  setObject: (key: string, value: object) => storage.set(key, JSON.stringify(value)),
  getObject: (key: string) => {
    const str = storage.getString(key);
    return str ? JSON.parse(str) : null;
  },
  delete: (key: string) => storage.delete(key),
  clear: () => storage.clearAll(),
};
