<commit_before>/*jshint loopfunc:true */
/*global exports, lumbarLoadPrefix */
var lumbarLoader = exports.loader = {
  loadPrefix: typeof lumbarLoadPrefix === 'undefined' ? '' : lumbarLoadPrefix,
  preloadTimeout: 5000,

  isLoaded: function(moduleName) {
    return lumbarLoadedModules[moduleName] === true;
  },
  isLoading: function(moduleName) {
    return !!lumbarLoadedModules[moduleName];
  },

  loadModule: function(moduleName, callback, options) {
    options = options || {};

    var loaded = lumbarLoadedModules[moduleName];
    if (loaded) {
      // We have already been loaded or there is something pending. Handle it
      if (loaded === true) {
        callback();
      } else {
        loaded.push(callback);
      }
      return;
    }

    loaded = lumbarLoadedModules[moduleName] = [callback];

    var loadCount = 0,
        expected = 1,
        allInit = false,
        moduleInfo = lumbarLoader.modules && lumbarLoader.modules[moduleName];

    function complete(error) {
      loadCount++;
      if (error || (allInit && loadCount >= expected)) {
        lumbarLoadedModules[moduleName] = !error;
        if (moduleInfo && moduleInfo.preload && !options.silent) {
          setTimeout(function() {
            preloadModules(moduleInfo.preload);
          }, lumbarLoader.preloadTimeout);
        }
        for (var i = 0, len = loaded.length; i < len; i++) {
          loaded[i](error);
        }
        lumbarLoader.loadComplete && lumbarLoader.loadComplete(moduleName, error);
      }
    }

    function loadResources(error) {
      if (!error) {
        expected += lumbarLoader.loadCSS(moduleName, complete);
        expected += lumbarLoader.loadJS(moduleName, complete);
        // If everything was done sync then fire away
        allInit = true;
      }
      complete(error);
    }

    if (moduleInfo && moduleInfo.depends) {
      var dep = moduleInfo.depends,
          queue = self.queue();
      for (var i=0; i<dep.length; i++) {
        queue.defer(lumbarLoader.loadModule, dep[i]);
      }
      queue.awaitAll(loadResources);
    } else {
      loadResources();
    }
  },

  loadInlineCSS: function(content) {
    var style = document.createElement('style');
    style.textContent = content;
    appendResourceElement(style);
    return style;
  }
};

var lumbarLoadedModules = {},
    lumbarLoadedResources = {},
    fieldAttr = {
      js: 'src',
      css: 'href'
    };
function loadResources(moduleName, field, callback, create) {
  var module = moduleName === 'base' ? lumbarLoader.map.base : lumbarLoader.modules[moduleName], // Special case for the base case
      loaded = [],
      attr = fieldAttr[field];
  field = module[field] || [];

  if (Array.isArray ? !Array.isArray(field) : Object.prototype.toString.call(field) !== '[object Array]') {
    field = [field];
  }
  for (var i = 0, len = field.length; i < len; i++) {
    var object = field[i];
    var href = checkLoadResource(object, attr);
    if (href && !lumbarLoadedResources[href]) {
      var el = create(href, function(err) {
        if (err && err.type === 'connection') {
          lumbarLoadedResources[href] = false;
        }<commit_msg>Fix loading of non-application base module<commit_after>/*jshint loopfunc:true */
/*global exports, lumbarLoadPrefix */
var lumbarLoader = exports.loader = {
  loadPrefix: typeof lumbarLoadPrefix === 'undefined' ? '' : lumbarLoadPrefix,
  preloadTimeout: 5000,

  isLoaded: function(moduleName) {
    return lumbarLoadedModules[moduleName] === true;
  },
  isLoading: function(moduleName) {
    return !!lumbarLoadedModules[moduleName];
  },

  loadModule: function(moduleName, callback, options) {
    options = options || {};

    var loaded = lumbarLoadedModules[moduleName];
    if (loaded) {
      // We have already been loaded or there is something pending. Handle it
      if (loaded === true) {
        callback();
      } else {
        loaded.push(callback);
      }
      return;
    }

    loaded = lumbarLoadedModules[moduleName] = [callback];

    var loadCount = 0,
        expected = 1,
        allInit = false,
        moduleInfo = lumbarLoader.modules && lumbarLoader.modules[moduleName];

    function complete(error) {
      loadCount++;
      if (error || (allInit && loadCount >= expected)) {
        lumbarLoadedModules[moduleName] = !error;
        if (moduleInfo && moduleInfo.preload && !options.silent) {
          setTimeout(function() {
            preloadModules(moduleInfo.preload);
          }, lumbarLoader.preloadTimeout);
        }
        for (var i = 0, len = loaded.length; i < len; i++) {
          loaded[i](error);
        }
        lumbarLoader.loadComplete && lumbarLoader.loadComplete(moduleName, error);
      }
    }

    function loadResources(error) {
      if (!error) {
        expected += lumbarLoader.loadCSS(moduleName, complete);
        expected += lumbarLoader.loadJS(moduleName, complete);
        // If everything was done sync then fire away
        allInit = true;
      }
      complete(error);
    }

    if (moduleInfo && moduleInfo.depends) {
      var dep = moduleInfo.depends,
          queue = self.queue();
      for (var i=0; i<dep.length; i++) {
        queue.defer(lumbarLoader.loadModule, dep[i]);
      }
      queue.awaitAll(loadResources);
    } else {
      loadResources();
    }
  },

  loadInlineCSS: function(content) {
    var style = document.createElement('style');
    style.textContent = content;
    appendResourceElement(style);
    return style;
  }
};

var lumbarLoadedModules = {},
    lumbarLoadedResources = {},
    fieldAttr = {
      js: 'src',
      css: 'href'
    };
function loadResources(moduleName, field, callback, create) {
  var module = (moduleName === 'base' && lumbarLoader.map.base) || lumbarLoader.modules[moduleName], // Special case for the base case
      loaded = [],
      attr = fieldAttr[field];
  field = module[field] || [];

  if (Array.isArray ? !Array.isArray(field) : Object.prototype.toString.call(field) !== '[object Array]') {
    field = [field];
  }
  for (var i = 0, len = field.length; i < len; i++) {
    var object = field[i];
    var href = checkLoadResource(object, attr);
    if (href && !lumbarLoadedResources[href]) {
      var el = create(href, function(err) {
        if (err && err.type === 'connection') {
          lumbarLoadedResources[href] = false;
        }
{'fraction_non_alphanumeric': 0.13231831737560823, 'fraction_numerical': 0.002825302150368859, 'mean_word_length': 2.737243401759531, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, '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': '2307860', 'n_tokens_mistral': 1878, 'n_tokens_neox': 1840, 'n_words': 431}