<commit_before>'use strict';

exports.compress = compress;
exports.decompress = decompress;

var brotli  = require('iltorb');
var through = require('through2');

function getExtension(params) {
  return params && params.extension || 'br';
}

function compress(params) {
  params = params || {};

  var extension = getExtension(params);

  return through.obj(function(file, enc, cb) {
    if (file.isNull()) {
      cb(null, file);
      return;
    }

    file.path += '.' + extension;

    if (file.isStream()) {
      file.contents = file.contents.pipe(brotli.compressStream(params));
      cb(null, file);
      return;
    }

    if (file.isBuffer()) {
      brotli.compress(file.contents, params, function(err, output) {
        if (err) {
          cb(err);
          return;
        }
        file.contents = output;
        cb(null, file);
      });
    }
  });
}

function decompress(params) {
  var extension = getExtension(params);
  var reExtension = new RegExp('.' + extension + '$', 'i');
  return through.obj(function(file, enc, cb) {
    if (file.isNull()) {
      cb(null, file);
      return;
    }

    file.path = file.path.replace(reExtension, '');

    if (file.isStream()) {
      file.contents = file.contents.pipe(brotli.decompressStream());
      cb(null, file);
      return;
    }

    if (file.isBuffer()) {
      brotli.decompress(file.contents, function(err, output) {
        if (err) {
          cb(err);
          return;
        }
        file.contents = output;
        cb(null, file);
      });
    }
  });
}<commit_msg>Escape the dot in the regular expression<commit_after>'use strict';

exports.compress = compress;
exports.decompress = decompress;

var brotli  = require('iltorb');
var through = require('through2');

function getExtension(params) {
  return params && params.extension || 'br';
}

function compress(params) {
  params = params || {};

  var extension = getExtension(params);

  return through.obj(function(file, enc, cb) {
    if (file.isNull()) {
      cb(null, file);
      return;
    }

    file.path += '.' + extension;

    if (file.isStream()) {
      file.contents = file.contents.pipe(brotli.compressStream(params));
      cb(null, file);
      return;
    }

    if (file.isBuffer()) {
      brotli.compress(file.contents, params, function(err, output) {
        if (err) {
          cb(err);
          return;
        }
        file.contents = output;
        cb(null, file);
      });
    }
  });
}

function decompress(params) {
  var extension = getExtension(params);
  var reExtension = new RegExp('\\.' + extension + '$', 'i');
  return through.obj(function(file, enc, cb) {
    if (file.isNull()) {
      cb(null, file);
      return;
    }

    file.path = file.path.replace(reExtension, '');

    if (file.isStream()) {
      file.contents = file.contents.pipe(brotli.decompressStream());
      cb(null, file);
      return;
    }

    if (file.isBuffer()) {
      brotli.decompress(file.contents, function(err, output) {
        if (err) {
          cb(err);
          return;
        }
        file.contents = output;
        cb(null, file);
      });
    }
  });
}
{'fraction_non_alphanumeric': 0.15717467387846007, 'fraction_numerical': 0.0006363347120585428, 'mean_word_length': 2.3915857605177995, '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': '2285893', 'n_tokens_mistral': 1009, 'n_tokens_neox': 991, 'n_words': 204}