pick-path
Rather simple route picking tool
API
<Value>(path: string, routes: Routes<Value>) => Match<Value>
Example
import pickPath from 'pick-path'
import { Home, About, AboutTeam, AboutMission, Item, NotFound } from './pages'
const { pattern, value, params } = pickPath('/item/10', {
'/': Home,
'/about/': { // must have trailing `/`
// nested routes object (infinite nesting possible)
'/': About,
'/team': AboutTeam,
},
'/about/mission': AboutMission
'/item/:id': Item
// '*': NotFound // https://github.com/mightyiam/pick-path/issues/10
});
pattern // '/item/:id'
value // Item
params // ['10']