Comparing version 6.6.3 to 6.6.4
11
index.js
@@ -24,10 +24,11 @@ var assert = require('assert') | ||
// (str, fn) -> obj | ||
function on (route, cb) { | ||
function on (route, fn) { | ||
assert.equal(typeof route, 'string') | ||
assert.equal(typeof cb, 'function') | ||
assert.equal(typeof fn, 'function') | ||
var cb = fn._wayfarer && fn._trie ? fn : proxy | ||
route = route || '/' | ||
cb.route = route | ||
if (cb && cb._wayfarer && cb._trie) { | ||
if (cb._wayfarer && cb._trie) { | ||
_trie.mount(route, cb._trie.trie) | ||
@@ -40,2 +41,6 @@ } else { | ||
return emit | ||
function proxy () { | ||
return fn.apply(this, Array.prototype.slice.call(arguments)) | ||
} | ||
} | ||
@@ -42,0 +47,0 @@ |
{ | ||
"name": "wayfarer", | ||
"version": "6.6.3", | ||
"version": "6.6.4", | ||
"description": "Composable trie based router", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -344,2 +344,16 @@ var wayfarer = require('../') | ||
}) | ||
t.test('should not mutate callback parameter', function (t) { | ||
t.plan(4) | ||
var r = wayfarer() | ||
var routes = ['/foo', '/bar'] | ||
r.on('/foo', callback) | ||
r.on('/bar', callback) | ||
r('/foo') | ||
r('/bar') | ||
function callback () { | ||
t.notEqual(this, callback, 'callback was proxied') | ||
t.equal(this.route, routes.shift(), 'proxy exposes route property') | ||
} | ||
}) | ||
}) |
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
31054
695