<commit_before>import pathToRegExp from 'path-to-regexp';
import { _castString, $isArray, $isFunction, $isString, $isObject } from 'core/types';
import { $exec } from 'core/core';
import { parseLocation } from 'routes/location';
import Handler from 'routes/route-handler';
import { getRouteMap, mapRoutes, resetRouteMap } from 'routes/route-map';
import History from './routes/history';

let _history = new History();

/**
 * Set base configurations for router
 *
 * @param {Object} config
 */
function router(config = {}) {
	return router;
}

/**
 * Add a filter or array of filters to internal filter registry
 *
 * @param {string|Array} name
 * @param {Function} [callback]
 */
router.addFilter = function addFilter(name, callback) {
	if ($isObject(name)) {
		_addFilters(name);
	} else {
		_addFilter(name, callback)
	}

	return this;
}

/**
 * Retrieve current route
 *
 * @returns {Object}
 */
router.currentRoute = function currentRoute() {
	return _history.current;
}

/**
 * Return all registered filters
 *
 * @returns {Object}
 */
router.filters = function filters() {
	return _filters;
}

// TODO: Change map to register
/**
 * Register routes
 *
 * @param {Array} routes
 * @returns {Object}
 */
router.map = function routerMap(routes) {
	mapRoutes(routes);

	// Ensure we are on the current URL/evaluate routes
	_history.navigate(this.uri().full);

	return this;
}

/**
 * Reset all routes and filters - mainly for testing purposes
 */
router.reset = function reset() {
	resetRouteMap();
}

/**
 * Retrieve all routes or specific route by name/path
 *
 * @param {string} [value]
 * @param {string} keyType
 * @returns {Object|Array}
 */
router.routes = function routes(key, keyType = 'path') {
	let routeMaps = getRouteMap();
	let map;

	if (key && routeMaps.pathMap[key]) {
		return routeMaps.pathMap[key];
	} else if (key && routeMaps.nameMap[key]) {
		return routeMaps.nameMap[key];
	}

	if (keyType === 'path') {
		map = routeMaps.pathMap;<commit_msg>Remove unused functions and dependencies from wee-routes<commit_after>import { parseLocation } from 'routes/location';
import Handler from 'routes/route-handler';
import { getRouteMap, mapRoutes, resetRouteMap } from 'routes/route-map';
import History from './routes/history';

let _history = new History();

/**
 * Set base configurations for router
 *
 * @param {Object} config
 */
function router(config = {}) {
	return router;
}

/**
 * Retrieve current route
 *
 * @returns {Object}
 */
router.currentRoute = function currentRoute() {
	return _history.current;
}

// TODO: Change map to register
/**
 * Register routes
 *
 * @param {Array} routes
 * @returns {Object}
 */
router.map = function routerMap(routes) {
	mapRoutes(routes);

	// Ensure we are on the current URL/evaluate routes
	_history.navigate(this.uri().full);

	return this;
}

/**
 * Reset all routes - mainly for testing purposes
 */
router.reset = function reset() {
	resetRouteMap();
}

/**
 * Retrieve all routes or specific route by name/path
 *
 * @param {string} [value]
 * @param {string} keyType
 * @returns {Object|Array}
 */
router.routes = function routes(key, keyType = 'path') {
	let routeMaps = getRouteMap();
	let map;

	if (key && routeMaps.pathMap[key]) {
		return routeMaps.pathMap[key];
	} else if (key && routeMaps.nameMap[key]) {
		return routeMaps.nameMap[key];
	}

	if (keyType === 'path') {
		map = routeMaps.pathMap;
{'fraction_non_alphanumeric': 0.14370195150798346, 'fraction_numerical': 0.0, 'mean_word_length': 4.094879518072289, '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': '1267270', 'n_tokens_mistral': 1089, 'n_tokens_neox': 1087, 'n_words': 311}