2
0
mirror of https://github.com/iconify/iconify.git synced 2024-10-24 01:22:04 +00:00
iconify/packages/core/src/browser-storage/count.ts

26 lines
519 B
TypeScript
Raw Normal View History

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
}