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.1 to 1.1.2

2

package.json
{
"name": "wayfarer",
"version": "1.1.1",
"version": "1.1.2",
"description": "A simple router built for minimalism and speed",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -15,12 +15,6 @@ # wayfarer

```js
/**
* Initialize wayfarer.
*/
var wayfarer = require('wayfarer');
var router = wayfarer();
/**
* Register routes.
*/
// Register routes.

@@ -34,5 +28,3 @@ router

/**
* Match a route.
*/
// Match a route.

@@ -44,9 +36,7 @@ router.match('/tobi')

## API
#### .path()
#### .path(path, cb)
Register a new path. 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')});

@@ -56,7 +46,6 @@ router.path('/:user', function() {console.log('do user stuff')});

#### .default()
#### .default(defaultPath)
Sets a default path to match. This is particularly
useful for setting 404 pages.
```js
// Set a {String} pathName as the default path to match. This is particularly
// useful for setting 404 pages.
router.default('/404');

@@ -66,7 +55,6 @@ router.path('/404', function() {console.log('sunglasses not found')});

#### .match()
#### .match(path)
Match a 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');

@@ -73,0 +61,0 @@ // => 'do user stuff'

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