<commit_before>function WeightedRandomPicker (weightedValues) {

  this.weightedValues = weightedValues || {};

  this.randomPick = function(options){
    var options = options || {};
    var uniq = options.uniq || false;
    var times = options.times || 1;
    var picks = [];

    if (uniq && times > this.getKeys().length) {
      throw new InvalidUniqTimesException();
    } else {
      for (var i=0; i<times; i++){
        picks.push(_randomPick.call(this, uniq));
      }
    }

    return options.times > 1 ? picks : picks[0];
  };

  this.getKeys = function(){
    return Object.keys(this.weightedValues);
  };
<commit_msg>clones the input object<commit_after>function WeightedRandomPicker (initialWeightedValues) {

  //clones the initialWeightedValues:
  //set default to empty object for the JSON lib clone trick to work
  var weightedValues = initialWeightedValues || {};
  // clones param object to property of this
  this.weightedValues = JSON.parse(JSON.stringify(weightedValues));

  this.randomPick = function(options){
    var options = options || {};
    var uniq = options.uniq || false;
    var times = options.times || 1;
    var picks = [];

    if (uniq && times > this.getKeys().length) {
      throw new InvalidUniqTimesException();
    } else {
      for (var i=0; i<times; i++){
        picks.push(_randomPick.call(this, uniq));
      }
    }

    return options.times > 1 ? picks : picks[0];
  };

  this.getKeys = function(){
    return Object.keys(this.weightedValues);
  };

{'fraction_non_alphanumeric': 0.1333775713337757, 'fraction_numerical': 0.0053085600530856005, 'mean_word_length': 3.097826086956522, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '2815425', 'n_tokens_mistral': 470, 'n_tokens_neox': 444, 'n_words': 117}