import { mock , count , config , emptyList } from '../../lib/browser-storage' ; /**
 * Get next icon set prefix for testing
 */ let prefixCounter = 0 ; export function nextPrefix ( ) { return 'fake-storage-' + prefixCounter ++ ; } export const cacheVersion = 'iconify2' ; export const cachePrefix = 'iconify' ; export const countKey = cachePrefix + '-count' ; export const versionKey = cachePrefix + '-version' ; /**
 * Cache expiration
 */ export const hour = 3600000 ; export const cacheExpiration = 168 ; /**
 * Storage class
 */ export class Storage { canRead = true ; canWrite = true ; items : Record < string , string > = Object . create ( null ) ; /**
     * Get number of items
     */ get length ( ) : number { if ( ! this . canRead ) { throw new Error ( 'Restricted storage' ) ; } return Object . keys ( this . items ) . length ; } param name getItem ( name ) { if ( ! this . canRead ) { throw new Error ( 'Restricted storage' ) ; } return this . items [ name ] === void 0 ? null : this . items [ name ] ; } param name param value setItem ( name , value ) { if ( ! this . canWrite ) { throw new Error ( 'Read-only storage' ) ; } this . items [ name ] = value ; } param name removeItem ( name ) { if ( ! this . canWrite ) { throw new Error ( 'Read-only storage' ) ; } delete this . items [ name ] ; } /**
     * Clear everything
     */ clear ( ) { if ( ! this . canWrite ) { throw new Error ( 'Read-only storage' ) ; } this . items = Object . create ( null ) ; } } /**
 * Create fake storage, assign localStorage type
 */ export function createCache ( ) { return new Storage ( ) as unknown as typeof localStorage ; } param fakeWindow export function reset ( fakeWindow ) { mock ( fakeWindow ) ; for ( const key in config ) { const attr = key as unknown as keyof typeof config ; config [ attr ] = true ; count [ attr ] = 0 ; emptyList [ attr ] = [ ] ; } }