Code coverage report for src/js/base/core/async.js

# 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXN5bmMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI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