# path-handler-map

> > A path to handler map, base on [radix tree](http://en.wikipedia.org/wiki/Radix_tree).

Latest version **2.3.2** (published 2017-06-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install path-handler-map
pnpm add path-handler-map
yarn add path-handler-map
bun add path-handler-map
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.3.2 |
| Published | 2017-06-24 |
| First published | 2017-03-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | jKey Lu |
| Maintainers | jkeylu |
| Keywords | express, koa, route, routing |

## Links

- npm: https://www.npmjs.com/package/path-handler-map
- Repository: https://github.com/jkeylu/path-handler-map
- Homepage: https://github.com/jkeylu/path-handler-map#readme
- Issues: https://github.com/jkeylu/path-handler-map/issues
- npm.io page: https://npm.io/package/path-handler-map

## Alternatives

- [express-promise-router](https://npm.io/package/express-promise-router.md) — 736.1K weekly downloads
- [next-usequerystate](https://npm.io/package/next-usequerystate.md) — 29.8K weekly downloads
- [@bitkyc08/opencodex](https://npm.io/package/@bitkyc08/opencodex.md) — 4.6K weekly downloads
- [lynkr](https://npm.io/package/lynkr.md) — 575 weekly downloads
- [baremetal.js](https://npm.io/package/baremetal.js.md) — 42 weekly downloads

## Recent versions

- 2.3.2 (latest) — 2017-06-24
- 2.3.1 — 2017-06-11
- 2.3.0 — 2017-06-07
- 2.2.0 — 2017-05-31
- 2.1.0 — 2017-05-28
- 2.0.1 — 2017-05-24
- 2.0.0 — 2017-05-23
- 1.0.0 — 2017-03-17

## README

# path-handler-map

> A path to handler map, base on [radix tree](http://en.wikipedia.org/wiki/Radix_tree).

## Installation

```
npm install path-handler-map
```

## Usage

```
import { PathHandlerMap } from 'path-handler-map';

let m = new PathHandlerMap();
m.add('/user', 'GET', () => { });
m.add('/post/:post_id', 'GET', () => { });

let r = m.find('GET', '/post/234');
```

## Pattern Rule

| Syntax | Description |
|--------|-------------|
| `:name` | named param |
| `:` | unnamed param |
| `:name*` or `*name` | named catch-all param |
| `:*` or `*` | unnamed catch-all param |

- Named parameters and unnamed parameters match anything until the next '/' or the path end.
- Named catch-all param and unnamed catch-all param match anything until the path end.

## Path matching order

- Static
- Param
- Match any

## Examples

```
/api/*
/api/users/:user_name
/api/users/popular
```

Above routes would resolve in the following order:

- `/api/users/popular`
- `/api/users/:user_name`
- `/api/*`

## Inspired by

- [Echo](https://github.com/labstack/echo)
- [trek-router](https://github.com/trekjs/router)

## License

MIT

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