<commit_before>

function controller(httpMethodName, url, body, doneCallback) {

   var 
       // the api available on an oboe instance. Will expose 3 methods, onPath, onNode and onError               
       events = pubSub(),
       
       clarinetParser = clarinet.parser(),           
                                      
       // create a json builder and store a function that can be used to get the
       // root of the json later:
       /**
        * @type {Function}
        */          
       objectSoFar = jsonBuilder(
                         clarinetParser,
                          
                         // when a node is found, notify matching node listeners:
                         partialComplete(events.notify, NODE_FOUND_EVENT),
      
                         // when a node is found, notify matching path listeners:                                        
                         partialComplete(events.notify, PATH_FOUND_EVENT)
                     );
   
   clarinetParser.onerror =  
       function(e) {
          events.notifyErr(e);
            
          // the json is invalid, give up and close the parser to prevent getting any more:
          clarinetParser.close();
       };
                     
   /* Given a value from the user to send as the request body, return in a form
      that is suitable to sending over the wire. Which is, either a string or
      null.                     
    */
   function validatedBody( body ) {
      if( !body )
         return null;
   
      return isString(body)? body: JSON.stringify(body);<commit_msg>shortcut method<commit_after>

function controller(httpMethodName, url, body, doneCallback) {

   var 
       // the api available on an oboe instance. Will expose 3 methods, onPath, onNode and onError               
       events = pubSub(),
       
       notify = events.notify, // shortcut
       
       clarinetParser = clarinet.parser(),           
                                      
       // create a json builder and store a function that can be used to get the
       // root of the json later:
       /**
        * @type {Function}
        */          
       objectSoFar = jsonBuilder(
                         clarinetParser,
                          
                         // when a node is found, notify matching node listeners:
                         partialComplete(notify, NODE_FOUND_EVENT),
      
                         // when a node is found, notify matching path listeners:                                        
                         partialComplete(notify, PATH_FOUND_EVENT)
                     );
   
   clarinetParser.onerror =  
       function(e) {
          events.notifyErr(e);
            
          // the json is invalid, give up and close the parser to prevent getting any more:
          clarinetParser.close();
       };
                     
   /* Given a value from the user to send as the request body, return in a form
      that is suitable to sending over the wire. Which is, either a string or
      null.                     
    */
   function validatedBody( body ) {
      if( !body )
         return null;
   
      return isString(body)? body: JSON.stringify(body);
{'fraction_non_alphanumeric': 0.06356589147286822, 'fraction_numerical': 0.00062015503875969, 'mean_word_length': 1.2325259515570934, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1308928', 'n_tokens_mistral': 750, 'n_tokens_neox': 720, 'n_words': 271}