{"id":13526557,"url":"https://github.com/grncdr/merge-stream","last_synced_at":"2025-05-15T20:02:51.548Z","repository":{"id":8867125,"uuid":"10579821","full_name":"grncdr/merge-stream","owner":"grncdr","description":"Merge multiple streams into one interleaved stream","archived":false,"fork":false,"pushed_at":"2019-06-20T04:46:40.000Z","size":28,"stargazers_count":212,"open_issues_count":0,"forks_count":15,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-08T03:03:26.150Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/grncdr.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":"2013-06-09T07:19:43.000Z","updated_at":"2025-03-15T20:58:43.000Z","dependencies_parsed_at":"2022-08-28T04:40:37.971Z","dependency_job_id":null,"html_url":"https://github.com/grncdr/merge-stream","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grncdr%2Fmerge-stream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grncdr%2Fmerge-stream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grncdr%2Fmerge-stream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grncdr%2Fmerge-stream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grncdr","download_url":"https://codeload.github.com/grncdr/merge-stream/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254414477,"owners_count":22067270,"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-08-01T06:01:31.514Z","updated_at":"2025-05-15T20:02:49.756Z","avatar_url":"https://github.com/grncdr.png","language":"JavaScript","funding_links":[],"categories":["Repository","插件","Plugins","Modules"],"sub_categories":["Streams","流控制","Flow Control"],"readme":"# merge-stream\n\nMerge (interleave) a bunch of streams.\n\n[![build status](https://secure.travis-ci.org/grncdr/merge-stream.svg?branch=master)](http://travis-ci.org/grncdr/merge-stream)\n\n## Synopsis\n\n```javascript\nvar stream1 = new Stream();\nvar stream2 = new Stream();\n\nvar merged = mergeStream(stream1, stream2);\n\nvar stream3 = new Stream();\nmerged.add(stream3);\nmerged.isEmpty();\n//=\u003e false\n```\n\n## Description\n\nThis is adapted from [event-stream](https://github.com/dominictarr/event-stream) separated into a new module, using Streams3.\n\n## API\n\n### `mergeStream`\n\nType: `function`\n\nMerges an arbitrary number of streams. Returns a merged stream.\n\n#### `merged.add`\n\nA method to dynamically add more sources to the stream. The argument supplied to `add` can be either a source or an array of sources.\n\n#### `merged.isEmpty`\n\nA method that tells you if the merged stream is empty.\n\nWhen a stream is \"empty\" (aka. no sources were added), it could not be returned to a gulp task.\n\nSo, we could do something like this:\n\n```js\nstream = require('merge-stream')();\n// Something like a loop to add some streams to the merge stream\n// stream.add(streamA);\n// stream.add(streamB);\nreturn stream.isEmpty() ? null : stream;\n```\n\n## Gulp example\n\nAn example use case for **merge-stream** is to combine parts of a task in a project's **gulpfile.js** like this:\n\n```js\nconst gulp =          require('gulp');\nconst htmlValidator = require('gulp-w3c-html-validator');\nconst jsHint =        require('gulp-jshint');\nconst mergeStream =   require('merge-stream');\n\nfunction lint() {\n  return mergeStream(\n    gulp.src('src/*.html')\n      .pipe(htmlValidator())\n      .pipe(htmlValidator.reporter()),\n    gulp.src('src/*.js')\n      .pipe(jsHint())\n      .pipe(jsHint.reporter())\n  );\n}\ngulp.task('lint', lint);\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrncdr%2Fmerge-stream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrncdr%2Fmerge-stream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrncdr%2Fmerge-stream/lists"}