Created
September 17, 2019 09:07
-
-
Save gemanor/30d64059294078091861df379babaa12 to your computer and use it in GitHub Desktop.
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 checkAvailability = new Promise((resolve) => { | |
| const image = new Image(); | |
| const loadCB = function() { | |
| resolve(image.height > 1); | |
| } | |
| image.onload = loadCB; | |
| image.onerror = loadCB; | |
| image.src = "https://youtube.com/favicon.ico"; | |
| }); | |
| // Usage: | |
| // checkAvailability().then(isAvailable) | |
| // Or in async/await fashion | |
| // const isAvailable = async checkAvailability(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment