<commit_before>'use strict';

var fs = require('fs-extra');
var Promise = require('any-promise');
var slice = Array.prototype.slice;

var keys = Object.keys(fs);
var promiseKeys = ['access', 'readFile', 'close', 'open', 'read', 'write', 'rename', 'truncate', 'ftruncate', 'rmdir', 'fdatasync', 'fsync', 'mkdir', 'readdir', 'fstat', 'lstat', 'stat', 'readlink', 'symlink', 'link', 'unlink', 'fchmod', 'lchmod', 'chmod', 'lchown', 'fchown', 'chown', '_toUnixTimestamp', 'utimes', 'futimes', 'writeFile', 'appendFile', 'realpath', 'lutimes', 'gracefulify', 'copy', 'mkdirs', 'mkdirp', 'ensureDir', 'remove', 'readJson', 'readJSON', 'writeJson', 'writeJSON', 'outputJson', 'outputJSON', 'move', 'createOutputStream', 'emptyDir', 'emptydir', 'createFile', 'ensureFile', 'createLink', 'ensureLink', 'createSymlink', 'ensureSymlink', 'outputFile', 'walk'];
var noErrorKeys = ['exists'];

keys.forEach(function (key) {
  var func = fs[key];

  if (promiseKeys.indexOf(key) !== -1) {
    exports[key] = function () {
      var args = slice.call(arguments);

      return new Promise(function (resolve, reject) {
        args.push(function(error, response) {
          if (error) {
            reject(error);
          } else {
            resolve(response);
          }
        });

        func.apply(fs, args);
      });
    };
  } else if (noErrorKeys.indexOf(key) !== -1) {
    exports[key] = function () {
      var args = slice.call(arguments);

      return new Promise(function (resolve) {
        args.push(resolve);

        func.apply(fs, args);
      });
    };
  } else {
    exports[key] = func;
  }
});
<commit_msg>add readable stream support (handle walk method properly)<commit_after>'use strict';

var fs = require('fs-extra');
var Promise = require('any-promise');
var slice = Array.prototype.slice;

var keys = Object.keys(fs);
var promiseKeys = ['access', 'readFile', 'close', 'open', 'read', 'write', 'rename', 'truncate', 'ftruncate', 'rmdir', 'fdatasync', 'fsync', 'mkdir', 'readdir', 'fstat', 'lstat', 'stat', 'readlink', 'symlink', 'link', 'unlink', 'fchmod', 'lchmod', 'chmod', 'lchown', 'fchown', 'chown', '_toUnixTimestamp', 'utimes', 'futimes', 'writeFile', 'appendFile', 'realpath', 'lutimes', 'gracefulify', 'copy', 'mkdirs', 'mkdirp', 'ensureDir', 'remove', 'readJson', 'readJSON', 'writeJson', 'writeJSON', 'outputJson', 'outputJSON', 'move', 'createOutputStream', 'emptyDir', 'emptydir', 'createFile', 'ensureFile', 'createLink', 'ensureLink', 'createSymlink', 'ensureSymlink', 'outputFile'];
var streamKeys = ['walk'];
var noErrorKeys = ['exists'];

keys.forEach(function (key) {
  var func = fs[key];

  if (promiseKeys.indexOf(key) !== -1) {
    exports[key] = function () {
      var args = slice.call(arguments);

      return new Promise(function (resolve, reject) {
        args.push(function(error, response) {
          if (error) {
            reject(error);
          } else {
            resolve(response);
          }
        });

        func.apply(fs, args);
      });
    };
  } else if (noErrorKeys.indexOf(key) !== -1) {
    exports[key] = function () {
      var args = slice.call(arguments);

      return new Promise(function (resolve) {
        args.push(resolve);

        func.apply(fs, args);
      });
    };
  } else if (streamKeys.indexOf(key) !== -1) {
    exports[key] = function () {
      var args = slice.call(arguments);

      return new Promise(function (resolve, reject) {
        var stream = func.apply(fs, args);
        var items = [];

        stream
          .on('data', function (item) {
            items.push(item);
          })
          .on('end', function () {
            resolve(items);
          })
          .on('error', function (error) {
            reject(error);
          });
      });
    };
  } else {
    exports[key] = func;
  }
});

{'fraction_non_alphanumeric': 0.1946624803767661, 'fraction_numerical': 0.0013082155939298796, 'mean_word_length': 3.1964873765093302, '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': '4449566', 'n_tokens_mistral': 1233, 'n_tokens_neox': 1210, 'n_words': 287}