#include utility.js

const MamiEEPROMLoadScript = baseUrl => {
    return new Promise((resolve, reject) => {
        if(typeof baseUrl !== 'string')
            throw 'baseUrl must be a string';

        const src = `${baseUrl}/scripts/eepromv1a.js`;

        let script = $q(`script[src="${src}"]`);
        if(script instanceof Element) {
            resolve();
            return;
        }

        script = <script src={src} onload={() => { resolve(); }} onerror={() => { $r(script); reject(); }} />;
        document.body.appendChild(script);
    });
};
