<commit_before><commit_msg>Copied original code from gulp-html PR, added jsdoc and improved clarity<commit_after>/**
 * Filter variables from the environment.
 *
 * @param  {String[]} keys             Array of environment variables to filter out
 * @param  {Object=}  oldEnv           Environment object. Defaults to `process.env`
 * @return {Object}   result           Environment
 * @return {Object}   result.env       Clean environment
 * @return {String}   result.arguments Arguments string
 */
function filter(keys, oldEnv) {
  // New process environment
  var cleanEnv = {};
  // Filtered options
  var filteredOpts = [];
  var filteredEnv = {};

  oldEnv = oldEnv || process.env;

  // Copy environment but filter variables
  Object.keys(oldEnv)
    .forEach(function (property) {
      if (keys.indexOf(property) > -1) {
        // Copy into result object
        filteredEnv[property] = oldEnv[property];

        // If empty, don't add to arguments string
        if (oldEnv[property].length > 0) {
          filteredOpts.push(oldEnv[property]);
        }
      } else {
        cleanEnv[property] = oldEnv[property];
      }
    });

  filteredEnv.env = cleanEnv;
  filteredEnv.arguments = filteredOpts.join(' ');

  return filteredEnv;
}

exports.filter = filter;
{'fraction_non_alphanumeric': 0.11137254901960784, 'fraction_numerical': 0.001568627450980392, 'mean_word_length': 2.7640117994100293, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5761630', 'n_tokens_mistral': 355, 'n_tokens_neox': 350, 'n_words': 104}