<commit_before>/**
 * SystemJS Image Loader that embeds images as data URIs inside the application bundle.
 *
 * Created by tom on 03/06/15.
 */

var fs = require('fs');
var path = require('path');

exports.build = true;

exports.fetch = function (load) {
    return new Promise(function (resolve, reject) {
        var absolutePath = load.address.substr('file:'.length);
        fs.readFile(absolutePath, function (error, data) {
            if (error) { reject(error); }

            var extension = path.extname(absolutePath).replace('.', '').toLowerCase();

            /* SVG images don't need to be base64 encoded */
            var isSvg = extension === 'svg';
            var imgdata = isSvg ? data : data.toString('base64');

            var dataType = 'image/' + isSvg ? 'svg+xml' : extension;
            var charset = ';charset=utf-8';
            var encoding = isSvg ? '' : ';base64';

            if (isSvg) { data = data.toString().replace(/(\r\n|\n|\r)/gm, ''); }

            var uri = 'data:' + dataType + charset + encoding + ',' + imgdata;
            resolve('module.exports = "' + uri + '";');
        });
    });
};<commit_msg>Reverting until we have solution in place for Hans' inject-into-DOM use case<commit_after>/**
 * SystemJS Image Loader that embeds images as data URIs inside the application bundle.
 *
 * Created by tom on 03/06/15.
 */

var fs = require('fs');
var path = require('path');

exports.build = true;

exports.fetch = function (load) {
    return new Promise(function (resolve, reject) {
        var absolutePath = load.address.substr('file:'.length);
        fs.readFile(absolutePath, function (error, data) {
            if (error) { reject(error); }

            var extension = path.extname(absolutePath).replace('.', '').toLowerCase();

            /* SVG images don't need to be base64 encoded */
            var isSvg = extension === 'svg';
            var imgdata = isSvg ? data : data.toString('base64');

            var dataType = 'image/' + extension;
            var charset = ';charset=utf-8';
            var encoding = isSvg ? '' : ';base64';

            if (isSvg) {

                data = data.toString().replace(/(\r\n|\n|\r)/gm, '');
                //console.log(data);
                resolve('module.exports = \'' + data + '\';');
            }
            else {
                var uri = 'data:' + dataType + charset + encoding + ',' + imgdata;
                resolve('module.exports = "' + uri + '";');
            }
        });
    });
};
{'fraction_non_alphanumeric': 0.15910898965791567, 'fraction_numerical': 0.010342084327764518, 'mean_word_length': 2.093480934809348, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5130361', 'n_tokens_mistral': 752, 'n_tokens_neox': 715, 'n_words': 197}