# all files / src/js/base/core/ async.js

65% Statements 13/20
100% Branches 0/0
50% Functions 5/10
63.16% Lines 12/19

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    521×
    1×
    1×

    2×

    1×

    2×
    1×
    1×
    1×
    1×
    1×

    1×

     (function(global){global.wrappers['/Users/lqez/Dev/summernote/src/js/base/core/async.js']=[function(require,module,exports,__dirname,__filename){ "use strict";
    exports.__esModule = true;
    var jquery_1 = require("jquery");
    /**
     * @method readFileAsDataURL
     *
     * read contents of file as representing URL
     *
     * @param {File} file
     * @return {Promise} - then: dataUrl
     */
    function readFileAsDataURL(file) {
        return jquery_1["default"].Deferred(function (deferred) {
            jquery_1["default"].extend(new FileReader(), {
                onload: function (e) {
                    var dataURL = e.target.result;
                    deferred.resolve(dataURL);
                },
                onerror: function (err) {
                    deferred.reject(err);
                }
            }).readAsDataURL(file);
        }).promise();
    }
    exports.readFileAsDataURL = readFileAsDataURL;
    /**
     * @method createImage
     *
     * create `<image>` from url string
     *
     * @param {String} url
     * @return {Promise} - then: $image
     */
    function createImage(url) {
        return jquery_1["default"].Deferred(function (deferred) {
            var $img = jquery_1["default"]('<img>');
            $img.one('load', function () {
                $img.off('error abort');
                deferred.resolve($img);
            }).one('error abort', function () {
                $img.off('load').detach();
                deferred.reject($img);
            }).css({
                display: 'none'
            }).appendTo(document.body).attr('src', url);
        }).promise();
    }
    exports.createImage = createImage;

    },'src/js/base/core/async.js',{"jquery":"/Users/lqez/Dev/summernote/node_modules/jquery/dist/jquery.js"}];})(this);
    //# sourceMappingURL=data:application/json;charset=utf-8;base64,