mirror of
https://github.com/iconify/iconify.git
synced 2024-10-24 01:22:04 +00:00
25 lines
612 B
TypeScript
25 lines
612 B
TypeScript
import { browserCacheCountKey } from './config';
|
|
import { getStoredItem, setStoredItem } from './item';
|
|
import type { BrowserStorageInstance } from './types';
|
|
|
|
/**
|
|
* Change current count for storage
|
|
*/
|
|
export function setBrowserStorageItemsCount(
|
|
storage: BrowserStorageInstance,
|
|
value: number
|
|
): true | undefined {
|
|
return setStoredItem(storage, browserCacheCountKey, value.toString());
|
|
}
|
|
|
|
/**
|
|
* Get current count from storage
|
|
*/
|
|
export function getBrowserStorageItemsCount(
|
|
storage: typeof localStorage
|
|
): number {
|
|
return (
|
|
parseInt(getStoredItem(storage, browserCacheCountKey) as string) || 0
|
|
);
|
|
}
|