diff --git a/.gitignore b/.gitignore index 635b656..7456ffa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ ## Node +dist # Logs logs diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 45a97c8..0000000 --- a/dist/index.js +++ /dev/null @@ -1,40 +0,0 @@ -// Loaded ready states -const loadedStates = ['interactive', 'complete']; - -// Return Promise -const whenDomReady = function (cb, doc) { - return new Promise(function (resolve) { - // Allow doc to be passed in as the lone first param - if (cb && typeof cb !== 'function') { - doc = cb; - cb = null; - } - - // Use global document if we don't have one - doc = doc || window.document; - - // Handle DOM load - const done = function () { - return resolve(cb && cb()); - }; - - // Resolve now if DOM has already loaded - // Otherwise wait for DOMContentLoaded - if (loadedStates.indexOf(doc.readyState) !== -1) { - setTimeout(done, 0); - } else { - doc.addEventListener('DOMContentLoaded', done); - } - }); -}; - -// Promise chain helper -whenDomReady.resume = function (doc) { - return function (val) { - return whenDomReady(doc).then(function () { - return val; - }); - }; -}; - -module.exports = whenDomReady; \ No newline at end of file