<commit_before>var Module = require('module');
var removeTypes = require('./index');

// Rather than use require.extensions, swizzle Module#_compile. Not only does
// this typically leverage the existing behavior of require.extensions['.js'],
// but allows for use alongside other "require extension hook" if necessary.
var super_compile = Module.prototype._compile;
Module.prototype._compile = function _compile(source, filename) {
  var transformedSource = filename.indexOf('node_modules/') === -1
    ? removeTypes(source)
    : source;
  super_compile.call(this, transformedSource, filename);
};
<commit_msg>Yet another improvement to the require hook.<commit_after>var removeTypes = require('./index');

// Swizzle Module#_compile on each applicable module instance.
// NOTE: if using alongside Babel or another require-hook which simply
// over-writes the require.extensions and does not continue execution, then
// this require hook must come after it. Encourage those module authors to call
// the prior loader in their require hooks.
var jsLoader = require.extensions['.js'];
var exts = [ '.js', '.jsx', '.flow', '.es6' ];
exts.forEach(function (ext) {
  var superLoader = require.extensions[ext] || jsLoader;
  require.extensions[ext] = function (module, filename) {
    if (filename.indexOf('/node_modules/') === -1) {
      var super_compile = module._compile;
      module._compile = function _compile(code, filename) {
        super_compile.call(this, removeTypes(code), filename);
      };
    }
    superLoader(module, filename);
  };
});

{'fraction_non_alphanumeric': 0.12411575562700965, 'fraction_numerical': 0.0019292604501607716, 'mean_word_length': 4.347079037800687, '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': '2789193', 'n_tokens_mistral': 413, 'n_tokens_neox': 410, 'n_words': 139}