{"name":"wayfarer","version":"7.0.1","description":"Composable trie based router","main":"index.js","scripts":{"test":"standard && npm run test-no-cov","test-cov":"NODE_ENV=test nyc tape test/*","test-no-cov":"NODE_ENV=test tape test/*"},"repository":{"type":"git","url":"git+https://github.com/choojs/wayfarer.git"},"keywords":["router","trie","client","simple","minimal","functional","idempotent","on","event","emitter","react","browserify","browser"],"license":"MIT","browser":{"assert":"nanoassert"},"dependencies":{"nanoassert":"^1.1.0"},"devDependencies":{"noop2":"^2.0.0","nyc":"^15.0.0","standard":"^14.3.1","tape":"^4.6.2"},"gitHead":"8a175a54996a6c98272a2b6a9b726b123e444ed9","bugs":{"url":"https://github.com/choojs/wayfarer/issues"},"homepage":"https://github.com/choojs/wayfarer#readme","_id":"wayfarer@7.0.1","_nodeVersion":"13.11.0","_npmVersion":"6.14.3","dist":{"integrity":"sha512-yf+kAlOYnJRjLxflLy+1+xEclb6222EAVvAjSY+Yz2qAIDrXeN5wLl/G302Mwv3E0KMg1HT/WDGsvSymX0U7Rw==","shasum":"17a64d351d49f9d3d6c508155867df7658184ce3","tarball":"http://registry-npm.ywwl.com/wayfarer/download/wayfarer-7.0.1.tgz","fileCount":15,"unpackedSize":32221,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJedhLbCRA9TVsSAnZWagAAtu4QAJYegk5gjBhGWdUHqZDd\nRSV34NJj+CXNrrJCoT/JdVNRu3dqpV5zsBoAiS9iv6CHf3+zLSGsPawiShYP\nFq4sFzofHMEvh9pwgHqec8XSo4evWLQYriBI/sN30R5iEH+EjThQXNx+Epo+\nDvB7WaEOPgO7NqfqEc4HR6/aKxerw06t2MQ/8sA/YvZ50zbKHQZQPJ32FZHg\nIRH6O7ChrlWbDipTukMyED19kOtpxroMIaNJDkwIlM5i5LvgQeq3E2TK1Hep\nfPG7PW4GtxR6gDaN+t6J0pv/3tmd6Ke+4eQ8CXfcmIXa1GJtss48Lz1F2Do4\ncosS3TDeGGk9NNIWi/OB+LRvUfoTkgoB4uNSGlTfcgGJ8jzYqW1b9vXi8F2u\nidL1VsgNteipjvjujjtK6bAaXFbU7fgUimeWJSjF0KnpwbvwYerwuh+ikmb/\nypfQYt0g45NMWvE/btjYD4M8IyLsKoWSi/7v90KMZ891J9+WOfQXnUwDvLd3\ne/G1MKXGZ3uPMefnirtRkT9e107UzZ0xHSjAk44pK12pPUJ8RTOYKcOE+CsG\nCNOX0Tcd1UdN223i1c0b14UTAOiAr9l1xaUWdH52WP3HZYRHWtKgZZ/pRemw\nVftdHt97aMwS0YX0YtdyO1dD8bbBePWIcUfzqhfHKnFct4KezFDDxiwGMPY8\nQB/K\r\n=36Vv\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBqqzB8hEfb7hWq0ai3yJ1DnMV5osoIBmT1BrwnY7laRAiEAro8XVMc9GRb6o1HMcQB/eb6KVrmwdAbVUqm8iwjNzzA="}],"size":9074,"noattachment":false,"key":"/wayfarer/-/wayfarer-7.0.1.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":"goto-bus-stop","email":"renee@kooi.me"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/wayfarer_7.0.1_1584796378732_0.6304955237978238"},"_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":1584796378868,"_cnpm_publish_time":1584796378868,"dist-tags":{"latest":"7.0.1"}}