<commit_before>var express = require('express');
var Connection = require('./lib/droonga-protocol/connection').Connection;
var httpAdapter = require('./lib/adapter/http');
var socketIoAdapter = require('./lib/adapter/socket.io');
var dashboardUI = require('./lib/ui/dashboard');

express.application.droonga = function(params) {
  params = params || {};

  params.connection = params.connection || new Connection(params);
  var connection = params.connection;

  params.prefix = params.prefix || '';
  params.prefix = params.prefix.replace(/\/$/, '');

  httpAdapter.register(this, params);

  if (params.server) {
    socketIoAdapter.register(this, params.server, params);
    params.server.on('close', function() {
      // The connection can be mocked/stubbed. We don't need to close
      // such a fake connection.
      if (typeof connection.close == 'function')
        connection.close();
    });
  }

  dashboardUI.register(this, params);

  this.connection = connection;
  this.emitMessage = connection.emitMessage.bind(connection); // shorthand
}

require('./lib/adapter/api').exportTo(exports);

exports.command = require('./lib/adapter/command');<commit_msg>Export initializer function separatelly<commit_after>var express = require('express');
var Connection = require('./lib/droonga-protocol/connection').Connection;
var httpAdapter = require('./lib/adapter/http');
var socketIoAdapter = require('./lib/adapter/socket.io');
var dashboardUI = require('./lib/ui/dashboard');

function droonga(application, params) {
  params = params || {};

  params.connection = params.connection || new Connection(params);
  var connection = params.connection;

  params.prefix = params.prefix || '';
  params.prefix = params.prefix.replace(/\/$/, '');

  httpAdapter.register(application, params);

  if (params.server) {
    socketIoAdapter.register(application, params.server, params);
    params.server.on('close', function() {
      // The connection can be mocked/stubbed. We don't need to close
      // such a fake connection.
      if (typeof connection.close == 'function')
        connection.close();
    });
  }

  dashboardUI.register(application, params);

  application.connection = connection;
  application.emitMessage = connection.emitMessage.bind(connection); // shorthand
}

exports.initialize = droonga;
express.application.droonga = droonga;

require('./lib/adapter/api').exportTo(exports);

exports.command = require('./lib/adapter/command');
{'fraction_non_alphanumeric': 0.15381493506493507, 'fraction_numerical': 0.0, 'mean_word_length': 4.20042194092827, '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': '5635997', 'n_tokens_mistral': 683, 'n_tokens_neox': 668, 'n_words': 143}