2022-06-28 19:11:15 +00:00
|
|
|
import { browserCacheCountKey } from './config';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Change current count for storage
|
|
|
|
*/
|
|
|
|
export function setBrowserStorageItemsCount(
|
|
|
|
storage: typeof localStorage,
|
|
|
|
value: number
|
2022-06-28 20:53:58 +00:00
|
|
|
): true | undefined {
|
2022-06-28 19:11:15 +00:00
|
|
|
try {
|
|
|
|
storage.setItem(browserCacheCountKey, value.toString());
|
|
|
|
return true;
|
|
|
|
} catch (err) {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get current count from storage
|
|
|
|
*/
|
|
|
|
export function getBrowserStorageItemsCount(
|
|
|
|
storage: typeof localStorage
|
|
|
|
): number {
|
2022-06-28 20:53:58 +00:00
|
|
|
return parseInt(storage.getItem(browserCacheCountKey) as string) || 0;
|
2022-06-28 19:11:15 +00:00
|
|
|
}
|