<commit_before>'use strict';

var type = require('type-of-is');
var io = require('socket.io');
var path = require('path');
var walk = require('walk');

function getRelativeName(root, name, basedir) {
  return path.normalize(path.join(root, path.basename(name, '.js')).replace(basedir, ''));
}

function getNamespace(root, name, basedir) {
  return getRelativeName(root, name, basedir).
  replace(/index/gi, '/').
  replace(/\\+|\/+/g, '/');
}

function getPath(root, name) {
  return path.normalize(path.join(root, name));
}

var debug = function () {};

module.exports = {

  io: null,

  modules: {},

  of: function (namespace) {
    namespace = ('/' + (namespace || '')).replace(/\/+/gi, '/');

    debug('Obtaining %s', namespace);

    try {
      return this.modules[namespace];
    } catch (ex) {
      throw new Error("Socket module [" + namespace + "] not registered!");
    }
  },

  init: function (config, callback) {
    var self = this;

    self.io = io(config.server);

    if (type.is(config.debug, Function)) {
      debug = config.debug;
    } else if (type.is(config.debug, Boolean) && config.debug) {
      debug = console.log;
    }

    /* Initialize socket modules (*.js) on the basedir folder */
    var walker = walk.walk(config.basedir);

    walker.on('file', function (root, stats, next) {
      if (path.extname(stats.name) === '.js') {
        /* Get file's path */
        var file = getPath(root, stats.name);
        /* Generate the socket's namespace */
        var namespace = getNamespace(root, stats.name, config.basedir);<commit_msg>Removed excessive logging<commit_after>'use strict';

var type = require('type-of-is');
var io = require('socket.io');
var path = require('path');
var walk = require('walk');

function getRelativeName(root, name, basedir) {
  return path.normalize(path.join(root, path.basename(name, '.js')).replace(basedir, ''));
}

function getNamespace(root, name, basedir) {
  return getRelativeName(root, name, basedir).
  replace(/index/gi, '/').
  replace(/\\+|\/+/g, '/');
}

function getPath(root, name) {
  return path.normalize(path.join(root, name));
}

var debug = function () {};

module.exports = {

  io: null,

  modules: {},

  of: function (namespace) {
    namespace = ('/' + (namespace || '')).replace(/\/+/gi, '/');

    try {
      return this.modules[namespace];
    } catch (ex) {
      throw new Error("Socket module [" + namespace + "] is not registered!");
    }
  },

  init: function (config, callback) {
    var self = this;

    self.io = io(config.server);

    if (type.is(config.debug, Function)) {
      debug = config.debug;
    } else if (type.is(config.debug, Boolean) && config.debug) {
      debug = console.log;
    }

    /* Initialize socket modules (*.js) on the basedir folder */
    var walker = walk.walk(config.basedir);

    walker.on('file', function (root, stats, next) {
      if (path.extname(stats.name) === '.js') {
        /* Get file's path */
        var file = getPath(root, stats.name);
        /* Generate the socket's namespace */
        var namespace = getNamespace(root, stats.name, config.basedir);
{'fraction_non_alphanumeric': 0.18097373478539397, 'fraction_numerical': 0.0, 'mean_word_length': 3.0984251968503935, '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': '561350', 'n_tokens_mistral': 1010, 'n_tokens_neox': 982, 'n_words': 243}