<commit_before>'use strict';

var through = require('through');
var innersource = require('innersource');
var detective = require('detective');
var prepend = innersource(addRequire).replace('\n', ';');
var postpend = innersource(addModule).replace('\n', ';');

module.exports = function() {
  var buffer = '';

  return through(function(chunk) {
    buffer += chunk.toString();
  },
  function() {
    var nodeModuleRequires = getNodeModuleRequires(buffer);
    this.queue(prepend + nodeModuleRequires+buffer +';' + postpend);
    this.queue(null);
  });

};

function addModule(){
  var global = (function(){ return this; }).call(null);
  if(typeof __filename !== 'undefined'){
    global.require[__filename.substring(0, __filename.length - 3)] = module.exports;
  }
}

function addRequire(){
  var global = (function(){ return this; }).call(null);
  if(!global.require){
    global.require = global.require || function require(key){return global.require[key];};

    (function(){
    var require = global.require;
    var ret = global.require;
        
    Object.defineProperty(global, 'require', {
        get: function(){
          return ret;
        },
        set: function(newRequire){
            ret = function(key){
                if(require[key]){
                  return require[key];
                }else{
                  var temp = ret;
                  ret = newRequire;
                  try {
                    var module = newRequire(key);
                  }
                  catch(e){
                    ret = temp;
                    throw e;
                  }
                  ret = temp;
                  return module;
                }
            };
            for(var key in require){
              ret[key] = require[key];
            }
        }
    });

    })();
  }

}

function getNodeModuleRequires(source){
  var requires = detective(source);
  requires = requires.filter(function(require){
    return require[0] !== '.';
  });
  return requires.map(function(require){
    return ";var global = (function(){ return this; }).call(null);global.require['"+require+"'] = require('"+require+"');";
  }).join('');
}

<commit_msg>Condense requireify added code to only two lines<commit_after>'use strict';

var through = require('through');
var innersource = require('innersource');
var detective = require('detective');
var prepend = innersource(addRequire).replace(/\n/g, '');
var postpend = innersource(addModule).replace(/\n/g, '');

module.exports = function() {
  var buffer = '';

  return through(function(chunk) {
    buffer += chunk.toString();
  },
  function() {
    var nodeModuleRequires = getNodeModuleRequires(buffer);
    this.queue(prepend + nodeModuleRequires+buffer +';' + postpend);
    this.queue(null);
  });

};

function addModule(){
  var global = (function(){ return this; }).call(null);
  if(typeof __filename !== 'undefined'){
    global.require[__filename.substring(0, __filename.length - 3)] = module.exports;
  }
}

function addRequire(){
  var global = (function(){ return this; }).call(null);
  if(!global.require){
    global.require = global.require || function require(key){return global.require[key];};

    (function(){
    var require = global.require;
    var ret = global.require;
        
    Object.defineProperty(global, 'require', {
        get: function(){
          return ret;
        },
        set: function(newRequire){
            ret = function(key){
                if(require[key]){
                  return require[key];
                }else{
                  var temp = ret;
                  ret = newRequire;
                  try {
                    var module = newRequire(key);
                  }
                  catch(e){
                    ret = temp;
                    throw e;
                  }
                  ret = temp;
                  return module;
                }
            };
            for(var key in require){
              ret[key] = require[key];
            }
        }
    });

    })();
  }

}

function getNodeModuleRequires(source){
  var requires = detective(source);
  requires = requires.filter(function(require){
    return require[0] !== '.';
  });
  return requires.map(function(require){
    return ";var global = (function(){ return this; }).call(null);global.require['"+require+"'] = require('"+require+"');";
  }).join('');
}


{'fraction_non_alphanumeric': 0.1504444950991566, 'fraction_numerical': 0.0013676772281741509, 'mean_word_length': 2.120910384068279, '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': '5943730', 'n_tokens_mistral': 1222, 'n_tokens_neox': 1186, 'n_words': 261}