<commit_before>/**
 * Here we have a fairly minimal set of polyfills needed to give old and rubbish browsers a fighting
 * chance of running the code. IE8, I'm looking at you.
 * 
 * If you already have polyfills in your webapp or you don't need to support bad browsers, feel free 
 * to make a custom build without this.
 */

if( !Array.prototype.forEach ) {

   /* Array.forEach has to be a polyfill, clarinet expects it
    *  Ignoring all but function argument since not needed, eg can't take a context  */     
   Array.prototype.forEach = function( func ){
   
      for( var i = 0 ; i < this.length ; i++ ) {      
         func( this[i] );    
      }      
   };         
}

if( !Array.prototype.filter ) {

   /* Array.filter has to be a polyfill, clarinet expects it.
    *  Ignoring all but function argument since not needed, eg can't take a context  */ 
   Array.prototype.filter = function( func ){
         
      var out = [];
   
      // let's use the .forEach we just declared above to implement .filter
      this.forEach(function(item){      
         if( func( item ) ) {
            out.push(item);
         }                  
      });
      
      return out;
   };
}

if( !Function.prototype.bind ) {
 
   Function.prototype.bind = function( context /*, arg1, arg2 ... */ ){
      var f = this,
          boundArgs = toArray(arguments, 1);
   
      return function( /* yet more arguments */ ) {
         var callArgs = boundArgs.concat(toArray(arguments));            
            
         return f.apply(context, callArgs);
      }
   };
}<commit_msg>shortcut prototypes in polyfills<commit_after>(function(arrayProto, functionProto){

   /**
    * Here we have a fairly minimal set of polyfills needed to give old and rubbish browsers a fighting
    * chance of running the code. IE8, I'm looking at you.
    * 
    * If you already have polyfills in your webapp or you don't need to support bad browsers, feel free 
    * to make a custom build without this.
    */
   
   if( !arrayProto.forEach ) {
   
      /* Array.forEach has to be a polyfill, clarinet expects it
       *  Ignoring all but function argument since not needed, eg can't take a context  */     
      arrayProto.forEach = function( func ){
      
         for( var i = 0 ; i < this.length ; i++ ) {      
            func( this[i] );    
         }      
      };         
   }
   
   if( !arrayProto.filter ) {
   
      /* Array.filter has to be a polyfill, clarinet expects it.
       *  Ignoring all but function argument since not needed, eg can't take a context  */ 
      arrayProto.filter = function( func ){
            
         var out = [];
      
         // let's use the .forEach we just declared above to implement .filter
         this.forEach(function(item){      
            if( func( item ) ) {
               out.push(item);
            }                  
         });
         
         return out;
      };
   }
   
   if( !functionProto.bind ) {
    
      functionProto.bind = function( context /*, arg1, arg2 ... */ ){
         var f = this,
             boundArgs = toArray(arguments, 1);
      
         return function( /* yet more arguments */ ) {
            var callArgs = boundArgs.concat(toArray(arguments));            
               
            return f.apply(context, callArgs);
         }
      };
   }

})(Array.prototype, Function.prototype);
{'fraction_non_alphanumeric': 0.09882005899705015, 'fraction_numerical': 0.0029498525073746312, 'mean_word_length': 1.7128, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1033360', 'n_tokens_mistral': 956, 'n_tokens_neox': 911, 'n_words': 328}