<commit_before>
var router = require('routington')
var assert = require('assert')

var wayfarer = Wayfarer.prototype

module.exports = Wayfarer

// Create a new router.
// @param  {Object} opts
//   @prop {String} default
// @return {Object}
function Wayfarer(opts) {
  if (!(this instanceof Wayfarer)) return new Wayfarer(opts)
  opts = opts || {}
  this.router = router()
  this.defaultPath = opts.default || ''
}

// Define a new path.
// @param {String} path
// @param {Function} cb
// @return {Wayfarer}
wayfarer.on = function(path, cb) {
  assert('string' == typeof path, 'Path should be a string')
  assert('function' == typeof cb, 'Callback should be a function')
  var node = this.router.define(path)[0]
  node.cb = cb

  return this
}

// Math a route against the paths.
// @param {String} path
// @return {Any}
// @api public
wayfarer.match = function(path) {
  assert('string' == typeof path, 'Path should be a string')

  var nw = path.split('?')[0]
  var match = this.router.match(nw)
  if (!match) match = this.router.match(this.defaultPath)

  return match.node.cb(match.param);
}

// Aliases.
wayfarer.path = wayfarer.on
wayfarer.route = wayfarer.on<commit_msg>resolve: fishrock123/master<commit_after>
var router = require('routington')
var assert = require('assert')

var wayfarer = Wayfarer.prototype

module.exports = Wayfarer

// Create a new router.
// @param  {Object} opts
//   @prop {String} default
// @return {Object}
function Wayfarer(opts) {
  if (!(this instanceof Wayfarer)) return new Wayfarer(opts)
  opts = opts || {}
  this.router = router()
  this.defaultPath = opts.default || ''
}

// Define a new path.
// @param {String} path
// @param {Function} cb
// @return {Wayfarer}
wayfarer.on = function(path, cb) {
  assert('string' == typeof path, 'Path should be a string')
  assert('function' == typeof cb, 'Callback should be a function')
  var node = this.router.define(path)[0]
  node.cb = cb

  return this
}

// Math a route against the paths.
// @param {String} path
// @return {Any}
// @api public
wayfarer.match = function(path) {
  assert('string' == typeof path, 'Path should be a string')

  var nw = path.split('?')[0]
  var match = this.router.match(nw)
  if (!match) match = this.router.match(this.defaultPath)

  return match.node.cb(match ? match.param : {})
}

// Aliases.
wayfarer.path = wayfarer.on
wayfarer.route = wayfarer.on
{'fraction_non_alphanumeric': 0.15575146935348447, 'fraction_numerical': 0.002938706968933669, 'mean_word_length': 3.681728880157171, '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': '3759492', 'n_tokens_mistral': 812, 'n_tokens_neox': 800, 'n_words': 235}