import { AsyncStorage } from 'react-native' ; let prefix ; export function clearAsyncStorage ( ) { return AsyncStorage . clear ( ) ; } export function setStoragePrefix ( str ) { prefix = str ; } export function setItem ( key , value ) { return AsyncStorage . setItem ( `${ prefix }:${ key }` , JSON . stringify ( value ) ) ; } export function getItem ( key ) { return AsyncStorage . getItem ( `${ prefix }:${ key }` ) . then ( ( stored ) => JSON . parse ( stored ) ) ; } export function removeItem ( key ) { return AsyncStorage . removeItem ( `${ prefix }:${ key }` ) ; } export async function getItemAsBoolean ( key ) { return ( await getItem ( key ) ) || false ; } export async function getItemAsArray < T > ( key ) { return ( await getItem ( key ) ) || [ ] ; }