<commit_before>'use strict';

var concat = require('concat-stream'),
    through = require('through2'),
    duplexer = require('duplexer2');

var fs = require('fs');


module.exports = function (file) {
  if (file != null) {
    return concat(function (data) {
      fs.createWriteStream(file).end(data);
    });
  }
  else {
    var readable = through();
    var writable = concat(readable.write.bind(readable));
    return duplexer(writable, readable);
  }
};<commit_msg>End transform stream when finished<commit_after>'use strict';

var concat = require('concat-stream'),
    through = require('through2'),
    duplexer = require('duplexer2');

var fs = require('fs');


module.exports = function (file) {
  if (file != null) {
    return concat(function (data) {
      fs.createWriteStream(file).end(data);
    });
  }
  else {
    var readable = through();
    var writable = concat(readable.end.bind(readable));
    return duplexer(writable, readable);
  }
};
{'fraction_non_alphanumeric': 0.15751295336787566, 'fraction_numerical': 0.004145077720207254, 'mean_word_length': 3.7586206896551726, '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': '5148386', 'n_tokens_mistral': 315, 'n_tokens_neox': 302, 'n_words': 68}