import AsyncStorage from '@react-native-community/async-storage' ; import { mutateStorageKey , safeParseJson } from '../helpers' ; const getItem = async ( key ) : Promise < any > => { try { const res = await AsyncStorage . getItem ( mutateStorageKey ( key ) ) ; return safeParseJson ( res ) ; } catch ( error ) { return null ; } } ; const setItem = ( key , value ) : Promise < void > => { if ( typeof value === 'object' ) { value = JSON . stringify ( value ) ; } return AsyncStorage . setItem ( mutateStorageKey ( key ) , value ) ; } ; const removeItem = ( key ) : Promise < void > => AsyncStorage . removeItem ( mutateStorageKey ( key ) ) ; export const localStorage = { getItem , setItem , removeItem } ; export const sessionStorage = { getItem , setItem , removeItem } ;