<commit_before>/** 
 * A pub/sub which is responsible for a single event type
 * 
 * @param {String} eventType                   the name of the events managed by this singleEventPubSub
 * @param {singleEventPubSub} [newListener]    place to notify of new listeners
 * @param {singleEventPubSub} [removeListener] place to notify of when listeners are removed
 */
function singleEventPubSub(eventType, newListener, removeListener){

   var listeners;

   function hasId(id){
      return function(tuple) {
         return tuple.id == id;      
      };  
   }
              
   return {

      /**
       * @param {Function} listener
       * @param {*} listenerId 
       *    an id that this listener can later by removed by. 
       *    Can be of any type, to be compared to other ids using ==
       */
      on:function( listener, listenerId ) {
         
         var tuple = {
            listener: listener
         ,  id:       listenerId || listener // when no id is given use the
                                             // listener function as the id
         };

         if( newListener ) {
            newListener.emit(eventType, listener, tuple.id);
         }
         
         listeners = cons( tuple, listeners );

         return this; // chaining
      },
     
      emit:function () {      
         var parameters = arguments;
                    
         function emitInner(tuple) {                  
            tuple.listener.apply(null, parameters);               
         }                    
                                                                              
         applyEach( 
            emitInner, 
            listeners
         );
      },
      
      un: function( listenerId ) {
             
         var removed;             
              
         listeners = without(
            listeners,
            hasId(listenerId),
            function(tuple){
               removed = tuple;
            }
         );    
         
         if( removeListener && removed ) {
            removeListener.emit(eventType, removed.listener, removed.id);
         }
      },
      
      listeners: function(){<commit_msg>replace named function with inline/anon<commit_after>/** 
 * A pub/sub which is responsible for a single event type
 * 
 * @param {String} eventType                   the name of the events managed by this singleEventPubSub
 * @param {singleEventPubSub} [newListener]    place to notify of new listeners
 * @param {singleEventPubSub} [removeListener] place to notify of when listeners are removed
 */
function singleEventPubSub(eventType, newListener, removeListener){

   var listeners;

   function hasId(id){
      return function(tuple) {
         return tuple.id == id;      
      };  
   }
              
   return {

      /**
       * @param {Function} listener
       * @param {*} listenerId 
       *    an id that this listener can later by removed by. 
       *    Can be of any type, to be compared to other ids using ==
       */
      on:function( listener, listenerId ) {
         
         var tuple = {
            listener: listener
         ,  id:       listenerId || listener // when no id is given use the
                                             // listener function as the id
         };

         if( newListener ) {
            newListener.emit(eventType, listener, tuple.id);
         }
         
         listeners = cons( tuple, listeners );

         return this; // chaining
      },
     
      emit:function () {      
         var parameters = arguments;
                                                                                                                              
         applyEach( 
            function (tuple) {                  
               tuple.listener.apply(null, parameters);               
            }, 
            listeners
         );
      },
      
      un: function( listenerId ) {
             
         var removed;             
              
         listeners = without(
            listeners,
            hasId(listenerId),
            function(tuple){
               removed = tuple;
            }
         );    
         
         if( removeListener && removed ) {
            removeListener.emit(eventType, removed.listener, removed.id);
         }
      },
      
      listeners: function(){
{'fraction_non_alphanumeric': 0.07692307692307693, 'fraction_numerical': 0.0, 'mean_word_length': 1.1704035874439462, 'pattern_counts': {'":': 0, '<': 3, '<?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': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2850351', 'n_tokens_mistral': 993, 'n_tokens_neox': 970, 'n_words': 300}