Skip to content

Commit

Permalink
Merge a01eb70 into ff25c87
Browse files Browse the repository at this point in the history
  • Loading branch information
rook2pawn committed Apr 23, 2018
2 parents ff25c87 + a01eb70 commit 3cd6493
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@ var trie = require('./trie')

module.exports = Wayfarer

const clone = function (fn) {
var cloneObj = fn
if (cloneObj.__isClone) {
cloneObj = cloneObj.__clonedFrom
}

var temp = function () { return cloneObj.apply(fn, arguments) }
Object.assign(temp, fn)

temp.__isClone = true
temp.__clonedFrom = cloneObj

return temp
}

// create a router
// str -> obj
function Wayfarer (dft) {
Expand Down Expand Up @@ -33,7 +48,7 @@ function Wayfarer (dft) {
_trie.mount(route, cb._trie.trie)
} else {
var node = _trie.create(route)
node.cb = cb
node.cb = clone(cb)
}

return emit
Expand Down

0 comments on commit 3cd6493

Please sign in to comment.