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.0.0 to 1.0.1

2

package.json
{
"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)

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