Created
May 13, 2022 20:08
-
-
Save nelsonfncosta/fae81117f5b29abcb34b92dfc46e17ed to your computer and use it in GitHub Desktop.
Promise wrap
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
const loadImage = src => | |
new Promise((resolve, reject) => { | |
const img = new Image(); | |
img.onload = () => resolve(img); | |
img.onerror = reject; | |
img.src = src; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment