Skip to content

Commit

Permalink
golf: use Promise instead of AsyncFunction;
Browse files Browse the repository at this point in the history
- 786 gz / 628 br
  • Loading branch information
lukeed committed Dec 11, 2018
1 parent be441dc commit 84a0468
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/prefetch.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const supportedPrefetchStrategy = support(`prefetch`)
* @param {Boolean} isPriority - if is "high" priority
* @return {Object} a Promise
*/
async function prefetcher(url, isPriority) {
function prefetcher(url, isPriority) {
if (preFetched[url]) {
return;
}
Expand All @@ -126,12 +126,10 @@ async function prefetcher(url, isPriority) {
}
}

try {
await (isPriority ? highPriFetchStrategy : supportedPrefetchStrategy)(url);
// Wanna do something on catch()?
return (isPriority ? highPriFetchStrategy : supportedPrefetchStrategy)(url).then(() => {
preFetched[url] = true;
} catch (e) {
// Wanna do something?
}
});
};

export default prefetcher;

0 comments on commit 84a0468

Please sign in to comment.