<commit_before>'use strict';

/**
 * Require modules.
 */

var isObject = require('is-object');
var clone = require('clone');

/**
 * Pick values from object except the given keys.
 *
 * @param {object} obj
 * @param {array|string}
 *
 * @return {object}
 */

module.exports = function except(obj, keys) {
  if (!isObject(obj)) {
    throw new Error('`obj` should be object');
  }

  if (typeof keys === 'string') {
    keys = [keys];
  }

  if (keys instanceof Array === false) {
    throw new Error('`keys` should be array');
  }

  var result = clone(obj);

  for (var i = 0, l = keys.length; i < l; i++) {
    var parts = keys[i].split('.');
    var first = parts.shift();
    var value = result[first];

    if (isObject(value) && parts.length > 0) {
      except(result[first], parts);
      if (isObject(result[first]) && !Object.keys(result[first]).length) {
        delete result[first];
      }
    } else {
      delete result[first];
    }
  }

  return result;
};
<commit_msg>Make it work in recursion too<commit_after>'use strict';

/**
 * Require modules.
 */

var isObject = require('is-object');
var clone = require('clone');

/**
 * Pick values from object except the given keys.
 *
 * @param {object} obj
 * @param {array|string}
 *
 * @return {object}
 */

module.exports = function except(obj, keys) {
  if (!isObject(obj)) {
    throw new Error('`obj` should be object');
  }

  if (typeof keys === 'string') {
    keys = [keys];
  }

  if (keys instanceof Array === false) {
    throw new Error('`keys` should be array');
  }

  var result = clone(obj);

  for (var i = 0, l = keys.length; i < l; i++) {
    var parts = keys[i].split('.');
    var first = parts.shift();
    var value = result[first];

    if (isObject(value) && parts.length > 0) {
      result = except(result[first], parts);
      if (isObject(result[first]) && !Object.keys(result[first]).length) {
        delete result[first];
      }
    } else {
      delete result[first];
    }
  }

  return result;
};

{'fraction_non_alphanumeric': 0.17523714428357465, 'fraction_numerical': 0.00199700449326011, 'mean_word_length': 2.853846153846154, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1228952', 'n_tokens_mistral': 669, 'n_tokens_neox': 651, 'n_words': 188}