<commit_before>
/**
 * function f provide value to make sure if it exist
 */
export function unique<T>(xs: T[], f?: (value: T) => any): T[] {
  if (!xs) {
    throw new Error('invalid array')
  }

  if (xs.length === 0) {
    return xs
  }

  let mem = []
  let result = []

  xs.forEach(v => {
    const value = f ? f(v) : v
    if (mem.indexOf(value) === -1) {
      result.push(v)
      mem.push(value)
    }
  })
  return result
}<commit_msg>Rafactor unique():rename parameter<commit_after>export function unique<T>(xs: T[], valueExtractor?: (value: T) => any): T[] {
  if (!Array.isArray(xs)) {
    throw new Error('invalid array')
  }

  if (xs.length === 0) {
    return xs
  }

  let mem = []
  let result = []

  xs.forEach(v => {
    const value = valueExtractor ? valueExtractor(v) : v
    if (mem.indexOf(value) === -1) {
      result.push(v)
      mem.push(value)
    }
  })
  return result
}
{'fraction_non_alphanumeric': 0.17900552486187846, 'fraction_numerical': 0.004419889502762431, 'mean_word_length': 2.5669291338582676, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '7624549', 'n_tokens_mistral': 336, 'n_tokens_neox': 326, 'n_words': 87}