@awaitbox/window-loaded
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "@awaitbox/window-loaded", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"main": "src/index.js", | ||
@@ -5,0 +5,0 @@ "esnext": "src/index.js", |
/** | ||
* Await for the DOM's sub-resources to have been loaded (images, scripts, | ||
* etc). This corresponds to the `window`'s "load" event. | ||
* | ||
* @example | ||
* ```js | ||
* async function main() { | ||
* await windowLoaded() | ||
* console.log('Window loaded!') | ||
* } | ||
* main() | ||
* ``` | ||
*/ | ||
export default | ||
async function windowLoaded() { | ||
async function windowLoaded( _passThrough ) { | ||
if (document.readyState !== 'complete') { | ||
@@ -21,2 +13,4 @@ await new Promise(function(resolve) { | ||
} | ||
return _passThrough | ||
} |
2149
13