<commit_before>var EventEmitter = require('events').EventEmitter,
  path = require('path'),
  _ = require('underscore'),
  store = {},
  Route = new EventEmitter();

var format = Route.format = function(str){
  if (str.substr(0, 1) === '/') str = str.substring(1);

  var last = str.substr(str.length - 1, 1);
  if (!last || last === '/') str += 'index.html';

  return str;
};

Route.get = function(source){
  return store[format(source)];
};

Route.set = function(source, callback){
  source = format(source);

  if (_.isFunction(callback)){
    store[source] = function(func){
      callback(function(err, content){
        value = content;
        func(err, content, source);
        Route.emit('change', source, content);
      });
    };
  } else {
    store[source] = function(func){
      func(null, callback, source);
    };

    Route.emit('change', source, callback);
  }
};

Route.destroy = function(source){
  source = format(source);
  delete store[source];

  Route.emit('change', source, null);
  Route.emit('destroy', source);
};

Route.list = function(){
  return store;
};

Route.clear = function(){
  store = {};
};

module.exports = Route;<commit_msg>Simplify route.set<commit_after>var EventEmitter = require('events').EventEmitter,
  path = require('path'),
  _ = require('underscore'),
  store = {},
  Route = new EventEmitter();

var format = Route.format = function(str){
  if (str.substr(0, 1) === '/') str = str.substring(1);

  var last = str.substr(str.length - 1, 1);
  if (!last || last === '/') str += 'index.html';

  return str;
};

Route.get = function(source){
  return store[format(source)];
};

Route.set = function(source, callback){
  source = format(source);

  if (_.isFunction(callback)){
    store[source] = callback;
  } else {
    store[source] = function(fn){
      fn(null, callback, source);
    };
  }
};

Route.destroy = function(source){
  source = format(source);
  delete store[source];
};

Route.list = function(){
  return store;
};

Route.clear = function(){
  store = {};
};

module.exports = Route;
{'fraction_non_alphanumeric': 0.1870748299319728, 'fraction_numerical': 0.004859086491739553, 'mean_word_length': 3.6373873873873874, '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': '6833021', 'n_tokens_mistral': 674, 'n_tokens_neox': 658, 'n_words': 148}