"use strict";

module.exports = function awaitImageLoad(imageElement) {
	// FIXME: Validation
	return new Promise((resolve, reject) => {
		imageElement.addEventListener("load", (_event) => {
			resolve();
		});

		imageElement.addEventListener("error", (_event) => {
			// The event does not have an actual error stored on it
			reject(new Error("Could not load image")); // FIXME: Error type
		});
	});
};
