<commit_before>/*!
 * Dsafio
 * Copyright (c) 2017 <NAME> <<EMAIL>>
 * MIT Licensed
 */

/**
 * Implements the `pick` method of lodash, throwing errors when keys are absent.
 * The original package is not used due to lodash custom builds being quite big.
 *
 * @see https://www.npmjs.com/package/lodash.pick
 * @see https://lodash.com/docs/#pick
 */
const pick = (source, keys) => {
  if (!source || typeof source !== 'object') {
    throw new Error('Parameter `source` must be an object')
  }

  if (keys !== undefined && !Array.isArray(keys)) {
    throw new Error('Parameter `keys` must be an array')
  }

  if (!keys) {
    return source
  }<commit_msg>Adds debug() calls to lib/helpers/pick<commit_after>/*!
 * Dsafio
 * Copyright (c) 2017 <NAME> <<EMAIL>>
 * MIT Licensed
 */

const debug = require('debug')('dsafio/lib/helpers/pick')
debug('lib/config/pick running')

/**
 * Implements the `pick` method of lodash, throwing errors when keys are absent.
 * The original package is not used due to lodash custom builds being quite big.
 *
 * @see https://www.npmjs.com/package/lodash.pick
 * @see https://lodash.com/docs/#pick
 */
const pick = (source, keys) => {
  debug('pick() running')

  debug(`source: ${typeof source} ${source}`)
  debug(`keys: ${typeof keys} ${keys}`)

  if (!source || typeof source !== 'object') {
    throw new Error('Parameter `source` must be an object')
  }

  if (keys !== undefined && !Array.isArray(keys)) {
    throw new Error('Parameter `keys` must be an array')
  }

  if (!keys) {
    return source
  }
{'fraction_non_alphanumeric': 0.16181229773462782, 'fraction_numerical': 0.005177993527508091, 'mean_word_length': 3.56047197640118, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, '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': '875504', 'n_tokens_mistral': 503, 'n_tokens_neox': 483, 'n_words': 163}