{"id":18357132,"url":"https://github.com/funkia/rudolph","last_synced_at":"2025-04-06T12:32:33.028Z","repository":{"id":46959408,"uuid":"85389477","full_name":"funkia/rudolph","owner":"funkia","description":"A pure and functional router using classic FRP. Written in TypeScript.","archived":false,"fork":false,"pushed_at":"2021-09-20T12:05:45.000Z","size":606,"stargazers_count":20,"open_issues_count":2,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-27T18:50:57.666Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/funkia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-18T09:21:19.000Z","updated_at":"2023-11-16T22:07:11.000Z","dependencies_parsed_at":"2022-08-25T20:01:41.458Z","dependency_job_id":null,"html_url":"https://github.com/funkia/rudolph","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funkia%2Frudolph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funkia%2Frudolph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funkia%2Frudolph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funkia%2Frudolph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/funkia","download_url":"https://codeload.github.com/funkia/rudolph/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247484513,"owners_count":20946388,"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-11-05T22:12:56.428Z","updated_at":"2025-04-06T12:32:28.001Z","avatar_url":"https://github.com/funkia.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg align=\"right\" src=\"https://avatars0.githubusercontent.com/u/21360882?v=3\u0026s=200\"\u003e\n\n# Rudolph\nA pure and functional router using classic FRP. Written in TypeScript.\nExperimental.\n\n[![Build Status](https://travis-ci.org/funkia/rudolph.svg?branch=master)](https://travis-ci.org/funkia/rudolph)\n[![codecov](https://codecov.io/gh/funkia/rudolph/branch/master/graph/badge.svg)](https://codecov.io/gh/funkia/rudolph)\n\n\n## Install\n```\nnpm install --save @funkia/rudolph @funkia/hareactive\n```\n\n## API\n\n### Router\n\n```ts\ntype Router = {\n  prefixPath: string;\n  path: Behavior\u003cstring\u003e;\n  useHash: boolean;\n};\n```\n\n### createRouter\n\nTakes a configuration Object describing how to handle the routing:\n\n* `useHash: boolean` - whether to use hash-routing\n* `path: Behavior\u003cstring\u003e` - defaults to `locationHashB` or `locationB`\n\nIt errors if `useHash = true` but hash-routing is unsupported in that browser, or if there is no support for the history API.\n\nThe returned Router object is identical to its input, augmented with `prefixPath: \"\"`, which is used to nest routers.\n\nUsage:\n\n```ts\nconst router = createRouter({\n  useHash: false\n});\n\nrunComponent(\"#mount\", main({ router }));\n```\n\n### navigate\n\n```ts\nnavigate(router: Router, pathStream: Stream\u003cstring\u003e): Now\u003cStream\u003cany\u003e\u003e\n```\n\n`navigate` takes a stream of paths. Whenever the stream has an occurence, it is navigated to.\n\nUsage:\n\n```ts\nconst navs: Stream\u003cstring\u003e = userIds\n  .map(prefix(\"/user/\"))\n  .combine(on.homeClicks.mapTo(\"/\"));\n\nstart(navigate(props.router, navs));\n```\n\n### routePath\n\n`routePath\u003cA\u003e(routes: Routes\u003cA\u003e, router: Router): Behavior\u003cA\u003e`\n\nTakes a description of the routes and a router, and returns a behavior with the result of parsing the router's location according to the routes' pattern.\n\nThe first parameter, `routes: Routes`, is a description of the routes, in the form:\n\n```ts\n{\"/route/:urlParam\"; (restUrl, params) =\u003e result}\n```\n\nUsage:\n\n```ts\nE.section(\n  routePath(\n    {\n      \"/user/:userId\": (_subrouter, { userId }) =\u003e user(userId),\n      \"/\": () =\u003e home,\n      \"*\": () =\u003e notFound,\n    },\n    props.router\n  )\n)\n```\n\n### Routes\n\n```ts\ntype Routes\u003cA\u003e = Record\u003cstring, RouteHandler\u003cA\u003e\u003e\n```\n\nExample:\n\n```ts\n{\n  \"/user/:userId\": (_subrouter, { userId }) =\u003e user(userId),\n  \"/\": () =\u003e home,\n  \"*\": () =\u003e notFound,\n}\n```\n\n### RouteHandler\n\n```ts\ntype RouteHandler\u003cA\u003e = (\n  router: Router,\n  params: Record\u003cstring, string\u003e\n) =\u003e A;\n```\n\n### locationHashB\n\n`locationHashB: Behavior\u003cstring\u003e` represents the current values of the URL hash.\n\n### locationB\n\n`locationHashB: Behavior\u003cstring\u003e` represents the current values of the URL pathname.\n\n### navigateHashIO\n\n`navigateHashIO: (path: string) =\u003e IO\u003cvoid\u003e` is an `IO` effect that updates the URL hash to the supplied argument.\n\n### navigateIO\n\n`navigateIO: (path: string) =\u003e IO\u003cvoid\u003e` is an `IO` effect that updates the URL pathname to the supplied argument.\n\n### warnNavigation\n\nTakes a behavior of a boolean, if true the user will have to confirm before unloading page.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunkia%2Frudolph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffunkia%2Frudolph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunkia%2Frudolph/lists"}