multi-path-matcher
Advanced tools
Comparing version 1.2.0 to 1.3.0
{ | ||
"name": "multi-path-matcher", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"type": "module", | ||
@@ -10,4 +10,7 @@ "publishConfig": { | ||
"module": "src/multi-path-matcher.mjs", | ||
"description": "finds and decodes best matching path", | ||
"keywords": [], | ||
"description": "finds and decodes best matching path in a set of routes", | ||
"keywords": [ | ||
"router", | ||
"routing" | ||
], | ||
"contributors": [ | ||
@@ -14,0 +17,0 @@ { |
@@ -17,6 +17,27 @@ [![npm](https://img.shields.io/npm/v/multi-path-matcher.svg)](https://www.npmjs.com/package/multi-path-matcher) | ||
finds and decodes best matching path | ||
finds and decodes best matching path in a set of routes | ||
# usage | ||
```js | ||
import { compile, matcher } from "multi-path-matcher"; | ||
const routes = [ | ||
{ path: "/a/b/c" }, | ||
{ path: "/a/b" }, | ||
{ path: "/d/:att1/e/:att2" }, | ||
{ path: "/d/:att1/e" }, | ||
{ path: "/" } | ||
]; | ||
const compiled = compile(routes); | ||
matcher(compiled "/a"); // undefined | ||
matcher(compiled, "/a/b"); // routes[1] | ||
matcher(compiled, "/a/b/c"); // routes[0] | ||
matcher(compiled, "/d/value1/e"); // routes[3] { att1: "value1" } | ||
matcher(compileds, "/d/value1/e/value2"); // routes[2] { att1: "value1", att2: "value2" } | ||
matcher(macro, routes, "/"); // routes[4] | ||
``` | ||
# API | ||
@@ -28,11 +49,17 @@ | ||
- [CompiledRoutes](#compiledroutes) | ||
- [Route](#route) | ||
- [Properties](#properties) | ||
- [Match](#match) | ||
- [Properties](#properties-1) | ||
- [compile](#compile) | ||
- [Parameters](#parameters) | ||
- [matcher](#matcher) | ||
- [Parameters](#parameters-1) | ||
- [multi-path-matcher](#multi-path-matcher) | ||
- [usage](#usage) | ||
- [API](#api) | ||
- [Table of Contents](#table-of-contents) | ||
- [CompiledRoutes](#compiledroutes) | ||
- [Route](#route) | ||
- [Properties](#properties) | ||
- [Match](#match) | ||
- [Properties](#properties-1) | ||
- [compile](#compile) | ||
- [Parameters](#parameters) | ||
- [matcher](#matcher) | ||
- [Parameters](#parameters-1) | ||
- [install](#install) | ||
- [license](#license) | ||
@@ -63,8 +90,8 @@ ## CompiledRoutes | ||
- `route` **[Route](#route)** | ||
- `params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** | ||
- `route` **[Route](#route)** as given to the compiler | ||
- `params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** extracted from the path | ||
## compile | ||
compile a set of routes | ||
Compile a set of routes | ||
@@ -75,6 +102,8 @@ ### Parameters | ||
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** | ||
Returns **[CompiledRoutes](#compiledroutes)** | ||
## matcher | ||
Find best match for a given path | ||
### Parameters | ||
@@ -81,0 +110,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8641
123