<commit_before>/*
      Extensions to core objects to provide Ruby-like idioms
      ===========================================================
*/

Object.keys = function(o) {
  var keys = [];
  for(key in o) {
    keys.push(key);
  }
  return keys;  
}





Array.prototype.toSentence = function() {
  switch(this.length) {
    case 0:
      return '';
    case 1:
      return this[0].toString();
    case 2:
      return this[0].toString() + ' and ' + this[1].toString();
    default:
      return this.slice(0, -1).join(', ') + ', and ' + this[this.length - 1].toString();
  }
}

Array.prototype.dup = function(fn) {
  return this.slice(0);
}

Array.prototype.each = function(fn) {
  for(i=0; i<this.length; i++) {
    fn(this[i]);
  }
}

Array.prototype.collect = function(fn) {
  var new_array = [];
  for(var i=0; i<this.length; i++) {
    new_array.push(fn(this[i]));
  }
  return new_array;
}

Array.prototype.inject = function(memo, fn) {
  for(var i=0; i<this.length; i++) {
    memo = fn(memo, this[i]);
  }
  return memo;
}

Array.prototype.find = function(fn) {
  for(var i=0; i<this.length; i++) {
    if(fn(this[i])) {
      return this[i];
    }
  }
  return null;
}<commit_msg>made array.js more other-library friendly<commit_after>/*
      Extensions to core objects to provide Ruby-like idioms
      ===========================================================
*/

if(!Object.keys) {
  Object.keys = function(o) {
    var keys = [];
    for(key in o) {
      keys.push(key);
    }
    return keys;  
  }
}



if(!Array.prototype.toSentence) {
  Array.prototype.toSentence = function() {
    switch(this.length) {
      case 0:
        return '';
      case 1:
        return this[0].toString();
      case 2:
        return this[0].toString() + ' and ' + this[1].toString();
      default:
        return this.slice(0, -1).join(', ') + ', and ' + this[this.length - 1].toString();
    }
  }
}
if(!Array.prototype.dup) {
  Array.prototype.dup = function(fn) {
    return this.slice(0);
  }
}

if(!Array.prototype.each) {
  Array.prototype.each = function(fn) {
    for(i=0; i<this.length; i++) {
      fn(this[i]);
    }
  }
}

if(!Array.prototype.collect) {
  Array.prototype.collect = function(fn) {
    var new_array = [];
    for(var i=0; i<this.length; i++) {
      new_array.push(fn(this[i]));
    }
    return new_array;
  }
}

if(!Array.prototype.inject) {
  Array.prototype.inject = function(memo, fn) {
    for(var i=0; i<this.length; i++) {
      memo = fn(memo, this[i]);
    }
    return memo;
  }
}

if(!Array.prototype.find) {
  Array.prototype.find = function(fn) {
    for(var i=0; i<this.length; i++) {
      if(fn(this[i])) {
        return this[i];
      }
    }
    return null;
  }
}

{'fraction_non_alphanumeric': 0.21798165137614678, 'fraction_numerical': 0.010275229357798165, 'mean_word_length': 2.6689098250336474, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, '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': '2796410', 'n_tokens_mistral': 999, 'n_tokens_neox': 975, 'n_words': 183}