<commit_before>function patternAdapter(oboeBus, jsonPathCompiler) {

   var predicateEventMap = {
      node:oboeBus(NODE_FOUND)
   ,  path:oboeBus(PATH_FOUND)
   };

   function addUnderlyingListener( fullEventName, predicateEvent, compiledJsonPath ){

      var fullEvent = oboeBus(fullEventName);
   
      predicateEvent.on( function (ascent) {

         var maybeMatchingMapping = compiledJsonPath(ascent);

         /* Possible values for maybeMatchingMapping are now:

          false: 
          we did not match 

          an object/array/string/number/null: 
          we matched and have the node that matched.
          Because nulls are valid json values this can be null.

          undefined:
          we matched but don't have the matching node yet.
          ie, we know there is an upcoming node that matches but we 
          can't say anything else about it. 
          */
         if (maybeMatchingMapping !== false) {

            fullEvent.emit(nodeOf(maybeMatchingMapping), ascent);
         }
      }, fullEventName);
   
      oboeBus('removeListener').on( function(removedEventName){

         // if the match even listener is later removed, clean up by removing
         // the underlying listener if nothing else is using that pattern:
      
         if( removedEventName == fullEventName ) {
         
            if( !oboeBus(removedEventName).listeners(  )) {
               predicateEvent.un( fullEventName );
            }
         }
      });   
   }

   oboeBus('newListener').on( function(fullEventName){

      var match = /(node|path):(.*)/.exec(fullEventName);
      
      if( match ) {
         var predicateEvent = predicateEventMap[match[1]];
                    
         if( !predicateEvent.hasListener( fullEventName) ) {  <commit_msg>extract emit method early<commit_after>function patternAdapter(oboeBus, jsonPathCompiler) {

   var predicateEventMap = {
      node:oboeBus(NODE_FOUND)
   ,  path:oboeBus(PATH_FOUND)
   };

   function addUnderlyingListener( fullEventName, predicateEvent, compiledJsonPath ){

      var emitMatch = oboeBus(fullEventName).emit;
   
      predicateEvent.on( function (ascent) {

         var maybeMatchingMapping = compiledJsonPath(ascent);

         /* Possible values for maybeMatchingMapping are now:

          false: 
          we did not match 

          an object/array/string/number/null: 
          we matched and have the node that matched.
          Because nulls are valid json values this can be null.

          undefined:
          we matched but don't have the matching node yet.
          ie, we know there is an upcoming node that matches but we 
          can't say anything else about it. 
          */
         if (maybeMatchingMapping !== false) {

            emitMatch(nodeOf(maybeMatchingMapping), ascent);
         }
      }, fullEventName);
   
      oboeBus('removeListener').on( function(removedEventName){

         // if the match even listener is later removed, clean up by removing
         // the underlying listener if nothing else is using that pattern:
      
         if( removedEventName == fullEventName ) {
         
            if( !oboeBus(removedEventName).listeners(  )) {
               predicateEvent.un( fullEventName );
            }
         }
      });   
   }

   oboeBus('newListener').on( function(fullEventName){

      var match = /(node|path):(.*)/.exec(fullEventName);
      
      if( match ) {
         var predicateEvent = predicateEventMap[match[1]];
                    
         if( !predicateEvent.hasListener( fullEventName) ) {  
{'fraction_non_alphanumeric': 0.08486878838637632, 'fraction_numerical': 0.0005583472920156337, 'mean_word_length': 2.1265270506108203, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5793135', 'n_tokens_mistral': 980, 'n_tokens_neox': 929, 'n_words': 263}