<commit_before>
/**
 * @class
 */
var MethodMsgProcessor = function( frameObserver ){
  this.frameObserver = frameObserver;
};

MethodMsgProcessor.prototype = {

  /**
   * @param {Event} msgEvt
   * @param {Object} source
   * @param {String} origin
   * @param {Deferred} deferred
   */
  onRecv:function( msgEvt, source, origin, deferred ){
    var frameObserver = this.frameObserver;
    var params = msgEvt.data.params;
    var methodName = params.shift()

    params.unshift( deferred );
    frameObserver.methods_ && frameObserver.methods_[methodName] && frameObserver.methods_[methodName].apply( frameObserver.methods_, params );
    deferred.done(function(){
      var respMsgEvt = buildMessageEvent( msgEvt.type, 'recv', {result:arguments}, msgEvt.id );
      source.postMessage( JSON.stringify( respMsgEvt ), origin);
    });
  },

  /**<commit_msg>added a fail feature when method is not exist<commit_after>
/**
 * @class
 */
var MethodMsgProcessor = function( frameObserver ){
  this.frameObserver = frameObserver;
};

MethodMsgProcessor.prototype = {

  /**
   * @param {Event} msgEvt
   * @param {Object} source
   * @param {String} origin
   * @param {Deferred} deferred
   */
  onRecv:function( msgEvt, source, origin, deferred ){
    var frameObserver = this.frameObserver;
    var params = msgEvt.data.params;
    var methodName = params.shift()

    params.unshift( deferred );

    if ( frameObserver.methods_ && frameObserver.methods_[methodName] ) {
      frameObserver.methods_[methodName].apply( frameObserver.methods_, params );
    } else {
      deferred.reject({err:"the method is not exist."});
    }

    deferred.always(function(){
      var respMsgEvt = buildMessageEvent( msgEvt.type, 'recv', {result:arguments}, msgEvt.id );
      source.postMessage( JSON.stringify( respMsgEvt ), origin);
    });

  },

  /**
{'fraction_non_alphanumeric': 0.13441734417344173, 'fraction_numerical': 0.0, 'mean_word_length': 3.6616161616161618, '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': '2196132', 'n_tokens_mistral': 565, 'n_tokens_neox': 549, 'n_words': 123}