<commit_before>var mirror = exports;
var fs = require('fs');

mirror.assets = function assets(require, assets, options) {
    if (!Array.isArray(assets)) assets = [ assets ];
    if (!options) options = {};
    if (!options.headers) options.headers = {'Content-Type': 'text/javascript'};

    return function(req, res, next) {
        var data = [];
        if (!assets.length) return done();

        var pending = assets.length, cancelled = false;
        for (var i = 0; i < assets.length; i++) {
            fs.readFile(require.resolve(assets[i]), 'utf8', function(err, file) {
                if (err) {
                    cancelled = true;
                    next(err);
                } else if (!cancelled) {
                    if (options.wrapper) file = options.wrapper(file, assets[this]);
                    data[this] = file;
                    if (!--pending) done();
                }
            }.bind(i));
        }

        function done() {
            res.send(data.join('\n'), options.headers);
        }
    };
};

mirror.source = function source(sources, options) {
    if (!Array.isArray(sources)) sources = [ sources ];
    if (!options) options = {};
    if (!options.headers) options.headers = {'Content-Type': 'text/javascript'};
<commit_msg>don't pass in require; always require global paths<commit_after>var mirror = exports;
var fs = require('fs');

mirror.assets = function assets(assets, options) {
    if (!Array.isArray(assets)) assets = [ assets ];
    if (!options) options = {};
    if (!options.headers) options.headers = {'Content-Type': 'text/javascript'};

    return function(req, res, next) {
        var data = [];
        if (!assets.length) return done();

        var pending = assets.length, cancelled = false;
        for (var i = 0; i < assets.length; i++) {
            fs.readFile(assets[i], 'utf8', function(err, file) {
                if (err) {
                    cancelled = true;
                    next(err);
                } else if (!cancelled) {
                    if (options.wrapper) file = options.wrapper(file, assets[this]);
                    data[this] = file;
                    if (!--pending) done();
                }
            }.bind(i));
        }

        function done() {
            res.send(data.join('\n'), options.headers);
        }
    };
};

mirror.source = function source(sources, options) {
    if (!Array.isArray(sources)) sources = [ sources ];
    if (!options) options = {};
    if (!options.headers) options.headers = {'Content-Type': 'text/javascript'};

{'fraction_non_alphanumeric': 0.15528677331252438, 'fraction_numerical': 0.0015606710885680843, 'mean_word_length': 1.9607390300230947, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '2285805', 'n_tokens_mistral': 721, 'n_tokens_neox': 703, 'n_words': 182}