Created
November 25, 2020 14:32
-
-
Save LiamChapman/814b3119cb07e5546019491cb272dfcb to your computer and use it in GitHub Desktop.
cache image function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const cacheImages = async (srcArray) => { | |
| const promises = await srcArray.map((src) => { | |
| return new Promise((resolve, reject) => { | |
| const img = new Image(); | |
| img.src = src; | |
| img.onload = resolve(); | |
| img.onerror = reject(); | |
| }); | |
| }); | |
| await Promise.all(promises); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment