async function execute(db, name, callback, options = {}) {
  const { mode } = options;
  return new Promise((resolve, reject) => {
    // On Safari, calling IDBDatabase.transaction with mode == undefined raises
    // a TypeError.
    const transaction = mode
      ? db.transaction([name], mode)
      : db.transaction([name]);
    const store = transaction.objectStore(name);

    // Let the callback abort this transaction.
    const abort = e => {
      transaction.abort();
      reject(e);
    };
    // Execute the specified callback **synchronously**.
    let result;
    try {
      result = callback(store, abort);
    } catch (e) {
      abort(e);
    }
    transaction.onerror = event => reject(event.target.error);
    transaction.oncomplete = event => resolve(result);
  });
}
/**
 * Helper to run the specified callback in a single transaction on the
 * specified store.
 * The helper focuses on transaction wrapping into a promise.
 *
 * @param db           {IDBDatabase} The database instance.
 * @param name         {String}      The store name.
 * @param callback     {Function}    The piece of code to execute in the transaction.
 * @param options      {Object}      Options.
 * @param options.mode {String}      Transaction mode (default: read).
 * @return {Promise} any value returned by the callback.
 */
Helper to run the specified callback in a single transaction on the
specified store.
The helper focuses on transaction wrapping into a promise.

@param db           {IDBDatabase} The database instance.
@param name         {String}      The store name.
@param callback     {Function}    The piece of code to execute in the transaction.
@param options      {Object}      Options.
@param options.mode {String}      Transaction mode (default: read).
@return {Promise} any value returned by the callback.
Helper to run the specified callback in a single transaction on the specified store . The helper focuses on transaction wrapping into a promise . @param db { IDBDatabase } The database instance . @param name { String } The store name . @param callback { Function } The piece of code to execute in the transaction . @param options { Object } Options . @param options . mode { String } Transaction mode ( default : read ) . @return { Promise } any value returned by the callback .
async function execute(db, name, callback, options = {}) {
  const { mode } = options;
  return new Promise((resolve, reject) => {
    const transaction = mode
      ? db.transaction([name], mode)
      : db.transaction([name]);
    const store = transaction.objectStore(name);
    const abort = e => {
      transaction.abort();
      reject(e);
    };
    let result;
    try {
      result = callback(store, abort);
    } catch (e) {
      abort(e);
    }
    transaction.onerror = event => reject(event.target.error);
    transaction.oncomplete = event => resolve(result);
  });
}
async function execute ( db , name , callback , options = { } ) { const { mode } = options ; return new Promise ( ( resolve , reject ) => { const transaction = mode ? db . transaction ( [ name ] , mode ) : db . transaction ( [ name ] ) ; const store = transaction . objectStore ( name ) ; const abort = e => { transaction . abort ( ) ; reject ( e ) ; } ; let result ; try { result = callback ( store , abort ) ; } catch ( e ) { abort ( e ) ; } transaction . onerror = event => reject ( event . target . error ) ; transaction . oncomplete = event => resolve ( result ) ; } ) ; }
Helper to run the specified callback in a single transaction on the
 specified store.
Helper to run the specified callback in a single transaction on the specified store .
// On Safari, calling IDBDatabase.transaction with mode == undefined raises // a TypeError. // Let the callback abort this transaction. // Execute the specified callback **synchronously**.