{"id":20181740,"url":"https://github.com/nichoth/pull-router","last_synced_at":"2026-07-14T15:03:24.478Z","repository":{"id":77400156,"uuid":"75987511","full_name":"nichoth/pull-router","owner":"nichoth","description":"High level router using pull streams","archived":false,"fork":false,"pushed_at":"2016-12-11T02:10:36.000Z","size":9,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-14T06:48:50.694Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/nichoth/pull-router#readme","language":"JavaScript","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/nichoth.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-09T00:45:43.000Z","updated_at":"2018-03-12T16:27:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"1d6e11fb-9f40-496f-b92d-c46c72bb1ea3","html_url":"https://github.com/nichoth/pull-router","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"d9cae7715f9f2cc24a713f0f0b66704e39394759"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nichoth%2Fpull-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nichoth%2Fpull-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nichoth%2Fpull-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nichoth%2Fpull-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nichoth","download_url":"https://codeload.github.com/nichoth/pull-router/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241616699,"owners_count":19991543,"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-14T02:36:36.861Z","updated_at":"2025-10-25T07:09:16.833Z","avatar_url":"https://github.com/nichoth.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pull router\n\nHigh level router using pull streams.\n\n## install\n\n    $ npm install pull-router\n\n## example\n\n```js\nvar S = require('pull-stream')\nvar Router = require('../')\nvar assert = require('assert')\n\n// through streams go here\nvar TestRouter = Router([\n    ['/foo', function (params, route) {\n        return S.map(function (ev) {\n            return { count: ev }\n        })\n    }]\n])\n\nvar router = TestRouter([\n    // duplex streams go here\n    ['/foo', function (params, route) {\n        return {\n            source: S.once(1),\n            sink: S.collect(function (err, res) {\n                // our source is piped through the transform\n                // we defined above\n                console.log(route.route)  // =\u003e /foo\n                console.log(res[0])  // =\u003e { count: 1 }\n                assert.equal(res[0].count, 1)\n            }),\n            // in here we would do something to connect a view\n            // to the source and sink if we a in a browser\n            view: 'test'\n        }\n    }]\n])\n\n// `router()` returns a source stream that emits views and\n// listens for route events (in a browser).\n// In node call `router().push()` -- `router()` is an instance of\n// pull-pushable.\n// When the route changes, this stream will pipe the new route and\n// unpipe the old one\nvar routeStream = router()\nS(\n    routeStream,\n    S.drain(function onRoute (view) {\n        assert.equal(view, 'test')\n    })\n)\nrouteStream.push('/foo')\nrouteStream.end()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnichoth%2Fpull-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnichoth%2Fpull-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnichoth%2Fpull-router/lists"}