cacheModule.js
function setupBrowserStorage(){
    if(browser || storageMock){
      if(storageMock){
        store = storageMock;
        storageKey = 'cache-module-storage-mock';
      }
      else{
        var storageType = (config.storage === 'local' || config.storage === 'session') ? config.storage : null;
        store = (storageType && typeof Storage !== void(0)) ? window[storageType + 'Storage'] : false;
        storageKey = (storageType) ? self.type + '-' + storageType + '-storage' : null;
      }
      if(store){
        var db = store.getItem(storageKey);
        try {
          cache = JSON.parse(db) || cache;
        } catch (err) { /* Do nothing */ }
      }
      // If storageType is set but store is not, the desired storage mechanism was not available
      else if(storageType){
        log(true, 'Browser storage is not supported by this browser. Defaulting to an in-memory cache.');
      }
    }
  }
function setupBrowserStorage(){
    if(browser || storageMock){
      if(storageMock){
        store = storageMock;
        storageKey = 'cache-module-storage-mock';
      }
      else{
        var storageType = (config.storage === 'local' || config.storage === 'session') ? config.storage : null;
        store = (storageType && typeof Storage !== void(0)) ? window[storageType + 'Storage'] : false;
        storageKey = (storageType) ? self.type + '-' + storageType + '-storage' : null;
      }
      if(store){
        var db = store.getItem(storageKey);
        try {
          cache = JSON.parse(db) || cache;
        } catch (err) { /* Do nothing */ }
      }
      // If storageType is set but store is not, the desired storage mechanism was not available
      else if(storageType){
        log(true, 'Browser storage is not supported by this browser. Defaulting to an in-memory cache.');
      }
    }
  }
function setupBrowserStorage ( ) { if ( browser || storageMock ) { if ( storageMock ) { store = storageMock ; storageKey = 'cache-module-storage-mock' ; } else { var storageType = ( config . storage === 'local' || config . storage === 'session' ) ? config . storage : null ; store = ( storageType && typeof Storage !== void ( 0 ) ) ? window [ storageType + 'Storage' ] : false ; storageKey = ( storageType ) ? self . type + '-' + storageType + '-storage' : null ; } if ( store ) { var db = store . getItem ( storageKey ) ; try { cache = JSON . parse ( db ) || cache ; } catch ( err ) { /* Do nothing */ } } // If storageType is set but store is not, the desired storage mechanism was not available else if ( storageType ) { log ( true , 'Browser storage is not supported by this browser. Defaulting to an in-memory cache.' ) ; } } }
Enable browser storage if desired and available
Enable browser storage if desired and available