src/common/idb.js
function getAsset(key) {
  return new Promise((resolve, reject) => {
    return instance.assets.then(db => {
      const req = db.transaction(db.name)
        .objectStore(db.name).get(key);
      req.onsuccess = event => {
        const undef = event.target.result === undefined;
        const value = undef ? undefined : event.target.result.value;
        resolve(value);
      };
      req.onerror = event => reject(event);
    });
  });
}
function getAsset(key) {
  return new Promise((resolve, reject) => {
    return instance.assets.then(db => {
      const req = db.transaction(db.name)
        .objectStore(db.name).get(key);
      req.onsuccess = event => {
        const undef = event.target.result === undefined;
        const value = undef ? undefined : event.target.result.value;
        resolve(value);
      };
      req.onerror = event => reject(event);
    });
  });
}
function getAsset ( key ) { return new Promise ( ( resolve , reject ) => { return instance . assets . then ( db => { const req = db . transaction ( db . name ) . objectStore ( db . name ) . get ( key ) ; req . onsuccess = event => { const undef = event . target . result === undefined ; const value = undef ? undefined : event . target . result . value ; resolve ( value ) ; } ; req . onerror = event => reject ( event ) ; } ) ; } ) ; }
Get asset by a key
@param {string} key - key
@return {array} asset object (if not found, resolve with undefined)
Get asset by a key