Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "wayfarer", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A simple router built for minimalism and speed", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# wayfarer | ||
[![NPM version][npm-image]][npm-url] [![build status][travis-image]][travis-url] [![Test coverage][coveralls-image]][coveralls-url] | ||
A simple router built for minimalism and speed. Works best with | ||
[React](facebook.github.io/react) and Browserify(github.com/substack/browserify). | ||
A simple trie based router built for minimalism and speed. Works best with | ||
[React](facebook.github.io/react) and [Browserify](github.com/substack/browserify). | ||
@@ -12,7 +12,15 @@ ## Installation | ||
## API | ||
## Overview | ||
```js | ||
/** | ||
* Initialize wayfarer. | ||
*/ | ||
var wayfarer = require('wayfarer'); | ||
var router = wayfarer(); | ||
/** | ||
* Register routes. | ||
*/ | ||
router | ||
@@ -23,4 +31,29 @@ .path('/', function() {console.log('/')}) | ||
.path('/:user', function() {console.log('/user')}); | ||
/** | ||
* Match a route. | ||
*/ | ||
router.match('/tobi') | ||
// => '/user' | ||
``` | ||
## API | ||
#### .path() | ||
Register a new path. Takes a `{String} pathName` that calls a `{Function} callback`. | ||
Partial paths are supported through the `/:` operator. Wayfarer uses a trie | ||
to match routes, so the order in which routes are registered does not matter. | ||
```js | ||
router.path('/', function() {console.log('do stuff')}); | ||
router.path('/:user', function() {console.log('do user stuff')}); | ||
``` | ||
#### .match() | ||
Match a `{String} path` against the saved paths in the router. If a match is found | ||
the registered callback will be executed. | ||
```js | ||
router.match('/tobi'); | ||
// => 'do user stuff' | ||
``` | ||
## License | ||
@@ -27,0 +60,0 @@ [MIT](https://tldrlegal.com/license/mit-license) © [Yoshua Wuyts](i@yoshuawuyts.com) |
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
5425
65