{"name":"wayfarer","version":"7.0.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/yoshuawuyts/wayfarer.git"},"keywords":["router","trie","client","simple","minimal","functional","idempotent","on","event","emitter","react","browserify","browser"],"license":"MIT","dependencies":{},"devDependencies":{"istanbul":"^0.4.5","mocha":"^3.1.2","noop2":"^2.0.0","standard":"^8.4.0","tape":"^4.6.2"},"gitHead":"94dcc3591fa08896719c2ecd75e70de8b9478c06","bugs":{"url":"https://github.com/yoshuawuyts/wayfarer/issues"},"homepage":"https://github.com/yoshuawuyts/wayfarer#readme","_id":"wayfarer@7.0.0","_nodeVersion":"12.4.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-mKF6pIaNHTdmwWjzrjbIWDnlgFFPC7MuQ+gbUVjBLpXp40mYmiP3Eb7qtO0rgAcsj3kuzGu3sN2Ya6GqOYiTwQ==","shasum":"ae65e759628e5042bdaa380aa47bb736ca07380c","tarball":"http://registry-npm.ywwl.com/wayfarer/download/wayfarer-7.0.0.tgz","fileCount":15,"unpackedSize":31208,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc/MZaCRA9TVsSAnZWagAAdcEP/3v8h8tyh8Qhkx0xa7Du\nOQTuXEJMBSEuNr/TsuSh5qu2TAdzRQuFXNkxLgaZFcqcQ0/CVtf0bothpZY0\nru4z+Yvkg2xc06AcU4MlG/C4at1u4CM3L17GrNPBw/rD2Erc/g2tzAcfT8jo\nEMWYnmjkTDAxYTA30rTIkQ9SrxFxrpaC0Q3FAXzD9lFmizz5RpZ0awDSbsN1\nDPkQZY504eyUENgwbl3AU1By5ZX9c2l4btn+skgNf3Z/3FDHrjOmRkmi0YlX\nAIAW+huuKTur2iQldJLPnTE6b7ZzaLX9jEQ1DiIjwqsKeU6ciU7M97xAlgJB\ndcv/FeK6NWzJR7Jq7613L6ysv0NABtKit6VZAIm3xl0nxAHZbP6emT6e47A+\n4MM6joDH0g+yQvVOWJSeUxXpscN6wr/0r34iBEx9gMdANy1+sQ8FMpsL8tm5\neyG5yPrV6UUbyJpoDVqZIxdNoCOuxO8ycgngZHT6obMHjfrm8IEXtfAnELJK\nPrI2ZvdIU1j1jNVQCoEACZ+T2sUfVOsC9e1KjPqYAeOWhe/KuheD/8Zy8mLp\n+40lZsKYBw0SJnUAZge/BzwOWSykNH9RR/dyhQp8dWzPlzpiaab607IbPODC\nM3U5FvjU4P+T2eWmzO1MlcRVnL5nVz6wXqTn4yr+FpfKSzeXdzgMRIED5l3C\nM7U3\r\n=+TIj\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIENeAo+imkfYWOpCu6VYXE5ub1++/MwfcNFNJkkUzLEdAiEA5AW6nfAuB5ofuD53s0DmlC7lkLn73tLetGmqcXf76pM="}],"size":8865,"noattachment":false,"key":"/wayfarer/-/wayfarer-7.0.0.tgz"},"maintainers":[{"email":"michael.williams@enspiral.com","name":"ahdinosaur"},{"email":"tom@almostobsolete.net","name":"almost"},{"email":"jon@folderstudio.com","name":"amongiants"},{"email":"bendik.lynghaug@gmail.com","name":"benlyn"},{"email":"bcomnes@gmail.com","name":"bret"},{"email":"colin@colin-gourlay.com","name":"colingourlay"},{"email":"github@tixz.dk","name":"emilbayes"},{"email":"feross@feross.org","name":"feross"},{"email":"the.freeman.lab@gmail.com","name":"freeman-lab"},{"email":"renee@kooi.me","name":"goto-bus-stop"},{"email":"neatcube@gmail.com","name":"graforlock"},{"email":"hughskennedy@gmail.com","name":"hughsk"},{"email":"james.kyburz@gmail.com","name":"jameskyburz"},{"email":"julian@juliangruber.com","name":"juliangruber"},{"email":"shestak.irina@gmail.com","name":"lrlna"},{"email":"mathiasbuus@gmail.com","name":"mafintosh"},{"email":"marc.brookman@gmail.com","name":"marcbachmann"},{"email":"max@maxogden.com","name":"maxogden"},{"email":"s3th.thompson@gmail.com","name":"s3ththompson"},{"email":"sethvincent@gmail.com","name":"sethvincent"},{"email":"kyle@dontkry.com","name":"shama"},{"email":"robert@publicclass.se","name":"slaskis"},{"email":"substack@gmail.com","name":"substack"},{"email":"secoif@gmail.com","name":"timoxley"},{"email":"tim@timwis.com","name":"timwis"},{"email":"todd@selfassembled.org","name":"toddself"},{"email":"carl@tornqv.ist","name":"tornqvist"},{"email":"ungoldman@gmail.com","name":"ungoldman"},{"email":"yerko.palma@usach.cl","name":"yerkopalma"},{"email":"yoshuawuyts@gmail.com","name":"yoshuawuyts"}],"_npmUser":{"name":"tornqvist","email":"carl@tornqv.ist"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/wayfarer_7.0.0_1560069721649_0.027975850403192615"},"_hasShrinkwrap":false,"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\nvar wayfarer = require('wayfarer')\n\nvar 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\nvar r1 = wayfarer()\nvar 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\nvar walk = require('wayfarer/walk')\nvar wayfarer = require('wayfarer')\n\nvar router = wayfarer()\nrouter.on('/multiply', (x, y) => x * y)\nrouter.on('/divide', (x, y) => x / y)\n\nwalk(router, (route, cb) => {\n  var 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### matchedRoute = router.match(route)\nMatches a route and returns an object. The returned object contains the properties `{cb, params, route}`. This method does not invoke the callback of a route. If no route matches, the default route will be returned. If no default route matches, an error will be thrown.\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","publish_time":1560069721804,"_cnpm_publish_time":1560069721804,"dist-tags":{"latest":"7.0.1"}}