<commit_before>import { routes } from './config-routes.js'
import { connect } from 'react-redux'

export const path = Object.keys(routes).reduce((mapping, route) => {
  mapping[route] = routes[route].pattern
  return mapping
}, {})

export const paramsToProps = Object.keys(routes).reduce((mapping, route) => {
  mapping[routes[route].pattern] = (state, { routeParams }) => 
    routes[route].paramsToProps(state, routeParams)
  return mapping
}, {})

export const uriToLink = Object.keys(routes).reduce((mapping, route) => {
  mapping[route] = routes[route].uriToLink
  return mapping
}, {})

export const connectFromRoute = (...args) => connect(
  (state, ownProps) => {
    const mapRoute = paramsToProps[ownProps.route.path]
    //TODO warning if no mapping is found for the route (because it fails
    //silently but it can hide an error)
    return mapRoute ? mapRoute(state, ownProps) : {}
  })(...args)



<commit_msg>Throw error where no mapping was found for a route<commit_after>import { routes } from './config-routes.js'
import { connect } from 'react-redux'

export const path = Object.keys(routes).reduce((mapping, route) => {
  mapping[route] = routes[route].pattern
  return mapping
}, {})

export const paramsToProps = Object.keys(routes).reduce((mapping, route) => {
  mapping[routes[route].pattern] = (state, { routeParams }) => 
    routes[route].paramsToProps(state, routeParams)
  return mapping
}, {})

export const uriToLink = Object.keys(routes).reduce((mapping, route) => {
  mapping[route] = routes[route].uriToLink
  return mapping
}, {})

export const connectFromRoute = (...args) => connect(
  (state, ownProps) => {
    const mapRoute = paramsToProps[ownProps.route.path]
    if (mapRoute === undefined) throw new ReferenceError(
      `Mapping for route \`${ownProps.route.path}\`is missing`
    )
    return mapRoute ? mapRoute(state, ownProps) : {}
  })(...args)




{'fraction_non_alphanumeric': 0.15149921094160967, 'fraction_numerical': 0.0, 'mean_word_length': 4.239669421487603, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '4496748', 'n_tokens_mistral': 571, 'n_tokens_neox': 579, 'n_words': 146}