<commit_before>'use strict';

var fs      = require('fs');
var through = require('through2');

function write(d, m) {
  var fn = typeof d === 'function' ? d : function () { return d; };
  var mode = m === 'r+' ? m : 'w';

  return through.obj(function (file, enc, cb) {

    if (!file.stats.isFile()) {
      cb(null, file);
      return;
    }

    fs.writeFile(file.path, fn(file.path), {
      encoding: 'utf8',
      flag: mode
    },<commit_msg>Fix "write" based on tests<commit_after>'use strict';

var fs      = require('fs');
var through = require('through2');

function write(d, m) {
  var fn = typeof d === 'function' ? d : function () { return d; };
  var mode = m === 'a' ? m : 'w';

  return through.obj(function (file, enc, cb) {

    if (!file.stats.isFile()) {
      cb(null, file);
      return;
    }

    fs.writeFile(file.path, fn(file.path), {
      encoding: 'utf8',
      flag: mode
    },
{'fraction_non_alphanumeric': 0.1875, 'fraction_numerical': 0.0043859649122807015, 'mean_word_length': 2.6666666666666665, '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': '5163246', 'n_tokens_mistral': 321, 'n_tokens_neox': 315, 'n_words': 88}