<commit_before>module.exports = Response.inherits( autodafe.AppModule );

function Response( params ) {
  this._init( params );
}


Response.prototype._init = function( params ) {
  Response.parent._init.call( this, params );

  if ( !autodafe.Controller.is_instantiate( params.controller ) )
    throw new Error( '`controller` should be instance of Controller in Response._init' );
  this.controller = params.controller;

  this.view       = params.view;
  this.params     = params.params;
  this.text       = null;
};


Response.prototype.to = function( client ){
  var params = Object.merge( this.params, this.controller.global_view_params( this, client ) );

  var self = this;
  this.controller.render( this.view, params, function( e, data ){
    if ( e ) return self.emit( 'error', e );

    self.text = data;
    self.emit( 'data', self.text );

    client.send( self.text );
  } );

  return this;
};<commit_msg>fix Response.to<commit_after>module.exports = Response.inherits( autodafe.AppModule );

function Response( params ) {
  this._init( params );
}


Response.prototype._init = function( params ) {
  Response.parent._init.call( this, params );

  if ( !autodafe.Controller.is_instantiate( params.controller ) )
    throw new Error( '`controller` should be instance of Controller in Response._init' );
  this.controller = params.controller;

  this.view       = params.view;
  this.params     = params.params;
  this.text       = null;
};


Response.prototype.to = function( client ){
  var params = Object.merge( this.controller.global_view_params( this, client ), this.params );

  var self = this;
  this.controller.render( this.view, params, function( e, data ){
    if ( e ) return self.emit( 'error', e );

    self.text = data;
    self.emit( 'data', self.text );

    client.send( self.text );
  } );

  return this;
};
{'fraction_non_alphanumeric': 0.13626492942453855, 'fraction_numerical': 0.0, 'mean_word_length': 3.3569739952718676, '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': '3299498', 'n_tokens_mistral': 579, 'n_tokens_neox': 560, 'n_words': 141}