{"id":18458733,"url":"https://github.com/browserify/stream-splicer","last_synced_at":"2025-10-25T21:44:33.978Z","repository":{"id":17788093,"uuid":"20662644","full_name":"browserify/stream-splicer","owner":"browserify","description":"streaming pipeline with a mutable configuration","archived":false,"fork":false,"pushed_at":"2024-12-21T09:34:45.000Z","size":39,"stargazers_count":56,"open_issues_count":2,"forks_count":12,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-06T12:14:24.424Z","etag":null,"topics":["nodejs","pipeline","stream","streams"],"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/browserify.png","metadata":{"files":{"readme":"readme.markdown","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":"2014-06-09T21:21:18.000Z","updated_at":"2025-04-07T00:11:08.000Z","dependencies_parsed_at":"2025-01-12T16:10:55.327Z","dependency_job_id":null,"html_url":"https://github.com/browserify/stream-splicer","commit_stats":{"total_commits":75,"total_committers":7,"mean_commits":"10.714285714285714","dds":"0.18666666666666665","last_synced_commit":"d11ce6d702d979d7d701de90ae783640da4cb972"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserify%2Fstream-splicer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserify%2Fstream-splicer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserify%2Fstream-splicer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserify%2Fstream-splicer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/browserify","download_url":"https://codeload.github.com/browserify/stream-splicer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254384983,"owners_count":22062422,"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":["nodejs","pipeline","stream","streams"],"created_at":"2024-11-06T08:19:50.865Z","updated_at":"2025-10-25T21:44:28.937Z","avatar_url":"https://github.com/browserify.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# stream-splicer\n\nstreaming pipeline with a mutable configuration\n\nThis module is similar to\n[stream-combiner](https://npmjs.org/package/stream-combiner),\nbut with a pipeline configuration that can be changed at runtime.\n\n[![build status](https://travis-ci.org/browserify/stream-splicer.png?branch=master)](http://travis-ci.org/browserify/stream-splicer)\n\n# example\n\nThis example begins with an HTTP header parser that waits for an empty line to\nsignify the end of the header. At that point, it switches to a streaming json\nparser to operate on the HTTP body.\n\n``` js\nvar splicer = require('stream-splicer');\nvar through = require('through2');\nvar jsonStream = require('jsonstream2');\nvar split = require('split2');\n\nvar headerData = {};\nvar headers = through.obj(function (buf, enc, next) {\n    var line = buf.toString('utf8');\n    if (line === '') {\n        this.push(headerData);\n        pipeline.splice(1, 1, jsonStream.parse([ 'rows', true ]));\n    }\n    else {\n        var m = /^(\\S+):(.+)/.exec(line);\n        var key = m \u0026\u0026 m[1].trim();\n        var value = m \u0026\u0026 m[2].trim();\n        if (m) headerData[key] = value;\n    }\n    next();\n});\nvar pipeline = splicer([ split(), headers, jsonStream.stringify() ]);\nprocess.stdin.pipe(pipeline).pipe(process.stdout);\n```\n\nintput:\n\n```\nGET / HTTP/1.1\nHost: substack.net\nUser-Agent: echo\n\n{\"rows\":[\"beep\",\"boop\"]}\n```\n\noutput:\n\n```\n$ echo -ne 'GET / HTTP/1.1\\nHost: substack.net\\nUser-Agent: echo\\n\\n{\"rows\":[\"beep\",\"boop\"]}\\n' | node example/header.js\n[\n{\"Host\":\"substack.net\",\"User-Agent\":\"echo\"}\n,\n\"beep\"\n,\n\"boop\"\n]\n```\n\n# methods\n\n``` js\nvar splicer = require('stream-splicer')\n```\n\n## var pipeline = splicer(streams, opts)\n\nCreate a `pipeline` duplex stream given an array of `streams`. Each `stream`\nwill be piped to the next. Writes to `pipeline` get written to the first stream\nand data for reads from `pipeline` come from the last stream.\n\nFor example, for streams `[ a, b, c, d ]`, this pipeline is constructed\ninternally:\n\n```\na.pipe(b).pipe(c).pipe(d)\n```\n\nInput will get written into `a`. Output will be read from `d`.\n\nIf any of the elements in `streams` are arrays, they will be converted into\nnested pipelines. This is useful if you want to expose a hookable pipeline with\ngrouped insertion points.\n\n## var pipeline = splicer.obj(streams, opts)\n\nCreate a `pipeline` with `opts.objectMode` set to true for convenience.\n\n## var removed = pipeline.splice(index, howMany, stream, ...)\n\nSplice the pipeline starting at `index`, removing `howMany` streams and\nreplacing them with each additional `stream` argument provided.\n\nThe streams that were removed from the splice and returned.\n\n## pipeline.push(stream, ...)\n\nPush one or more streams to the end of the pipeline.\n\n## var stream = pipeline.pop()\n\nPop a stream from the end of the pipeline.\n\n## pipeline.unshift(stream, ...)\n\nUnshift one or more streams to the begining of the pipeline.\n\n## var stream = pipeline.shift()\n\nShift a stream from the begining of the pipeline.\n\n## var stream = pipeline.get(index, ...)\n\nReturn the stream at index `index, ...`. Indexes can be negative.\n\nMultiple indexes will traverse into nested pipelines.\n\n# attributes\n\n## pipeline.length\n\nThe number of streams in the pipeline\n\n# install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install stream-splicer\n```\n\n# license\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrowserify%2Fstream-splicer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrowserify%2Fstream-splicer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrowserify%2Fstream-splicer/lists"}