<commit_before>var through = require('through2');
var recast = require('recast');

var transformer = require('./unreachableBranchTransformer');

module.exports = function (file, opts) {
  opts = opts || [];
  var ignore = ['.json'].concat(opts.ignore || []).some(function(ext) {
    return file.indexOf(ext, file.length - ext.length) !== -1;
  });

  if (ignore) {
    return through();
  }

  var buffers = [];
  return through(function(chunk, enc, cb) {
    buffers.push(chunk);
    cb();
  }, function(cb) {
    var source = Buffer.concat(buffers).toString();
    this.push(transform(source));
    cb();
  });
};
<commit_msg>Make `file` argument optional, Resolves #4<commit_after>var through = require('through2');
var recast = require('recast');

var transformer = require('./unreachableBranchTransformer');

module.exports = function (file, opts) {
  if (typeof file === 'string') {
    opts = opts || [];
    var ignore = ['.json'].concat(opts.ignore || []).some(function(ext) {
      return file.indexOf(ext, file.length - ext.length) !== -1;
    });

    if (ignore) {
      return through();
    }
  }

  var buffers = [];
  return through(function(chunk, enc, cb) {
    buffers.push(chunk);
    cb();
  }, function(cb) {
    var source = Buffer.concat(buffers).toString();
    this.push(transform(source));
    cb();
  });
};

{'fraction_non_alphanumeric': 0.18922961854899029, 'fraction_numerical': 0.0037397157816005983, 'mean_word_length': 3.535593220338983, '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': '1383200', 'n_tokens_mistral': 425, 'n_tokens_neox': 422, 'n_words': 93}