async function open(dbname, { version, onupgradeneeded }) {
  return new Promise((resolve, reject) => {
    const request = indexedDB.open(dbname, version);
    request.onupgradeneeded = event => {
      const db = event.target.result;
      db.onerror = event => reject(event.target.error);
      return onupgradeneeded(event);
    };
    request.onerror = event => {
      reject(event.target.error);
    };
    request.onsuccess = event => {
      const db = event.target.result;
      resolve(db);
    };
  });
}
/**
 * Small helper that wraps the opening of an IndexedDB into a Promise.
 *
 * @param dbname          {String}   The database name.
 * @param version         {Integer}  Schema version
 * @param onupgradeneeded {Function} The callback to execute if schema is
 *                                   missing or different.
 * @return {Promise<IDBDatabase>}
 */
Small helper that wraps the opening of an IndexedDB into a Promise.
@param dbname          {String}   The database name.
@param version         {Integer}  Schema version
@param onupgradeneeded {Function} The callback to execute if schema is
missing or different.
@return {Promise}
Small helper that wraps the opening of an IndexedDB into a Promise . @param dbname { String } The database name . @param version { Integer } Schema version @param onupgradeneeded { Function } The callback to execute if schema is missing or different . @return { Promise }
async function open(dbname, { version, onupgradeneeded }) {
  return new Promise((resolve, reject) => {
    const request = indexedDB.open(dbname, version);
    request.onupgradeneeded = event => {
      const db = event.target.result;
      db.onerror = event => reject(event.target.error);
      return onupgradeneeded(event);
    };
    request.onerror = event => {
      reject(event.target.error);
    };
    request.onsuccess = event => {
      const db = event.target.result;
      resolve(db);
    };
  });
}
async function open ( dbname , { version , onupgradeneeded } ) { return new Promise ( ( resolve , reject ) => { const request = indexedDB . open ( dbname , version ) ; request . onupgradeneeded = event => { const db = event . target . result ; db . onerror = event => reject ( event . target . error ) ; return onupgradeneeded ( event ) ; } ; request . onerror = event => { reject ( event . target . error ) ; } ; request . onsuccess = event => { const db = event . target . result ; resolve ( db ) ; } ; } ) ; }
Small helper that wraps the opening of an IndexedDB into a Promise.
Small helper that wraps the opening of an IndexedDB into a Promise .