{"id":16834718,"url":"https://github.com/mscdex/conveyor","last_synced_at":"2025-04-10T06:41:36.547Z","repository":{"id":11756124,"uuid":"14288534","full_name":"mscdex/conveyor","owner":"mscdex","description":"Feed multiple node.js streams sequentially into one stream","archived":false,"fork":false,"pushed_at":"2013-11-11T23:01:34.000Z","size":131,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-24T07:48:56.227Z","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/mscdex.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-11-11T01:23:17.000Z","updated_at":"2024-04-07T12:03:02.000Z","dependencies_parsed_at":"2022-09-12T15:12:08.379Z","dependency_job_id":null,"html_url":"https://github.com/mscdex/conveyor","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscdex%2Fconveyor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscdex%2Fconveyor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscdex%2Fconveyor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscdex%2Fconveyor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mscdex","download_url":"https://codeload.github.com/mscdex/conveyor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248173061,"owners_count":21059591,"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-13T12:07:33.865Z","updated_at":"2025-04-10T06:41:36.522Z","avatar_url":"https://github.com/mscdex.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\nDescription\n===========\n\nFeed multiple node.js streams sequentially into one (Writable or Duplex) stream.\n\nNote: The single Writable/Duplex stream will emit multiple 'finish' events, so if\nyou have a listener for that event, you can ignore it until you end the Conveyor\ninstance.\n\n\nRequirements\n============\n\n* [node.js](http://nodejs.org/) -- v0.10.0 or newer\n\n\nInstall\n=======\n\n    npm install conveyor\n\n\nExamples\n========\n\n* Pass HTTP requests to a 'passthrough' stream:\n\n```javascript\nvar TransformStream = require('stream').Transform,\n    http = require('http');\n\nvar Conveyor = require('conveyor');\n\nvar stream = new TransformStream();\nstream._transform = function(chunk, encoding, cb) {\n  this.push(chunk);\n  cb();\n};\n\nvar c = new Conveyor(stream),\n    TOTAL = 10,\n    count = 0;\n\nhttp.createServer(function(req, res) {\n  if (++count === TOTAL)\n    this.close();\n  c.push(req, res);\n}).listen(8080, function() {\n  for (var i = 0; i \u003c TOTAL; ++i) {\n    http.request({\n      host: '127.0.0.1',\n      port: 8080,\n      method: 'POST'\n    }, function(res) {\n      var b = '';\n      res.on('data', function(d) {\n        b += d;\n      }).on('end', function() {\n        console.log(b);\n      });\n    }).end('Hello from request #' + (i + 1));\n  }\n});\n\n// output:\n// Hello from request #1\n// Hello from request #2\n// Hello from request #3\n// Hello from request #4\n// Hello from request #5\n// Hello from request #6\n// Hello from request #7\n// Hello from request #8\n// Hello from request #9\n// Hello from request #10\n```\n\n* Pass HTTP requests to a Writable stream:\n\n```javascript\nvar WritableStream = require('stream').Writable,\n    http = require('http');\n\nvar Conveyor = require('conveyor');\n\nvar stream = new WritableStream();\nstream._write = function(chunk, encoding, cb) {\n  console.log(chunk.toString());\n  cb();\n};\n\nvar c = new Conveyor(stream),\n    TOTAL = 10,\n    count = 0;\n\nhttp.createServer(function(req, res) {\n  if (++count === TOTAL)\n    this.close();\n  c.push(req, function() {\n    // this req stream finished\n    res.end();\n  });\n}).listen(8080, function() {\n  for (var i = 0; i \u003c TOTAL; ++i) {\n    http.request({\n      host: '127.0.0.1',\n      port: 8080,\n      method: 'POST'\n    }, function(res) {\n      res.resume();\n    }).end('Hello from request #' + (i + 1));\n  }\n});\n\n// output (assuming 1-chunk requests):\n// Hello from request #1\n// Hello from request #2\n// Hello from request #3\n// Hello from request #4\n// Hello from request #5\n// Hello from request #6\n// Hello from request #7\n// Hello from request #8\n// Hello from request #9\n// Hello from request #10\n```\n\n\nAPI\n===\n\n_Conveyor_ is an _EventEmitter_\n\nConveyor events\n---------------\n\n* **end**() - Emitted after end() is called and all streams have been processed.\n\n\nConveyor methods\n----------------\n\n* **(constructor)**(\u003c _Writable_ \u003edest, \u003c _object_ \u003econfig) - Creates and returns a new Dicer instance with the following valid `config` settings:\n\n    * **max** - _integer_ - This is the max queue size (this does not include the stream currently being processed, if applicable). (Default: Infinity)\n\n    * **startPaused** - _boolean_ - Start in a paused state? (Default: false)\n\n* **push**(\u003c _Readable_ \u003estream[, \u003c _Writable_ \u003epipeStream][, \u003c _object_ \u003epipeStreamOpts][, \u003c _function_ \u003ecallback]) - _boolean_ - Pushes (appends) `stream` to the queue. If `pipeStream` is set, data (from `dest` passed to the constructor) will be piped to this stream with optional `pipeStreamOpts` pipe settings. `callback` is called once `stream` has ended and `dest` is drained. The return value is false if `stream` could not be enqueued due to the queue being full.\n\n* **unshift**(\u003c _Readable_ \u003estream[, \u003c _Writable_ \u003epipeStream][, \u003c _object_ \u003epipeStreamOpts][, \u003c _function_ \u003ecallback]) - _boolean_ - Identical to push() except it unshifts (prepends) `stream` to the queue.\n\n* **pause**() - _(void)_ - Pauses processing of streams in the queue. If a stream is currently being processed, then the next one will not be started until resume() has been explicitly called.\n\n* **resume**() - _(void)_ - Resumes processing of streams in the queue.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmscdex%2Fconveyor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmscdex%2Fconveyor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmscdex%2Fconveyor/lists"}