{"id":15385976,"url":"https://github.com/gianlucaguarini/rawth","last_synced_at":"2025-04-15T17:33:20.715Z","repository":{"id":35103139,"uuid":"207093345","full_name":"GianlucaGuarini/rawth","owner":"GianlucaGuarini","description":"Pure functional isomorphic router based on streams","archived":false,"fork":false,"pushed_at":"2023-09-29T21:11:16.000Z","size":553,"stargazers_count":15,"open_issues_count":3,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-12T20:48:28.919Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GianlucaGuarini.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-08T10:01:34.000Z","updated_at":"2024-04-25T06:38:27.000Z","dependencies_parsed_at":"2024-06-19T01:50:01.318Z","dependency_job_id":"1275635e-c9e9-441b-85ff-deb7f41cbd16","html_url":"https://github.com/GianlucaGuarini/rawth","commit_stats":{"total_commits":52,"total_committers":2,"mean_commits":26.0,"dds":"0.038461538461538436","last_synced_commit":"70cc9605a88d9515f3dc92527abf927fed8942af"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GianlucaGuarini%2Frawth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GianlucaGuarini%2Frawth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GianlucaGuarini%2Frawth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GianlucaGuarini%2Frawth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GianlucaGuarini","download_url":"https://codeload.github.com/GianlucaGuarini/rawth/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249119017,"owners_count":21215657,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T14:46:53.524Z","updated_at":"2025-04-15T17:33:20.397Z","avatar_url":"https://github.com/GianlucaGuarini.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"righ\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/GianlucaGuarini/rawth/master/rawth-logo.png\" alt=\"rawth\"/\u003e\n\u003c/p\u003e\n\n\n##### Pure functional isomorphic router based on streams. It works consistently on modern browsers and on node.\n\n---\n\n\n[![Build Status][ci-image]][ci-url]\n\n[![NPM version][npm-version-image]][npm-url]\n[![NPM downloads][npm-downloads-image]][npm-url]\n[![Code Quality][codeclimate-image]][codeclimate-url]\n[![Coverage Status][coverage-image]][coverage-url]\n![rawth size][lib-size]\n[![MIT License][license-image]][license-url]\n\n## Usage\n\nAny `rawth.route` function creates an [erre stream](https://github.com/GianlucaGuarini/erre) connected to the main router stream. These sub-streams will be activated only when their paths will match the current router path. For example:\n\n```js\nimport route, { router } from 'rawth'\n\nroute('/users/:user').on.value(({params}) =\u003e {\n  const {user} = params\n\n  console.log(`Hello dear ${user}`)\n})\n\n// you can dispatch router events at any time\nrouter.push('/users/gianluca')\n```\n\nThe argument passed to the subscribed functions is an [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL) object having `params` as additional property. The `params` array will contain all the matched [route parameters](https://github.com/pillarjs/path-to-regexp#parameters)\n\n```js\nimport route, { router } from 'rawth'\n\nroute('/:group/:user').on.value(({params}) =\u003e {\n  const {group, user} = params\n\n  console.log(`Hello dear ${user}, you are part of the ${group} group`)\n})\n\n// you can dispatch router events at any time\nrouter.push('/friends/gianluca')\n```\n\n### Unsubscribe streams\n\nIf you want to unsubscribe to a specific route you need just to end the stream\n\n```js\nimport route from 'rawth'\n\nconst usersRouteStream = route('/users/:user')\n\n// subscribe to the stream as many times as you want\nusersRouteStream.on.value(({params}) =\u003e { /* */ })\nusersRouteStream.on.value(({params}) =\u003e { /* */ })\nusersRouteStream.on.value(({params}) =\u003e { /* */ })\n\n// end the stream\nusersRouteStream.end()\n```\n\n### Set the base path\n\nYou can set the base path and override the router default options using the `configure` method\n\n```js\nimport { configure } from 'rawth'\n\nconfigure({\n  base: 'https://example.com',\n  strict: true\n})\n\n```\n\n[ci-image]:https://github.com/GianlucaGuarini/rawth/actions/workflows/test.yml/badge.svg\n[ci-url]:https://github.com/GianlucaGuarini/rawth/actions/workflows/test.yml\n\n[license-image]:http://img.shields.io/badge/license-MIT-000000.svg?style=flat-square\n[license-url]:LICENSE\n\n[lib-size]:https://img.badgesize.io/https://unpkg.com/rawth/index.js?compression=gzip\n\n[npm-version-image]:http://img.shields.io/npm/v/rawth.svg?style=flat-square\n[npm-downloads-image]:http://img.shields.io/npm/dm/rawth.svg?style=flat-square\n[npm-url]:https://npmjs.org/package/rawth\n\n[coverage-image]:https://img.shields.io/coveralls/GianlucaGuarini/rawth/main.svg?style=flat-square\n[coverage-url]:https://coveralls.io/r/GianlucaGuarini/rawth?branch=main\n\n[codeclimate-image]:https://api.codeclimate.com/v1/badges/5a4b8cf4736254115cb3/maintainability\n[codeclimate-url]:https://codeclimate.com/github/GianlucaGuarini/rawth/maintainability\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgianlucaguarini%2Frawth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgianlucaguarini%2Frawth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgianlucaguarini%2Frawth/lists"}