Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wayfarer

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wayfarer - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

2

package.json
{
"name": "wayfarer",
"version": "1.1.0",
"version": "1.1.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 [trie based](https://github.com/jonathanong/routington/)
router built for minimalism and speed. Works best with
A simple [trie based](https://github.com/jonathanong/routington/)
router built for minimalism and speed. Works best with
[React](facebook.github.io/react) and [Browserify](github.com/substack/browserify).

@@ -27,2 +27,3 @@

router
.default('/404')
.path('/', function() {console.log('/')})

@@ -43,6 +44,8 @@ .path('/home', function() {console.log('/home')})

#### .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
// 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.
router.path('/', function() {console.log('do stuff')});

@@ -52,6 +55,16 @@ router.path('/:user', function() {console.log('do user stuff')});

#### .default()
```js
// Set a {String} pathName as the default path to match. This is particularly
// useful for setting 404 pages.
router.default('/404');
router.path('/404', function() {console.log('sunglasses not found')});
```
#### .match()
Match a `{String} path` against the saved paths in the router. If a match is found
the registered callback will be executed.
```js
// Match a {String} path against the saved paths in the router. If a match is
// found the registered callback will be executed.
router.match('/tobi');

@@ -62,9 +75,10 @@ // => 'do user stuff'

## License
[MIT](https://tldrlegal.com/license/mit-license) © [Yoshua Wuyts](i@yoshuawuyts.com)
[MIT](https://tldrlegal.com/license/mit-license) ©
[Yoshua Wuyts](i@yoshuawuyts.com)
[npm-image]: https://img.shields.io/npm/v/wayfarer.svg?style=flat
[npm-image]: https://img.shields.io/npm/v/wayfarer.svg?style=flat-square
[npm-url]: https://npmjs.org/package/wayfarer
[travis-image]: https://img.shields.io/travis/yoshuawuyts/wayfarer.svg?style=flat
[travis-image]: https://img.shields.io/travis/yoshuawuyts/wayfarer.svg?style=flat-square
[travis-url]: https://travis-ci.org/yoshuawuyts/wayfarer
[coveralls-image]: https://img.shields.io/coveralls/yoshuawuyts/wayfarer.svg?style=flat
[coveralls-url]: https://coveralls.io/r/yoshuawuyts/wayfarer?branch=master
[coveralls-image]: https://img.shields.io/coveralls/yoshuawuyts/wayfarer.svg?style=flat-square
[coveralls-url]: https://coveralls.io/r/yoshuawuyts/wayfarer?branch=master
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc