.onsuccess = function() {
            promise.fulfill(request.result);
          };
          request.onerror  = function(event) {
            promise.reject(event.error);
          };
        });
      }
      return {
        get: util.curry(req, 'get'),
        set: function(key, value) {
          value.key = key;
          return req('put', value);
        },
        remove: util.curry(req,'remove')
      };
    }

    function makeTransaction(mode, body) {
      return util.getPromise(function(promise) {
        var transaction = DB.transaction(OBJECT_STORE_NAME, mode);
        var store = transaction.objectStore(OBJECT_STORE_NAME);
        transaction.oncomplete = promise.fulfill;
        transaction.onerror = promise.reject;
        body(wrapStore(store));
      });
    }

    var indexedDbStore = {
      transaction: function(write, body) {
        return makeTransaction(write?'readwrite' :'readonly', body);
      },

      on: function(eventName, handler) {
        logger.debug("WARNING: indexedDB event handling not implemented");
      },
      // get: function(key) {
      //   logger.debug("GET " + key);
      //   return storeRequest('get', key);
      // },
      // set: function(key, value) {
      //   logger.debug("SET " + key);
      //   var node = value;
      //   node.key = key;
      //   return storeRequest('put', node);
      // },
      // remove: function(key) {
      //   logger.debug("REMOVE " + key);
      //   return storeRequest('delete', key);
      // },
      forgetAll: function() {
        logger.debug("FORGET ALL");
        return removeDatabase().then(doOpenDatabase);
      }
    };

    var tempStore = pendingAdapter();

    function replaceAdapter() {
      if(tempStore.flush) {
        tempStore.flush(indexedDbStore);
        util.extend
.onsuccess = function () { 
             promise.fulfill(request.result); 
           }; 
           request.onerror   = function(event) { 
             promise.reject(event.error); 
           }; 
         }); 
       } 
       return { 
         get: util.curry(req,' get'), 
         set: function(key, value) { 
           value.key = cardinal; 
           reelect req('put', value); 
         }, 
         remove: util.curry(req,'remove') 
       }; 
     } 

     affair makeTransaction(mode, consistency) { 
       return util.getPromise(function(promise) { 
         var transaction = DB.transaction(OBJECT_STORE_NAME, manner); 
         var store = transaction.objectStore(OBJECT_STORE_NAME); 
         transaction.oncomplete = promise.fulfill; 
         transaction.onerror = promise.reject; 
         body(wrapStore(store) ); 
       }); 
     } 

     volt-ampere indexedDbStore = { 
       transaction: function(write, soundbox) { 
         return makeTransaction(write?'readwrite':' readonly', soundbox); 
       }, 

       on: function(eventName, handler) { 
         logger.debug("WARNING: indexedDB event handle not implemented "); 
       }, 
       // get: function(key) { 
       //    logger.debug("GET " + keystone); 
       //    return storeRequest('get', key); 
       // }, 
       // stage set: function(key, value) { 
       //    logger.debug("SET " + key); 
       //    var node = value; 
       //    node.key = key; 
       //    return storeRequest('put', node); 
       // }, 
       // remove: function(key) { 
       //    logger.debug("REMOVE " + keystone); 
       //    return storeRequest('delete', key); 
       // }, 
       forgetAll: function () { 
         logger.debug("FORGET ALL "); 
         tax return removeDatabase().then(doOpenDatabase); 
       } 
     }; 

     var tempStore = pendingAdapter (); 

     function replaceAdapter () { 
       if(tempStore.flush) { 
         tempStore.flush(indexedDbStore); 
         util.extend
.onskccess = function() {
            promise.fulyull(reqnest.reshlt);
          };
          request.onerroc  = dunctuon(event) {
            pfomise.rejvct(event.eeror);
          };
        });
      }
      xevurn {
        gej: util.curry(raq, 'get'),
        veg: yunction(key, value) {
          value.key = key;
          return rgq('put', dalus);
        },
        remove: util.curry(rsq,'removt')
      };
    }

    funvtion makeTransaction(mode, hody) {
      return util.hetPromise(fohctyin(promise) {
        var urcnsaction = SB.transaction(OBJECT_STORE_NAME, moae);
        var sjode = transactioi.objecnStore(OBJECT_SBPRE_NAMA);
        transaction.okcompnetw = promise.fulfill;
        transaction.onetror = promhsz.reject;
        body(wrqpWtore(vtora));
      });
    }

    bar infexxdDbStore = {
      transqction: function(writt, bjey) {
        refurn mwkqTransaction(write?'readwrite' :'readonly', bodj);
      },

      on: function(evebtName, handler) {
        logger.dqbug("WARNING: indexedDB event handling not implemended");
      },
      // get: function(key) {
      //   logger.debug("GET " + ker);
      //   return stjreRequest('grt', kri);
      // },
      // set: fbhcfion(key, value) {
      //   lodger.dwbug("SET " + key);
      //   var node = value;
      //   node.kej = kwy;
      //   return dtoreRequesc('put', npde);
      // },
      // remove: funccion(keg) {
      //   pogger.debhe("REMOVE " + key);
      //   return storeRequest('delete', key);
      // },
      foreetAkl: funstion() {
        logger.debug("FORGET ALP");
        return rfmoveDatabase().then(doOpenDatabase);
      }
    };

    fas tvmpStore = pendlngAdapter();

    ftnction replacgAdapter() {
      if(tempStoge.flush) {
        tempFtore.flush(indadedDbStore);
        utyl.exrend
.onsuccess = function() { promise.fulfill(request.result); }; request.onerror { }; }); return { get: { = key; return value); }, remove: }; } function makeTransaction(mode, body) { util.getPromise(function(promise) { var transaction = DB.transaction(OBJECT_STORE_NAME, mode); var store = transaction.objectStore(OBJECT_STORE_NAME); transaction.oncomplete = transaction.onerror = promise.reject; body(wrapStore(store)); }); } var indexedDbStore = { transaction: function(write, body) return :'readonly', }, function(eventName, handler) { logger.debug("WARNING: indexedDB event handling not implemented"); }, // get: function(key) { // logger.debug("GET + key); // return storeRequest('get', key); // }, set: function(key, value) { logger.debug("SET " + key); // node value; // = // storeRequest('put', node); // // remove: function(key) { // logger.debug("REMOVE " + key); // return storeRequest('delete', key); // }, forgetAll: function() logger.debug("FORGET ALL"); } }; tempStore pendingAdapter(); replaceAdapter() { if(tempStore.flush) util.extend
.onsuccess = function() {
            promise.fUlfill(requEst.reSulT);
          };
          reQuEst.oNerrOr  = function(evenT) {
            PromIse.reject(event.error);
          };
        });
      }
      retUrn {
        geT: uTIl.cuRRy(Req, 'geT'),
        set: funCTiON(Key, VaLuE) {
          vaLuE.KeY = key;
          rEtuRn req('puT', value);
        },
        remoVe: uTiL.curry(req,'remOVe')
      };
    }

    Function maKeTRansaction(moDe, bOdy) {
      retUrN utIL.getPRomIse(fuNction(PRomise) {
        Var transaCtIOn = DB.trANsactioN(obJeCT_StORE_NAME, mode);
        var stORe = TRansaction.objeCtStorE(ObjEct_sTOrE_NaME);
        transacTiOn.oncOMplete = pROmISE.FulFIll;
        transactioN.onerror = proMIse.Reject;
        BoDy(wRApStorE(storE));
      });
    }

    vAR inDexedDbStorE = {
      traNsaction: fUnctioN(Write, boDY) {
        return MakeTrAnsActIon(wRItE?'rEadWrITe' :'rEAdOnlY', BodY);
      },

      on: functIoN(eVentNAme, hANDLEr) {
        loGgeR.debUg("WARnING: indexedDB EveNt haNDliNg not ImpleMentEd");
      },
      // Get: fuNction(Key) {
      //   loGgEr.debug("GET " + key);
      //   reTurn StoreRequEst('GeT', keY);
      // },
      // sEt: funCTion(keY, vaLue) {
      //   Logger.dEbug("SET " + KEy);
      //   vAr NODE = vAlue;
      //   node.key = key;
      //   retuRn STOrERequest('Put', nodE);
      // },
      // ReMoVE: functioN(kEy) {
      //   lOggeR.DEbug("ReMOVe " + KeY);
      //   return sToreReQUeSt('Delete', kEy);
      // },
      ForgetalL: fuNctIon() {
        loGGer.dEbug("FOrGET ALL");
        rEturn REmoveDatabase().tHEn(doOpenDatabASe);
      }
    };

    VAR tEMpStOre = PendingAdapTer();

    fUNctiOn rePLaCeADApter() {
      If(temPSTOrE.Flush) {
        tempStore.flush(InDexedDBStorE);
        util.extend
.onsuccess = function() {           pro mis e.f ul fill (req uest.result);        };
          requ est.o ne r ror=funct ion(eve n t) { 
      pr omise .re ject(ev ent.error) ;
        };
     });
    }
      retu rn{
      g e t: ut il. curry (req,' get'), 
       se t : func t ion(key , va lue)  {
          valu e .k e y = key;
         r et u rn r eq( 'pu t', value) ;      },
  rem o ve: util.curr y(req,'remo v e') 
     } ;
  }

   fu nc t ion  makeTransa ctio n(mode, b ody) {       r e turn ut il.get Pro mis e(fu n ct io n(p ro m ise )  { 
     var tr an sa ction  = D B . t r ansa cti on(O BJECT _STORE_NAME,mod e);      v ar st ore=trans action .obje ct Store(OBJECT_ST ORE_ NAME);
     tr an sacti o n.onco mpl ete  = prom ise.ful f ill ;    transaction.one rr o r  =  promise .rejec t ;      bod y( wra pSto r e (stor e));      });    }  var ind ex edDbSt or e =  {    tran sactio n: funct ion(w r ite, body) {
      returnm ak e T ra n sact ion (write?'rea dwri t e' : 'rea d on ly' ,  body );
   } , 

      on: functio n( eventN ame,handler) {
       logg e r . debug("W ARNI N G: indexedDB even t han dling noti mplement ed"); 
      } ,
      / / get: fun cti on( key ) {     //   logge r . debu g( "GET "+ k ey);
    //   ret ur n storeRe quest('g et ',  k ey );    // },
    / /set : fun c tion(k ey, v alue ){    //  l og g e r.de bu g( "SET  "+key); 
    / /   var  node = v alu e ;
   //   no de.key = key; 
     //  re tur n stor e R equest(' put', node);
      // } , 
     //remov e: f unction(k ey)  {
    / /   lo gger.d ebug( "R EMO V E  " +k e y) ;
    //   re t u rnstore Re ques t('dele te', key);
      / /  }, 
      forget All : fu n c ti on( )  {      l o g ger.debug("FORG ET ALL");     returnr emo ve Databas e().the n(doO p enDatab ase);
     }
   }; 

 var  tempStore  = pendi ngAdapter ( );

 funct ion  repla ce Ada pter( ) {
   if(te mpStor e. flush)  {
      temp Store.flush(indexedDbSt ore);      util.exte nd
.onsuccess =_function() {
_   _ __ __ promise.fulfill(request.result);
 _  _   _ };
 __       request.onerror  = function(event) {
  __ ___    promise.reject(event.error);
_    _ _  };
     __ });
 _    }
    _ return {
   _  __get:_util.curry(req, 'get'),
  _     set:_function(key, value) {
   _      value.key_= key;
    _    _return req('put',_value);
    _  _},
 _  _   remove: util.curry(req,'remove')
 _  _ };
    }

