<commit_before>//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// Returns list of unique values
//------------------------------------------------------------------------------
d3plus.util.uniques = function( data , value ) {

  if ( data === undefined || value === undefined ) {
    return []
  }

  var type = false

  return d3.nest()
    .key(function(d) {

      if ( d3plus.object.validate(d) && typeof value === "string" ) {
        var val = d[value]
      }
      else if ( typeof value === "function" ) {
        var val = value(d)
      }
      else {
        var val = d
      }

      if (!type) type = typeof val
      return val

    })
    .entries(data)
    .reduce(function( a , b ){

      if (b.key === "undefined") return a

      if (type === "number") var val = parseFloat(b.key)
      else var val = b.key

      return a.concat(val)

    }, [] ).sort(function(a,b){return a-b})

}<commit_msg>re-wrote d3plus.util.uniques<commit_after>//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// Returns list of unique values
//------------------------------------------------------------------------------
d3plus.util.uniques = function( data , value ) {

  if ( data === undefined || value === undefined ) {
    return []
  }

  if (!(data instanceof Array)) data = [data]

  var vals = [], lookups = []
  data.forEach(function(d){
    if (d3plus.object.validate(d)) {
      if (typeof value === "function") {
        var val = value(d)
      }
      else {
        var val = d[value]
      }
      var lookup = ["number","string"].indexOf(typeof val) >= 0 ? val : JSON.stringify(val)
      if (lookups.indexOf(lookup) < 0) {
        vals.push(val)
        lookups.push(lookup)
      }
    }
  })

  vals.sort(function(a,b){return a-b})

  return vals

}
{'fraction_non_alphanumeric': 0.30501089324618735, 'fraction_numerical': 0.004357298474945534, 'mean_word_length': 1.8218125960061444, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '7419334', 'n_tokens_mistral': 567, 'n_tokens_neox': 544, 'n_words': 128}