// Loaded ready states
const loadedStates = ['interactive', 'complete'];

// Return Promise
module.exports = (cb, doc) => new Promise(resolve => {
	// Use global document if we don't have one
	doc = doc || document;

	// Handle DOM load
	const done = () => resolve(cb && cb());

	// Resolve now if DOM has already loaded
	// Otherwise wait for DOMContentLoaded
	if (loadedStates.includes(doc.readyState)) {
		done();
	} else {
		doc.addEventListener('DOMContentLoaded', done);
	}
});

@@ -140,16 +140,138 @@
 ve =%3E %7B%0A
+%09// Allow doc to be passed in as the lone first param%0A%09if (cb && typeof cb !== 'function') %7B%0A%09%09doc = cb;%0A%09%09cb = null;%0A%09%7D%0A%0A
 %09// Use 

Allow doc to be passed in as the lone first param