<commit_before>
import { getItems, replaceItems } from './utils';

export const dePopulate = () => hook => {
  const items = getItems(hook);

  (Array.isArray(items) ? items : [items]).forEach(item => {
    if ('_computed' in item) {
      item._computed.forEach(key => { delete item[key]; });
      delete item._computed;
    }

    if ('_include' in item) {
      item._include.forEach(key => { delete item[key]; });
      delete item._include;
    }

    delete item._elapsed;
  });

  replaceItems(hook, items);
  return hook;
};

<commit_msg>Handled a code climate issue<commit_after>
import { getItems, replaceItems } from './utils';

export const dePopulate = () => hook => {
  const items = getItems(hook);

  (Array.isArray(items) ? items : [items]).forEach(item => {
    removeProps('_computed', item);
    removeProps('_include', item);
    delete item._elapsed;
  });

  replaceItems(hook, items);
  return hook;
};

function removeProps (name, item) {
  if (name in item) {
    item[name].forEach(key => { delete item[key]; });
    delete item[name];
  }
}

{'fraction_non_alphanumeric': 0.15681003584229392, 'fraction_numerical': 0.0, 'mean_word_length': 2.8517241379310345, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '2310635', 'n_tokens_mistral': 356, 'n_tokens_neox': 346, 'n_words': 83}