<commit_before>var Script = process.binding('evals').Script,
    jsdom = require('jsdom'),
    _ = require('underscore'),
    step = require('step'),
    error = require('./error'),
    AssetGraph = require('./AssetGraph'),
    transforms = require('./transforms');

function JavaScriptLoader(config) {
    _.extend(this, config);
    this.assetGraph = new AssetGraph({root: config.root});
    this.window = _.extend(jsdom.createWindow(), {
        location: null,
        document: {},
        one: {
            include: function () {},
            exclude: function () {}
        }
    });
}

JavaScriptLoader.prototype.load = function (assetConfigs, cb) {
    var that = this;
    if (!that.labelsAdded && that.labels) {
        that.labelsAdded = true;
        var weirdLabelsArray = _.map(this.labels, function (value, labelName) {
            return labelName + "=" + value;
        });
        that.assetGraph.transform(
            transforms.registerLabelsAsCustomProtocols(weirdLabelsArray),
            function () {
                process.nextTick(function () {
                    that.load(assetConfigs, cb);
                });
            }
        );
        return;<commit_msg>JavaScriptLoader: Set window.location to 'file:' to get some loaded code working.<commit_after>var Script = process.binding('evals').Script,
    jsdom = require('jsdom'),
    _ = require('underscore'),
    step = require('step'),
    error = require('./error'),
    AssetGraph = require('./AssetGraph'),
    transforms = require('./transforms');

function JavaScriptLoader(config) {
    _.extend(this, config);
    this.assetGraph = new AssetGraph({root: config.root});
    this.window = _.extend(jsdom.createWindow(), {
        location: 'file:',
        document: {},
        one: {
            include: function () {},
            exclude: function () {}
        }
    });
}

JavaScriptLoader.prototype.load = function (assetConfigs, cb) {
    var that = this;
    if (!that.labelsAdded && that.labels) {
        that.labelsAdded = true;
        var weirdLabelsArray = _.map(this.labels, function (value, labelName) {
            return labelName + "=" + value;
        });
        that.assetGraph.transform(
            transforms.registerLabelsAsCustomProtocols(weirdLabelsArray),
            function () {
                process.nextTick(function () {
                    that.load(assetConfigs, cb);
                });
            }
        );
        return;
{'fraction_non_alphanumeric': 0.13995943204868155, 'fraction_numerical': 0.0, 'mean_word_length': 2.198443579766537, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4590246', 'n_tokens_mistral': 662, 'n_tokens_neox': 645, 'n_words': 129}