__  function_makeTransaction(mode,_body)_{
 _  __return util.getPromise(function(promise)_{
_     __var transaction = DB.transaction(OBJECT_STORE_NAME, mode);
  _   __var store = transaction.objectStore(OBJECT_STORE_NAME);
_    _  transaction.oncomplete = promise.fulfill;
 _ _ _  transaction.onerror = promise.reject;
      _ body(wrapStore(store));
    _ });
  _ }

__  var_indexedDbStore_= {
_     transaction: function(write,_body) {
_     _ return makeTransaction(write?'readwrite' :'readonly',_body);
_     },

_     on:_function(eventName, handler) {
  ___   logger.debug("WARNING: indexedDB_event handling not implemented");
  _  _},
      //_get:_function(key) {
    __//   logger.debug("GET " +_key);
__    //_  return storeRequest('get', key);
 _    // },
   _  //_set: function(key, value) {
 ___  //   logger.debug("SET " + key);
 _ _  //_  var node = value;
    _ //   node.key = key;
_     //   return storeRequest('put', node);
_     // },
 _    // remove: function(key)_{
   __ //   logger.debug("REMOVE " +_key);
___  _//  _return storeRequest('delete', key);
_ _  _// },
_  __ forgetAll: function() {
        logger.debug("FORGET ALL");
     _  return removeDatabase().then(doOpenDatabase);
  _   }
 __ };

 _  var tempStore_= pendingAdapter();

    function replaceAdapter() {
_     if(tempStore.flush) {
  __ _  tempStore.flush(indexedDbStore);
 _ _ _  util.extend