# location-info

> Get custom information about a location object or path.

Latest version **5.1.6** (published 2019-07-23) · ISC license · 0 weekly downloads

## Install

```sh
npm install location-info
pnpm add location-info
yarn add location-info
bun add location-info
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.1.6 |
| Published | 2019-07-23 |
| First published | 2016-02-03 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 47.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Kai Curry |
| Maintainers | kaicurry |
| Keywords | router, path, location |

## Links

- npm: https://www.npmjs.com/package/location-info
- Repository: https://github.com/cape-io/location-info
- Homepage: https://github.com/cape-io/location-info#readme
- Issues: https://github.com/cape-io/location-info/issues
- npm.io page: https://npm.io/package/location-info

## Dependencies (7)

- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [prairie](https://npm.io/package/prairie.md) ^3.9.2
- [reselect](https://npm.io/package/reselect.md) ^4.0.0
- [cape-redux](https://npm.io/package/cape-redux.md) ^3.3.1
- [understory](https://npm.io/package/understory.md) ^1.7.1
- [cape-select](https://npm.io/package/cape-select.md) ^3.1.2
- [url-pattern](https://npm.io/package/url-pattern.md) ^1.0.3

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 5.1.6 (latest) — 2019-07-23
- 5.1.5 — 2019-07-11
- 5.1.4 — 2019-07-11
- 5.1.3 — 2019-07-11
- 5.1.2 — 2019-07-11
- 5.1.1 — 2019-07-11
- 5.1.0 — 2019-01-11
- 5.0.1 — 2019-01-10
- 5.0.0 — 2019-01-10
- 4.5.0 — 2017-08-22
- 4.4.0 — 2017-08-11
- 4.2.0 — 2017-07-28
- 4.1.2 — 2017-07-28
- 4.1.1 — 2017-07-12
- 4.1.0 — 2017-07-10
- … 12 more at https://npm.io/package/location-info/versions

## README

# location-info

Sometimes you want to parse a string into a meaningful object. The [url-pattern](https://github.com/snd/url-pattern) module does a decent job this. But what or how do you combine a bunch of possibilities together? This module enables you to build out a collection of parsing possibilities that a string can be matched against. Typically it's used for routing, but it could be used for anything.

Route possibilities are created with Redux actions and stored in state. A selector is used to build out the index and allow deciding what route a string belongs to.
Set and get custom information about a location object or string path.

The library forces creating a unique key/id for each route. The route info index with redux actions.

```javascript
import { combineReducers, createStore } from 'redux'
import locInfo, { addRoute, addRoutes, findRoute, getInitState, select } from 'location-info'

// If not otherwise saved in a database/persistent store...
const routeActions = [
  addRoutes({
    home: '/',
    about: '/about',
    member: '/home-drawer/:id',
    image: '/image-upload',
  }),
  addRoute('dat', '/feed/me'),
  addRoute({
    id: 'me', // Ignored because `routeId` has priority.
    routeId: 'user',
    routePattern: '/user/:userId',
    userId: 1,  // Ignored.
    name: 'Profile',  // Ignored.
  }),
  // Alternative to above: addRoute('user', '/user/:userId')
  addRoutes(['foo', 'bar']),
  addRoute({
    id: 'detail',
    pattern: '/detail/:id',
  }),
]
export const reducer = combineReducers({ locInfo })
export const initState = { locInfo: getInitState(routeActions) }
export const store = createStore(reducer, initState)

export const locationDetails = findRoute(selectRoutes(state), '/detail/vroom')

```

Note that no care is taken to enforce match order. Post an issue if you need it.

## Actions

* `addRoute(idOrObj, pattern = null, props = {})`
* addRoutes()
* delRoute()
* updateRoute()

---
_Source: https://npm.io/package/location-info · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
