<commit_before>var EventEmitter = require('events').EventEmitter ;
var proto = require('./proto') ;
var merge = require('utils-merge');
var methods = require('sip-methods') ;

exports = module.exports = createServer;

/**
 * Create a new server.
 *
 * @return {Function}
 * @api public
 */

function createServer() {
	function app(req, res, next){ 
		app.handle(req, res, next); 
	}
	app.method = '*';
	merge(app, proto);
	merge(app, EventEmitter.prototype);
	app.stack = [];
	app.params = []; 
	app._cachedEvents = [] ;
	app.routedMethods = {} ;
	for (var i = 0; i < arguments.length; ++i) {
		app.use(arguments[i]);
	}

	//create methods app.invite, app.register, etc..
	methods.forEach( function(method) {
		app[method.toLowerCase()] = app.use.bind( app, method.toLowerCase() ) ;		
	}) ;

	//special handling for cdr events
	app.on = function(event, listener) {
		if( 0 === event.indexOf('cdr:') ) {
		  if( app.client ) {
		    app.client.on(event, function() {
		      var args = Array.prototype.slice.call(arguments) ;
		      EventEmitter.prototype.emit.apply(app, [event].concat(args)) ;
		    }) ;
		  }
		  else {
		    this._cachedEvents.push( event ) ;
		  }
		}
		//delegate all others to standard EventEmitter prototype
    var args = Array.prototype.slice.call(arguments) ;
    return EventEmitter.prototype.addListener.call(app, event, listener) ;			
	} ;

  return app;
}<commit_msg>export objects from drachtio-client<commit_after>var EventEmitter = require('events').EventEmitter ;
var proto = require('./proto') ;
var merge = require('utils-merge');
var methods = require('sip-methods') ;
var client = require('./client') ;

exports = module.exports = createServer;

/**
 * Create a new server.
 *
 * @return {Function}
 * @api public
 */

function createServer() {
	function app(req, res, next){ 
		app.handle(req, res, next); 
	}
	app.method = '*';
	merge(app, proto);
	merge(app, EventEmitter.prototype);
	app.stack = [];
	app.params = []; 
	app._cachedEvents = [] ;
	app.routedMethods = {} ;
	for (var i = 0; i < arguments.length; ++i) {
		app.use(arguments[i]);
	}

	//create methods app.invite, app.register, etc..
	methods.forEach( function(method) {
		app[method.toLowerCase()] = app.use.bind( app, method.toLowerCase() ) ;		
	}) ;

	//special handling for cdr events
	app.on = function(event, listener) {
		if( 0 === event.indexOf('cdr:') ) {
		  if( app.client ) {
		    app.client.on(event, function() {
		      var args = Array.prototype.slice.call(arguments) ;
		      EventEmitter.prototype.emit.apply(app, [event].concat(args)) ;
		    }) ;
		  }
		  else {
		    this._cachedEvents.push( event ) ;
		  }
		}
		//delegate all others to standard EventEmitter prototype
    return EventEmitter.prototype.addListener.call(app, event, listener) ;			
	} ;

  return app;
}

createServer.Agent = client.Agent ;
createServer.Request = client.Request ;
createServer.Response = client.Response ;
createServer.onSend = client.onSend ;
{'fraction_non_alphanumeric': 0.1622169651909429, 'fraction_numerical': 0.0013518080432578573, 'mean_word_length': 3.4113263785394934, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7169976', 'n_tokens_mistral': 1022, 'n_tokens_neox': 968, 'n_words': 209}