src/main.js
function getImageRaw(options, _onProgress = () => {}){
    return new Promise((resolve, reject) => {
        var request = new XMLHttpRequest();
        request.open('GET', options.url, true);
        request.responseType = options.responseType || 'blob';        
        function transferComplete(){
            var result;
            switch (options.responseType){
            case 'blob':
                result = new Blob([this.response], { type: options.mimeType || 'image/jpeg' });
                resolve(result);
                break;
            case 'arraybuffer':
                result = this.response;
                resolve(result);
                break;
            default:
                result = this.response;
                resolve(result);
                break;

            }
        }

        var transferCanceled = reject;
        var transferFailed = reject;

        request.addEventListener('progress', _onProgress, false);
        request.addEventListener('load', transferComplete, false);
        request.addEventListener('error', transferFailed, false);
        request.addEventListener('abort', transferCanceled, false);

        request.send(null);
    });

}
function getImageRaw(options, _onProgress = () => {}){
    return new Promise((resolve, reject) => {
        var request = new XMLHttpRequest();
        request.open('GET', options.url, true);
        request.responseType = options.responseType || 'blob';        
        function transferComplete(){
            var result;
            switch (options.responseType){
            case 'blob':
                result = new Blob([this.response], { type: options.mimeType || 'image/jpeg' });
                resolve(result);
                break;
            case 'arraybuffer':
                result = this.response;
                resolve(result);
                break;
            default:
                result = this.response;
                resolve(result);
                break;

            }
        }

        var transferCanceled = reject;
        var transferFailed = reject;

        request.addEventListener('progress', _onProgress, false);
        request.addEventListener('load', transferComplete, false);
        request.addEventListener('error', transferFailed, false);
        request.addEventListener('abort', transferCanceled, false);

        request.send(null);
    });

}
function getImageRaw ( options , _onProgress = ( ) => { } ) { return new Promise ( ( resolve , reject ) => { var request = new XMLHttpRequest ( ) ; request . open ( 'GET' , options . url , true ) ; request . responseType = options . responseType || 'blob' ; function transferComplete ( ) { var result ; switch ( options . responseType ) { case 'blob' : result = new Blob ( [ this . response ] , { type : options . mimeType || 'image/jpeg' } ) ; resolve ( result ) ; break ; case 'arraybuffer' : result = this . response ; resolve ( result ) ; break ; default : result = this . response ; resolve ( result ) ; break ; } } var transferCanceled = reject ; var transferFailed = reject ; request . addEventListener ( 'progress' , _onProgress , false ) ; request . addEventListener ( 'load' , transferComplete , false ) ; request . addEventListener ( 'error' , transferFailed , false ) ; request . addEventListener ( 'abort' , transferCanceled , false ) ; request . send ( null ) ; } ) ; }
getImageRaw from a specific url

@param {Object} options - the options object
@param {String} options.url - http or whatever
@param {String} [options.responseType="blob"] - possible values arraybuffer|blob
@param {String} [options.mimeType="image/jpeg"] - possible values "image/png"|"image/jpeg" used only if "blob" is set as responseType
@param {Function} [_onProgress=function(){}]
@return {Promise<Blob|ArrayBuffer|Error>}
getImageRaw from a specific url