{"id":13454504,"url":"https://github.com/feross/multistream","last_synced_at":"2025-04-08T04:14:57.448Z","repository":{"id":18356528,"uuid":"21536544","full_name":"feross/multistream","owner":"feross","description":"A stream that emits multiple other streams one after another (streams3)","archived":false,"fork":false,"pushed_at":"2021-09-08T20:03:16.000Z","size":100,"stargazers_count":293,"open_issues_count":4,"forks_count":26,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-01T03:35:28.438Z","etag":null,"topics":["javascript","multistream","nodejs","stream","streams"],"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/feross.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}},"created_at":"2014-07-06T08:42:02.000Z","updated_at":"2025-02-18T12:25:11.000Z","dependencies_parsed_at":"2022-09-02T18:01:25.912Z","dependency_job_id":null,"html_url":"https://github.com/feross/multistream","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feross%2Fmultistream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feross%2Fmultistream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feross%2Fmultistream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feross%2Fmultistream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/feross","download_url":"https://codeload.github.com/feross/multistream/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247773719,"owners_count":20993639,"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":["javascript","multistream","nodejs","stream","streams"],"created_at":"2024-07-31T08:00:54.782Z","updated_at":"2025-04-08T04:14:57.422Z","avatar_url":"https://github.com/feross.png","language":"JavaScript","readme":"# multistream [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]\n\n[travis-image]: https://img.shields.io/travis/feross/multistream/master.svg\n[travis-url]: https://travis-ci.org/feross/multistream\n[npm-image]: https://img.shields.io/npm/v/multistream.svg\n[npm-url]: https://npmjs.org/package/multistream\n[downloads-image]: https://img.shields.io/npm/dm/multistream.svg\n[downloads-url]: https://npmjs.org/package/multistream\n[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg\n[standard-url]: https://standardjs.com\n\n#### A stream that emits multiple other streams one after another (streams3)\n\n[![Sauce Test Status](https://saucelabs.com/browser-matrix/multistream.svg)](https://saucelabs.com/u/multistream)\n\n![cat](https://raw.githubusercontent.com/feross/multistream/master/img.jpg)\n\nSimple, robust streams3 version of [combined-stream](https://www.npmjs.org/package/combined-stream). Allows you to combine multiple streams into a single stream. When the first stream ends, the next one starts, and so on, until all streams are consumed.\n\nThis module is used by [WebTorrent](http://webtorrent.io), specifically [create-torrent](https://github.com/feross/create-torrent).\n\n### install\n\n```\nnpm install multistream\n```\n\n### usage\n\nUse `multistream` like this:\n\n```js\nvar MultiStream = require('multistream')\nvar fs = require('fs')\n\nvar streams = [\n  fs.createReadStream(__dirname + '/numbers/1.txt'),\n  fs.createReadStream(__dirname + '/numbers/2.txt'),\n  fs.createReadStream(__dirname + '/numbers/3.txt')\n]\n\nnew MultiStream(streams).pipe(process.stdout) // =\u003e 123\n```\n\nYou can also create an object-mode stream with `MultiStream.obj(streams)`.\n\nTo lazily create the streams, wrap them in a function:\n\n```js\nvar streams = [\n  fs.createReadStream(__dirname + '/numbers/1.txt'),\n  function () { // will be executed when the stream is active\n    return fs.createReadStream(__dirname + '/numbers/2.txt')\n  },\n  function () { // same\n    return fs.createReadStream(__dirname + '/numbers/3.txt')\n  }\n]\n\nnew MultiStream(streams).pipe(process.stdout) // =\u003e 123\n```\n\nAlternatively, streams may be created by an asynchronous \"factory\" function:\n\n```js\nvar count = 0\nfunction factory (cb) {\n  if (count \u003e 3) return cb(null, null)\n  count++\n  setTimeout(function () {\n    cb(null, fs.createReadStream(__dirname + '/numbers/' + count + '.txt'))\n  }, 100)\n}\n\nnew MultiStream(factory).pipe(process.stdout) // =\u003e 123\n```\n\n### contributors\n\n- [Feross Aboukhadijeh](http://feross.org)\n- [Mathias Buus](https://github.com/mafintosh/)\n- [Yuri Astrakhan](https://github.com/nyurik/)\n\n### license\n\nMIT. Copyright (c) [Feross Aboukhadijeh](http://feross.org).\n","funding_links":[],"categories":["Packages","Repository","包","JavaScript","目录","Streams","Modules"],"sub_categories":["Streams","文件流","流处理","流"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffeross%2Fmultistream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffeross%2Fmultistream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffeross%2Fmultistream/lists"}