Comparing version 3.0.3 to 3.1.0
21
index.js
@@ -1,3 +0,3 @@ | ||
const routington = require('routington') | ||
const assert = require('assert') | ||
var routington = require('routington') | ||
var assert = require('assert') | ||
@@ -10,6 +10,7 @@ module.exports = wayfarer | ||
dft = dft || '' | ||
const router = routington() | ||
var router = routington() | ||
emit.emit = emit | ||
emit.on = on | ||
emit.match = match | ||
@@ -23,3 +24,3 @@ return emit | ||
assert.equal(typeof cb, 'function') | ||
const node = router.define(path)[0] | ||
var node = router.define(path)[0] | ||
node.cb = cb | ||
@@ -29,9 +30,15 @@ return emit | ||
// match a route | ||
// match and call a route | ||
// str -> null | ||
function emit (path) { | ||
path = path || '' | ||
const match = router.match(path) || router.match(dft) | ||
match.node.cb(path, match ? match.param : {}) | ||
var matched = match(path) | ||
if (matched) matched.node.cb(path, matched.param) | ||
} | ||
// match and return route | ||
// str -> obj | ||
function match (path) { | ||
return router.match(path) || router.match(dft) | ||
} | ||
} |
{ | ||
"name": "wayfarer", | ||
"version": "3.0.3", | ||
"version": "3.1.0", | ||
"description": "Composable trie based router", | ||
@@ -33,2 +33,3 @@ "main": "index.js", | ||
"mocha": "^1.20.1", | ||
"standard": "^4.0.1", | ||
"tape": "^3.0.3" | ||
@@ -35,0 +36,0 @@ }, |
@@ -59,2 +59,5 @@ # wayfarer | ||
### router.match(route) | ||
Match and return a route without executing the corresponding callback. | ||
## Why? | ||
@@ -61,0 +64,0 @@ Routers like [react-router](https://github.com/rackt/react-router) are |
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
5501
34
86
4