{"_id":"@arve.knudsen/wayfarer","_rev":"8-db63c03d6f2a371fb3236231e315ed47","name":"@arve.knudsen/wayfarer","description":"Composable trie based router","dist-tags":{"latest":"6.5.0"},"versions":{"6.4.1":{"name":"@arve.knudsen/wayfarer","version":"6.4.1","description":"Composable trie based router","main":"index.js","scripts":{"test":"standard && NODE_ENV=test tape test/*","test-cov":"NODE_ENV=test istanbul cover tape -- test/*"},"repository":{"type":"git","url":"git+https://github.com/aknuds1/wayfarer.git"},"keywords":["router","trie","client","simple","minimal","functional","idempotent","on","event","emitter","react","browserify","browser"],"license":"MIT","dependencies":{"xtend":"^4.0.1"},"devDependencies":{"istanbul":"^0.4.5","mocha":"^3.1.2","noop2":"^2.0.0","standard":"^8.4.0","tape":"^4.6.2"},"files":["LICENSE","index.js","trie.js","walk.js","README.md"],"gitHead":"c538a764aa3e0df4254e844044db67bfad1616ea","bugs":{"url":"https://github.com/aknuds1/wayfarer/issues"},"homepage":"https://github.com/aknuds1/wayfarer#readme","_id":"@arve.knudsen/wayfarer@6.4.1","_shasum":"1621e3782d32d4d500f82c2f26856cf4961e1b2d","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.7.0","_npmUser":{"name":"arve.knudsen","email":"arve.knudsen@gmail.com"},"dist":{"shasum":"1621e3782d32d4d500f82c2f26856cf4961e1b2d","tarball":"https://registry.npmjs.org/@arve.knudsen/wayfarer/-/wayfarer-6.4.1.tgz","integrity":"sha512-AMLTe5yvHr1OAlAGovmyHe+shQVmHccXbde01vAbFAKtSK43QbOGLExO+nf6i+RP0Ax2dqSqwAyhsrLrVYKR6Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCKJV+kZU5tlUUQe0sdzDcGfUlq22hzvzrfUm94vfIajgIgH8Le61/i1CT6nCXH2vzpoWlia3plA/5x2nDcZGPZkQY="}]},"maintainers":[{"name":"arve.knudsen","email":"arve.knudsen@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/wayfarer-6.4.1.tgz_1488466541305_0.574835432227701"}},"6.4.2":{"name":"@arve.knudsen/wayfarer","version":"6.4.2","description":"Composable trie based router","main":"index.js","scripts":{"test":"standard && NODE_ENV=test tape test/*","test-cov":"NODE_ENV=test istanbul cover tape -- test/*"},"repository":{"type":"git","url":"git+https://github.com/aknuds1/wayfarer.git"},"keywords":["router","trie","client","simple","minimal","functional","idempotent","on","event","emitter","react","browserify","browser"],"license":"MIT","dependencies":{"xtend":"^4.0.1"},"devDependencies":{"istanbul":"^0.4.5","mocha":"^3.1.2","noop2":"^2.0.0","standard":"^8.4.0","tape":"^4.6.2"},"files":["LICENSE","index.js","trie.js","walk.js","README.md"],"gitHead":"6708804116bf4ed46c1b2ef7194361cc47277f4e","bugs":{"url":"https://github.com/aknuds1/wayfarer/issues"},"homepage":"https://github.com/aknuds1/wayfarer#readme","_id":"@arve.knudsen/wayfarer@6.4.2","_shasum":"2ef655559fa6e30550629cb52471b3f5817b2842","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.7.0","_npmUser":{"name":"arve.knudsen","email":"arve.knudsen@gmail.com"},"dist":{"shasum":"2ef655559fa6e30550629cb52471b3f5817b2842","tarball":"https://registry.npmjs.org/@arve.knudsen/wayfarer/-/wayfarer-6.4.2.tgz","integrity":"sha512-O9pBtpdEoNDnM08XJfRm3Bwc69BXcr/dgxjpCIANh6MiPFN1sP8wc5y76BpB3RqpDyG153Vd8Vi67fy1Oxry8Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDtS9gAoJtcw5aQ4sXSziMXmuvtb79OfeIGuv7Cz3ZrtAIgZQG9oXfi3SSZkHe905wMenGS9tLYErn5NMU/IKZLWgA="}]},"maintainers":[{"name":"arve.knudsen","email":"arve.knudsen@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/wayfarer-6.4.2.tgz_1488470645705_0.9032767608296126"}},"6.4.3":{"name":"@arve.knudsen/wayfarer","version":"6.4.3","description":"Composable trie based router","main":"index.js","scripts":{"test":"standard && NODE_ENV=test tape test/*","test-cov":"NODE_ENV=test istanbul cover tape -- test/*"},"repository":{"type":"git","url":"git+https://github.com/aknuds1/wayfarer.git"},"keywords":["router","trie","client","simple","minimal","functional","idempotent","on","event","emitter","react","browserify","browser"],"license":"MIT","dependencies":{"xtend":"^4.0.1"},"devDependencies":{"istanbul":"^0.4.5","mocha":"^3.1.2","noop2":"^2.0.0","standard":"^8.4.0","tape":"^4.6.2"},"files":["LICENSE","index.js","trie.js","walk.js","README.md"],"gitHead":"09aca9f3be7494037bf27303aee6aa1da4aed3a9","bugs":{"url":"https://github.com/aknuds1/wayfarer/issues"},"homepage":"https://github.com/aknuds1/wayfarer#readme","_id":"@arve.knudsen/wayfarer@6.4.3","_shasum":"fe1cb03bf8a155cd71a29feab6b94319a450759b","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.7.0","_npmUser":{"name":"arve.knudsen","email":"arve.knudsen@gmail.com"},"dist":{"shasum":"fe1cb03bf8a155cd71a29feab6b94319a450759b","tarball":"https://registry.npmjs.org/@arve.knudsen/wayfarer/-/wayfarer-6.4.3.tgz","integrity":"sha512-JGWg88qz6arrtd87N28WYBivc5PDMyt6ExlxuJvBwZ9jPEg0Ytjm4R8TyRGkSW+PWwtWivS1ILXtWeLgV96oNw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD4AuvdqsUaJ0/N1ur46NRS1yZtkzboOKQBYT8Pn2iSnQIgcG9ZVJZLq3SYmz8b91Jj5dVLR3VpVhC0alEi8l+Abr4="}]},"maintainers":[{"name":"arve.knudsen","email":"arve.knudsen@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/wayfarer-6.4.3.tgz_1488472872769_0.6923109057825059"}},"6.4.4":{"name":"@arve.knudsen/wayfarer","version":"6.4.4","description":"Composable trie based router","main":"index.js","scripts":{"test":"standard && NODE_ENV=test tape test/*","test-cov":"NODE_ENV=test istanbul cover tape -- test/*"},"repository":{"type":"git","url":"git+https://github.com/aknuds1/wayfarer.git"},"keywords":["router","trie","client","simple","minimal","functional","idempotent","on","event","emitter","react","browserify","browser"],"license":"MIT","dependencies":{"xtend":"^4.0.1"},"devDependencies":{"istanbul":"^0.4.5","mocha":"^3.1.2","noop2":"^2.0.0","standard":"^8.4.0","tape":"^4.6.2"},"files":["LICENSE","index.js","trie.js","walk.js","README.md"],"gitHead":"b4e21cefa496213cda02ecd32ffcf25884b90add","bugs":{"url":"https://github.com/aknuds1/wayfarer/issues"},"homepage":"https://github.com/aknuds1/wayfarer#readme","_id":"@arve.knudsen/wayfarer@6.4.4","_shasum":"fff30cb669e3c7874c2eb247dd1841ffeeb2b9d0","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.7.0","_npmUser":{"name":"arve.knudsen","email":"arve.knudsen@gmail.com"},"dist":{"shasum":"fff30cb669e3c7874c2eb247dd1841ffeeb2b9d0","tarball":"https://registry.npmjs.org/@arve.knudsen/wayfarer/-/wayfarer-6.4.4.tgz","integrity":"sha512-GtHrmj/jxbWhstPcj8IDOkUHUpeKKFYQ88oBGM4l4WFyKyb1tJj+1hvYzc0/Gd5ezQEFVGIMZzuD+zyZrzd+Lg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD3T2/tTh8jAANp3ew4lHSVIghgzXNoMPxC6jC3KpEAOQIgIMaqksWTGnxe0mbl4IjVaxqCFoqnj5dbkESbBKpA1XI="}]},"maintainers":[{"name":"arve.knudsen","email":"arve.knudsen@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/wayfarer-6.4.4.tgz_1488473262325_0.36806813278235495"}},"6.4.5":{"name":"@arve.knudsen/wayfarer","version":"6.4.5","description":"Composable trie based router","main":"index.js","scripts":{"test":"standard && NODE_ENV=test tape test/*","test-cov":"NODE_ENV=test istanbul cover tape -- test/*"},"repository":{"type":"git","url":"git+https://github.com/aknuds1/wayfarer.git"},"keywords":["router","trie","client","simple","minimal","functional","idempotent","on","event","emitter","react","browserify","browser"],"license":"MIT","dependencies":{"xtend":"^4.0.1"},"devDependencies":{"istanbul":"^0.4.5","mocha":"^3.1.2","noop2":"^2.0.0","standard":"^8.4.0","tape":"^4.6.2"},"files":["LICENSE","index.js","trie.js","walk.js","README.md"],"gitHead":"e03145e62b54ff119a00ce3da55067b3712e840f","bugs":{"url":"https://github.com/aknuds1/wayfarer/issues"},"homepage":"https://github.com/aknuds1/wayfarer#readme","_id":"@arve.knudsen/wayfarer@6.4.5","_shasum":"0ca869d27a5d8cb47f125a6e9633467103efaf75","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.7.0","_npmUser":{"name":"arve.knudsen","email":"arve.knudsen@gmail.com"},"dist":{"shasum":"0ca869d27a5d8cb47f125a6e9633467103efaf75","tarball":"https://registry.npmjs.org/@arve.knudsen/wayfarer/-/wayfarer-6.4.5.tgz","integrity":"sha512-Cv55qrZ4Xjwj3ue0Ey/CsNKK18UevxKR0NW6lnPGyAURVd5HV1gbigJtsxDfG4nnGQYclnAqcNfgs+QY70w13w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC12rqec/Ny32UBLXFdsZbNFfMZRePUmIK62r/ofMTInwIgbL93YUQ28L22nlfif1u5zm0HRL1GoXVoJqE+swMMTtY="}]},"maintainers":[{"name":"arve.knudsen","email":"arve.knudsen@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/wayfarer-6.4.5.tgz_1488474737403_0.655446965014562"}},"6.4.6":{"name":"@arve.knudsen/wayfarer","version":"6.4.6","description":"Composable trie based router","main":"index.js","scripts":{"test":"standard && NODE_ENV=test tape test/*","test-cov":"NODE_ENV=test istanbul cover tape -- test/*"},"repository":{"type":"git","url":"git+https://github.com/aknuds1/wayfarer.git"},"keywords":["router","trie","client","simple","minimal","functional","idempotent","on","event","emitter","react","browserify","browser"],"license":"MIT","dependencies":{"xtend":"^4.0.1"},"devDependencies":{"istanbul":"^0.4.5","mocha":"^3.1.2","noop2":"^2.0.0","standard":"^8.4.0","tape":"^4.6.2"},"files":["LICENSE","index.js","trie.js","walk.js","README.md"],"bugs":{"url":"https://github.com/aknuds1/wayfarer/issues"},"homepage":"https://github.com/aknuds1/wayfarer#readme","_id":"@arve.knudsen/wayfarer@6.4.6","_shasum":"e4aaad43b3af73e8ea0de23fd96319c6a747d4f5","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.7.0","_npmUser":{"name":"arve.knudsen","email":"arve.knudsen@gmail.com"},"dist":{"shasum":"e4aaad43b3af73e8ea0de23fd96319c6a747d4f5","tarball":"https://registry.npmjs.org/@arve.knudsen/wayfarer/-/wayfarer-6.4.6.tgz","integrity":"sha512-xk2W2b20JhWMapUYcUJkKg9lcZLLR1Qlx0sLTayDjnuarsaFJQV8legHDevnpm4hijDO3qcS8oZMK83HjCQunA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDzO+ofa+LWBoI2+9QO5c4ynSbJEdvTRbp9vtnZS4WrDAiA0FgJoRq5/mAu3l61k02Q4YuMI+TsZEfgYIIXg3oxe0w=="}]},"maintainers":[{"name":"arve.knudsen","email":"arve.knudsen@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/wayfarer-6.4.6.tgz_1488475340341_0.5414197500795126"}},"6.5.0":{"name":"@arve.knudsen/wayfarer","version":"6.5.0","description":"Composable trie based router","main":"index.js","scripts":{"test":"standard && NODE_ENV=test tape test/*","test-cov":"NODE_ENV=test istanbul cover tape -- test/*"},"repository":{"type":"git","url":"git+https://github.com/aknuds1/wayfarer.git"},"keywords":["router","trie","client","simple","minimal","functional","idempotent","on","event","emitter","react","browserify","browser"],"license":"MIT","dependencies":{"xtend":"^4.0.1"},"devDependencies":{"istanbul":"^0.4.5","mocha":"^3.1.2","noop2":"^2.0.0","standard":"^8.4.0","tape":"^4.6.2"},"files":["LICENSE","index.js","trie.js","walk.js","README.md"],"gitHead":"a199adc23709b5be44a9f8f216eb3c1771e0a5a2","bugs":{"url":"https://github.com/aknuds1/wayfarer/issues"},"homepage":"https://github.com/aknuds1/wayfarer#readme","_id":"@arve.knudsen/wayfarer@6.5.0","_shasum":"394062963921631ed237e33c82ad8ba0acb558b3","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.7.0","_npmUser":{"name":"arve.knudsen","email":"arve.knudsen@gmail.com"},"dist":{"shasum":"394062963921631ed237e33c82ad8ba0acb558b3","tarball":"https://registry.npmjs.org/@arve.knudsen/wayfarer/-/wayfarer-6.5.0.tgz","integrity":"sha512-SBVNhNgu3ykELwUGcssc79rWGvcq5Tbq088EhMyw0OGKH4nIAsWsiVwlSItArG6VMkWDv4Zc1DGABx3N6cqUgg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDdDoPIfx274LNvzzpTtya4QD6VC2kYWjHrS+lO04Zr3AIgWLlJEOY4IezInqJhJ4KoXrTdSoQ+FajDvG13aI0x8f8="}]},"maintainers":[{"name":"arve.knudsen","email":"arve.knudsen@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/wayfarer-6.5.0.tgz_1489155806449_0.9007380632683635"}}},"readme":"# wayfarer [![stability][0]][1]\n[![npm version][2]][3] [![build status][4]][5] [![test coverage][6]][7]\n[![downloads][8]][9] [![js-standard-style][10]][11]\n\nComposable [trie based](https://en.wikipedia.org/wiki/Trie) router.  It's\nfaster than traditional, linear, regular expression-matching routers, although\ninsignficantly, and scales with the number of routes.\n\nIf you're looking for a client-side router check out\n[sheet-router](https://github.com/yoshuawuyts/sheet-router). If you're looking\nfor a server router check out\n[server-router](https://github.com/yoshuawuyts/server-router).\n\n### features\n- works with any framework\n- built for speed\n- minimal dependencies\n- extensible\n\n## Installation\n```sh\n$ npm install wayfarer\n```\n\n## Usage\n```js\nconst wayfarer = require('wayfarer')\n\nconst router = wayfarer('/404')\n\nrouter.on('/', () => console.log('/'))\nrouter.on('/404', () => console.log('404 not found'))\nrouter.on('/:user', (params) => console.log('user is %s', params.user))\nrouter.on('/wildcard/*', (params) => console.log('wildcard path is %s', params.wildcard))\n\nrouter('tobi')\n// => 'user is tobi'\n\nrouter('/uh/oh')\n// => '404 not found'\n\nrouter('/wildcard/example/path')\n// => 'wildcard path is example/path'\n```\n\n## Subrouting\nRouters can be infinitely nested, allowing routing to be scoped per view.\nMatched params are passed into subrouters. Nested routes will call their\nparent's default handler if no path matches.\n```js\nconst r1 = wayfarer()\nconst r2 = wayfarer()\n\nr2.on('/child', () => console.log('subrouter trix!'))\nr1.on('/:parent', r2)\n\nr1('/dada/child')\n// => 'subrouter trix!'\n```\n\n## Walk\nSometimes it's necessary to walk the `trie` to apply transformations.\n```js\nconst walk = require('wayfarer/walk')\nconst wayfarer = require('wayfarer')\n\nconst router = wayfarer()\nrouter.on('/multiply', (x, y) => x * y)\nrouter.on('/divide', (x, y) => x / y)\n\nwalk(router, (route, cb) => {\n  const y = 2\n  return function (params, x) {\n    return cb(x, y)\n  }\n})\n\nrouter('/multiply', 4)\n// => 8\nrouter('/divide', 8)\n// => 4\n```\n\n## API\n### router = wayfarer(default)\nInitialize a router with a default route. Doesn't ignore querystrings and\nhashes.\n\n### router.on(route, cb(params, [arg1, ...]))\nRegister a new route. The order in which routes are registered does not matter.\nRoutes can register multiple callbacks. The callback can return values when\ncalled.\n\n### val = router(route, [arg1, ...])\nMatch a route and execute the corresponding callback. Alias: `router.emit()`.\nReturns a values from the matched route (e.g. useful for streams). Any\nadditional values will be passed to the matched route.\n\n## Internals\nWayfarer is built on an internal trie structure. If you want to build a router\nusing this trie structure it can be accessed through\n`require('wayfarer/trie')`. It exposes the following methods:\n- `trie = Trie()` - create a new trie\n- `node = trie.create(route)` - create a node at a path, and return a node\n- `node = trie.match(route)` - match a route on the the trie and return a node\n- `trie.mount(path, trie)` - mount a trie onto a node at route\n\n## Known issues\n### multiple nested partials don't match\nE.g. `/:foo/:bar/:baz` won't work. This is due `Trie.mount()` overriding child\npartial paths when mounted. I'll get around to fixing this at some point in the\nfuture, but if anyone wants to contribute a patch it'd most appreciated.\n\n## FAQ\n### Why did you build this?\nRouters like [react-router](https://github.com/rackt/react-router) are\ncomplicated solutions for a simple problem. In reality all that's needed is a\n[methodless](http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html) router\nthat can define + match paths and can mount other routers to delegate requests.\n\n### Why isn't my route matching?\nWayfarer only compares strings. Before you pass in an url you probably want to\nstrip it of querystrings and hashes using the\n[pathname-match](https://github.com/yoshuawuyts/pathname-match) module.\n\n## See Also\n- [sheet-router](https://github.com/yoshuawuyts/sheet-router) - fast, modular\n  client-side router\n- [server-router](https://github.com/yoshuawuyts/server-router) - server router\n- [hash-match](https://github.com/sethvincent/hash-match) - easy\n  `window.location.hash` matching\n- [pathname-match](https://github.com/yoshuawuyts/pathname-match) - strip\n  querystrings and hashes from a url\n- [wayfarer-to-server](https://github.com/yoshuawuyts/wayfarer-to-server) -\n  Wrap wayfarer to provide HTTP method matching and `req, res` delegation\n\n## License\n[MIT](https://tldrlegal.com/license/mit-license)\n\n[0]: https://img.shields.io/badge/stability-2%20stable-brightgreen.svg?style=flat-square\n[1]: https://nodejs.org/api/documentation.html#documentation_stability_index\n[2]: https://img.shields.io/npm/v/wayfarer.svg?style=flat-square\n[3]: https://npmjs.org/package/wayfarer\n[4]: https://img.shields.io/travis/yoshuawuyts/wayfarer/master.svg?style=flat-square\n[5]: https://travis-ci.org/yoshuawuyts/wayfarer\n[6]: https://img.shields.io/codecov/c/github/yoshuawuyts/wayfarer/master.svg?style=flat-square\n[7]: https://codecov.io/github/yoshuawuyts/wayfarer\n[8]: http://img.shields.io/npm/dm/wayfarer.svg?style=flat-square\n[9]: https://npmjs.org/package/wayfarer\n[10]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square\n[11]: https://github.com/feross/standard\n[12]: http://github.com/raynos/mercury\n[13]: http://github.com/raynos/virtual-dom\n","maintainers":[{"name":"arve.knudsen","email":"arve.knudsen@gmail.com"}],"time":{"modified":"2022-06-12T14:49:04.256Z","created":"2017-03-02T14:55:41.957Z","6.4.1":"2017-03-02T14:55:41.957Z","6.4.2":"2017-03-02T16:04:06.305Z","6.4.3":"2017-03-02T16:41:14.699Z","6.4.4":"2017-03-02T16:47:44.238Z","6.4.5":"2017-03-02T17:12:18.018Z","6.4.6":"2017-03-02T17:22:20.984Z","6.5.0":"2017-03-10T14:23:26.990Z"},"homepage":"https://github.com/aknuds1/wayfarer#readme","keywords":["router","trie","client","simple","minimal","functional","idempotent","on","event","emitter","react","browserify","browser"],"repository":{"type":"git","url":"git+https://github.com/aknuds1/wayfarer.git"},"bugs":{"url":"https://github.com/aknuds1/wayfarer/issues"},"license":"MIT","readmeFilename":"README.md"}