{"id":17445991,"url":"https://github.com/jamen/pull-splitter","last_synced_at":"2025-07-18T01:36:12.723Z","repository":{"id":96785221,"uuid":"90928545","full_name":"jamen/pull-splitter","owner":"jamen","description":"Split a stream into other streams using filters","archived":false,"fork":false,"pushed_at":"2017-05-13T02:46:33.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-24T19:33:24.063Z","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/jamen.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":"2017-05-11T02:30:08.000Z","updated_at":"2021-12-19T15:38:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"f2e5819c-dd9b-4b33-b7fc-540077dfacfe","html_url":"https://github.com/jamen/pull-splitter","commit_stats":{"total_commits":7,"total_committers":1,"mean_commits":7.0,"dds":0.0,"last_synced_commit":"0ef678776b20ca3425ebd4a8fce506ef95b830d1"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/jamen/pull-splitter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamen%2Fpull-splitter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamen%2Fpull-splitter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamen%2Fpull-splitter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamen%2Fpull-splitter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jamen","download_url":"https://codeload.github.com/jamen/pull-splitter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamen%2Fpull-splitter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261374406,"owners_count":23148974,"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-17T18:19:50.423Z","updated_at":"2025-06-22T22:02:58.737Z","avatar_url":"https://github.com/jamen.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# pull-splitter\n\n\u003e Split a stream into other streams using filters\n\n```js\nconst { pull, drain } = require('pull-stream')\nconst { read, write } = require('pull-files')\nconst splitter = require('pull-splitter')\nconst { extname } = require('path')\n\nconst [split, channels, rest] = splitter({\n  js: file =\u003e extname(file.path) === '.js',\n  css: file =\u003e extname(file.path) === '.css',\n  html: file =\u003e extname(file.path) === '.html',\n  // Pass other files through\n  rest: true\n})\n\n// Pull files into splitter:\npull(\n  read('src/**/*'),\n  split\n)\n\n// Pull results out\npull(\n  channels.css,\n  write('out/css')\n)\n\npull(\n  channels.js,\n  write('out/js')\n)\n\n// Pull results with no match\npull(\n  rest,\n  write('out/assets')\n)\n```\n\nThe splitter returns `[split, channels, rest]`, where `split` is a sink that pushes onto one of the `channels`, or `rest` if none match\n\nSee [`pull-merge`](https://github.com/pull-stream/pull-merge) and [`pull-sorted-merge`](https://github.com/pull-stream/pull-sorted-merge) for joining the streams back together\n\n## Install\n\n```sh\nnpm install --save pull-splitter\n```\n\n```sh\nyarn add pull-splitter\n```\n\n## Usage\n\n### `splitter(config)`\n\nReturns a sink and sources (`channels` and `rest`), based on the config provided\n\n```js\nvar [split, channels, rest] = splitter({\n  high: item =\u003e item \u003e 10,\n  low: item =\u003e item \u003e 5,\n  // ...\n})\n```\n\nEach field in config turns into a source stream on `channels` based on the filter\n\n```js\npull(\n  channels.high,\n  drain(console.log)\n)\n\npull(\n  channels.low,\n  drain(console.log)\n)\n```\n\nThen to stream data in, you use `split.sink`:\n\n```js\npull(\n  values([ 3, 6, 9, 12, 15 ]),\n  split\n)\n```\n\nPull unmatching items through `rest`:\n\n```\npull(rest, drain(console.log))\n```\n\n## Also see \n\n - [`pull-merge`](https://github.com/pull-stream/pull-merge) to merge the streams\n - [`pull-sorted-merge`](https://github.com/pull-stream/pull-sorted-merge) to merge the streams with sorting\n - [`pull-pair`](https://github.com/pull-stream/pull-pair) for a basic way to link streams\n - [`pull-tee`](https://github.com/pull-stream/pull-tee) for a different mechanism of splitting a stream\n\n---\n\nMaintained by [Jamen Marz](https://git.io/jamen) (See on [Twitter](https://twitter.com/jamenmarz) and [GitHub](https://github.com/jamen) for questions \u0026 updates)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamen%2Fpull-splitter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjamen%2Fpull-splitter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamen%2Fpull-splitter/lists"}