Socket
Socket
Sign inDemoInstall

wayfarer

Package Overview
Dependencies
Maintainers
30
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 6.6.4 to 7.0.0

13

index.js

@@ -24,9 +24,7 @@ var assert = require('assert')

// (str, fn) -> obj
function on (route, fn) {
function on (route, cb) {
assert.equal(typeof route, 'string')
assert.equal(typeof fn, 'function')
assert.equal(typeof cb, 'function')
var cb = fn._wayfarer && fn._trie ? fn : proxy
route = route || '/'
cb.route = route

@@ -38,9 +36,6 @@ if (cb._wayfarer && cb._trie) {

node.cb = cb
node.route = route
}
return emit
function proxy () {
return fn.apply(this, Array.prototype.slice.call(arguments))
}
}

@@ -76,5 +71,5 @@

this.cb = matched.cb
this.route = matched.cb.route
this.route = matched.route
this.params = matched.params
}
}
{
"name": "wayfarer",
"version": "6.6.4",
"version": "7.0.0",
"description": "Composable trie based router",

@@ -27,5 +27,3 @@ "main": "index.js",

"license": "MIT",
"dependencies": {
"xtend": "^4.0.1"
},
"dependencies": {},
"devDependencies": {

@@ -32,0 +30,0 @@ "istanbul": "^0.4.5",

@@ -339,4 +339,11 @@ var wayfarer = require('../')

var r = wayfarer()
r.on('/foo', function () {
t.equal(this.route, '/foo', 'exposes route property')
r.on('/foo', function () {})
t.equal(r.match('/foo').route, '/foo', 'exposes route property')
})
t.test('should be called with self', function (t) {
t.plan(1)
var r = wayfarer()
r.on('/foo', function callback () {
t.equal(this, callback, 'calling context is self')
})

@@ -346,4 +353,4 @@ r('/foo')

t.test('should not mutate callback parameter', function (t) {
t.plan(4)
t.test('can register callback on many routes', function (t) {
t.plan(6)
var r = wayfarer()

@@ -353,9 +360,12 @@ var routes = ['/foo', '/bar']

r.on('/bar', callback)
r('/foo')
r('/bar')
for (var i = 0, len = routes.length, matched; i < len; i++) {
matched = r.match(routes[i])
t.equal(matched.cb, callback, 'matched callback is same')
t.equal(matched.route, routes[i], 'matched route is same')
r(routes[i])
}
function callback () {
t.notEqual(this, callback, 'callback was proxied')
t.equal(this.route, routes.shift(), 'proxy exposes route property')
t.equal(this, callback, 'calling context is same')
}
})
})

@@ -1,4 +0,2 @@

var mutate = require('xtend/mutable')
var assert = require('assert')
var xtend = require('xtend')

@@ -16,3 +14,3 @@ module.exports = Trie

// and return a node
// str -> null
// str -> obj
Trie.prototype.create = function (route) {

@@ -100,3 +98,3 @@ assert.equal(typeof route, 'string', 'route should be a string')

if (!node) return undefined
node = xtend(node)
node = Object.assign({}, node)
node.params = params

@@ -125,3 +123,3 @@ return node

mutate(node.nodes, trie.nodes)
Object.assign(node.nodes, trie.nodes)
if (trie.name) node.name = trie.name

@@ -136,5 +134,5 @@

})
mutate(node.nodes, node.nodes[''].nodes)
Object.assign(node.nodes, node.nodes[''].nodes)
delete node.nodes[''].nodes
}
}

Sorry, the diff of this file is not supported yet

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