<commit_before>'use strict';
var Promise = require('lie');
function denodify (nodefn) {
  return denodified;
  function denodified() {
    var self = this;
    var l = arguments.length;
    var args = new Array(l + 1);
    var promiseArgs = false;
    var i = -1;
    while (++i < l) {
      if (arguments[i] && typeof arguments[i].then === 'function') {
        promiseArgs = true;
      }
      args[i] = arguments[i];
    }
    if (!promiseArgs) {
      return new Promise(function(resolve, reject) {
        args[l] = function(err, val) {
              if (err) {
                reject(err);
              } else {
                resolve(val);
              }
          };
          nodefn.apply(self, args);
      });
    } else {
      return Promise.all(args).then(function (args) {
        return new Promise(function(resolve, reject) {
          args[l] = function(err, val) {
                if (err) {
                  reject(err);
                } else {
                  resolve(val);
                }
            };
            nodefn.apply(self, args);
        });
      });
    }
  };
}
module.exports = denodify;<commit_msg>more cases<commit_after>'use strict';
var Promise = require('lie');
module.exports = function denodify (nodefn, context) {
  return function denodified() {
    var self = context || this;
    var l = arguments.length;
    var args = new Array(l + 1);
    var promiseArgs = false;
    var i = -1;
    while (++i < l) {
      if (arguments[i] && typeof arguments[i].then === 'function') {
        promiseArgs = true;
      }
      args[i] = arguments[i];
    }
    if (!promiseArgs) {
      return new Promise(function denodifier(resolve, reject) {
        args[l] = function denodifyCallback(err, val) {
          var len = arguments.length;
          if (err) {
            reject(err);
          } else if (len < 3) {
            resolve(val);
          } else {
            var outArgs = new Array(len - 1);
            var i = 0;
            while (++i < len) {
              outArgs[i - 1] = arguments[i];
            }
            resolve(outArgs);
          }
        };
        nodefn.apply(self, args);
      });
    } else {
      return Promise.all(args).then( function afterAll(args) {
        return new Promise(function denodifier(resolve, reject) {
          args[l] = function denodifyCallback(err, val) {
            var len = arguments.length;
            if (err) {
              reject(err);
            } else if (len < 3) {
              resolve(val);
            } else {
              var outArgs = new Array(len - 1);
              var i = 0;
              while (++i < len) {
                outArgs[i - 1] = arguments[i];
              }
              resolve(outArgs);
            }
          };
          nodefn.apply(self, args);
        });
      });
    }
  };
}
{'fraction_non_alphanumeric': 0.1334507042253521, 'fraction_numerical': 0.004225352112676056, 'mean_word_length': 1.4533678756476685, 'pattern_counts': {'":': 0, '<': 9, '<?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': '2305744', 'n_tokens_mistral': 845, 'n_tokens_neox': 833, 'n_words': 203}