Comparing version 6.0.3 to 6.1.0
12
index.js
const assert = require('assert') | ||
const sliced = require('sliced') | ||
const trie = require('./trie') | ||
@@ -43,8 +44,15 @@ | ||
assert.notEqual(route, undefined, "'route' must be defined") | ||
const args = sliced(arguments) | ||
const node = _trie.match(route) | ||
if (node && node.cb) return node.cb(node.params) | ||
if (node && node.cb) { | ||
args[0] = node.params | ||
return node.cb.apply(null, args) | ||
} | ||
const dft = _trie.match(_default) | ||
if (dft && dft.cb) return dft.cb(dft.params) | ||
if (dft && dft.cb) { | ||
args[0] = dft.params | ||
return dft.cb.apply(null, args) | ||
} | ||
@@ -51,0 +59,0 @@ throw new Error("route '" + route + "' did not match") |
{ | ||
"name": "wayfarer", | ||
"version": "6.0.3", | ||
"version": "6.1.0", | ||
"description": "Composable trie based router", | ||
@@ -28,2 +28,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"sliced": "^1.0.1", | ||
"xtend": "^4.0.1" | ||
@@ -30,0 +31,0 @@ }, |
@@ -57,3 +57,3 @@ # wayfarer [![stability][0]][1] | ||
### router.on(route, cb(params)) | ||
### router.on(route, cb(params, [arg1, ...])) | ||
Register a new route. The order in which routes are registered does not matter. | ||
@@ -63,5 +63,6 @@ Routes can register multiple callbacks. The callback can return values when | ||
### val = router(route) | ||
### val = router(route, [arg1, ...]) | ||
Match a route and execute the corresponding callback. Alias: `router.emit()`. | ||
Returns a values from the matched route (e.g. useful for streams). | ||
Returns a values from the matched route (e.g. useful for streams). Any | ||
additional values will be passed to the matched route. | ||
@@ -68,0 +69,0 @@ ## Internals |
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
12303
142
119
2
+ Addedsliced@^1.0.1
+ Addedsliced@1.0.1(transitive)