{"_id":"@bybrave/concat-stream2","_rev":"2-c5c0adc2924882ffb97069a5b8332c49","name":"@bybrave/concat-stream2","dist-tags":{"latest":"3.0.1"},"versions":{"3.0.0":{"name":"@bybrave/concat-stream2","version":"3.0.0","keywords":["concat","stream","writable","buffer","concat-stream","collect","zero-dependency","typescript","esm"],"author":{"url":"https://github.com/bybraveHQ","name":"bybrave"},"license":"MIT","_id":"@bybrave/concat-stream2@3.0.0","maintainers":[{"name":"bybrave","email":"opmybrave@gmail.com"}],"contributors":[{"url":"author of the original concat-stream","name":"Max Ogden"}],"homepage":"https://github.com/bybraveHQ/concat-stream2#readme","bugs":{"url":"https://github.com/bybraveHQ/concat-stream2/issues"},"dist":{"shasum":"d7747d3bebc56ecdfd51d6d8dc5f3d0ffe1618c7","tarball":"https://registry.npmjs.org/@bybrave/concat-stream2/-/concat-stream2-3.0.0.tgz","fileCount":6,"integrity":"sha512-FtZNuMJs/50q1sCgy+EHFa7gQswX87rCJ3RlwPyoI79S+iMohaOeMu86fSqRv2eyWYxcNvv2lv3cLxy/AkWe/g==","signatures":[{"sig":"MEQCIBSgk2x/UIkjDumqz7wAWt5dz7N2y5tGWoFQQ5ZuYzizAiBDWvdkTw6SrWPHI1O6TDfdSCWBC5H8rmIHH0cacPacwA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":12784},"main":"lib/concat-stream.js","types":"index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./index.d.ts","import":"./index.mjs","require":"./lib/concat-stream.js"},"./package.json":"./package.json"},"funding":"https://ko-fi.com/bybrave","gitHead":"928c2715286bb88d79018e6b5f0750f6885edb22","scripts":{"test":"node --test test/*.test.js","test-types":"tsc --noEmit --strict test/type-declarations.ts"},"_npmUser":{"name":"bybrave","email":"opmybrave@gmail.com"},"repository":{"url":"git+https://github.com/bybraveHQ/concat-stream2.git","type":"git"},"_npmVersion":"10.8.2","description":"Maintained fork of concat-stream — zero runtime dependencies, dual ESM+CJS, and bundled TypeScript types (no separate @types/concat-stream needed)","directories":{},"_nodeVersion":"20.19.6","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.5.0","@types/node":"^20.14.0"},"_npmOperationalInternal":{"tmp":"tmp/concat-stream2_3.0.0_1783292284843_0.02400012688748432","host":"s3://npm-registry-packages-npm-production"}},"3.0.1":{"name":"@bybrave/concat-stream2","version":"3.0.1","description":"Maintained fork of concat-stream — zero runtime dependencies, dual ESM+CJS, and bundled TypeScript types (no separate @types/concat-stream needed)","main":"lib/concat-stream.js","types":"index.d.ts","exports":{".":{"types":"./index.d.ts","import":"./index.mjs","require":"./lib/concat-stream.js"},"./package.json":"./package.json"},"scripts":{"test":"node --test test/*.test.js","test-types":"tsc --noEmit --strict test/type-declarations.ts"},"repository":{"type":"git","url":"git+https://github.com/bybraveHQ/concat-stream2.git"},"bugs":{"url":"https://github.com/bybraveHQ/concat-stream2/issues"},"homepage":"https://github.com/bybraveHQ/concat-stream2#readme","keywords":["concat","stream","writable","buffer","concat-stream","collect","zero-dependency","typescript","esm"],"author":{"name":"bybrave","url":"https://github.com/bybraveHQ"},"contributors":[{"name":"Max Ogden","url":"author of the original concat-stream"}],"license":"MIT","funding":"https://ko-fi.com/bybrave","engines":{"node":">=18"},"devDependencies":{"@types/node":"^20.14.0","typescript":"^5.5.0"},"_id":"@bybrave/concat-stream2@3.0.1","gitHead":"91d413ec11a9e1c15d57a25855beca817060b74a","_nodeVersion":"20.19.6","_npmVersion":"10.8.2","dist":{"integrity":"sha512-aobFfAdnqXGInyEaoP4GTCcpTRWG2C7hZwp1ak5RBz/8S45y7f4a5qM+BQz6MUj2QxZw5JHsoBvKT774S3phSw==","shasum":"42be6a45a0c285d7f0c6ae0eb5df29e40c2b3567","tarball":"https://registry.npmjs.org/@bybrave/concat-stream2/-/concat-stream2-3.0.1.tgz","fileCount":6,"unpackedSize":13151,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDH2x/Z66BONITcIIkNWV4YvXno4FjfJeH9hjaHJM3I9gIhANH9BTlJ9xWHg/POqIy6MgaZ0nvq4XjjAoW5Nd1Z6DPV"}]},"_npmUser":{"name":"bybrave","email":"opmybrave@gmail.com"},"directories":{},"maintainers":[{"name":"bybrave","email":"opmybrave@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/concat-stream2_3.0.1_1783297133744_0.3525436325485187"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-05T22:58:04.603Z","modified":"2026-07-06T00:18:53.989Z","3.0.0":"2026-07-05T22:58:04.991Z","3.0.1":"2026-07-06T00:18:53.873Z"},"bugs":{"url":"https://github.com/bybraveHQ/concat-stream2/issues"},"author":{"name":"bybrave","url":"https://github.com/bybraveHQ"},"license":"MIT","homepage":"https://github.com/bybraveHQ/concat-stream2#readme","keywords":["concat","stream","writable","buffer","concat-stream","collect","zero-dependency","typescript","esm"],"repository":{"type":"git","url":"git+https://github.com/bybraveHQ/concat-stream2.git"},"description":"Maintained fork of concat-stream — zero runtime dependencies, dual ESM+CJS, and bundled TypeScript types (no separate @types/concat-stream needed)","contributors":[{"name":"Max Ogden","url":"author of the original concat-stream"}],"maintainers":[{"name":"bybrave","email":"opmybrave@gmail.com"}],"readme":"# @bybrave/concat-stream2\n\n[![CI](https://github.com/bybraveHQ/concat-stream2/actions/workflows/ci.yml/badge.svg)](https://github.com/bybraveHQ/concat-stream2/actions)\n[![npm](https://img.shields.io/npm/v/%40bybrave%2Fconcat-stream2)](https://www.npmjs.com/package/@bybrave/concat-stream2)\n\nMaintained fork of [`concat-stream`](https://github.com/maxogden/concat-stream) — a writable stream that concatenates all the data written to it and hands the result to a callback — with **zero runtime dependencies, dual ESM + CommonJS, and TypeScript types built in**.\n\nThe original has ~159M downloads/month and no release since December 2018. It still pulls `readable-stream`, `inherits`, `buffer-from` and `typedarray` — four polyfills that only ever mattered for legacy and browser runtimes. On any supported Node they are dead weight, and they drag transitive-dependency audit noise ([#64](https://github.com/maxogden/concat-stream/issues/64)) along with them. This fork keeps the concatenation logic **byte-for-byte identical** (verified against the original's own test suite) and drops every dependency.\n\n```bash\nnpm install @bybrave/concat-stream2\n```\n\n```js\n// CommonJS — drop-in\nconst concat = require('@bybrave/concat-stream2');\n\n// ESM — default or named import\nimport concat from '@bybrave/concat-stream2';\nimport { concat } from '@bybrave/concat-stream2';\n\n// TypeScript types built in — no @types/concat-stream needed\n```\n\n## Usage\n\nExactly the same API as the original. Pass an optional options object and a callback; write data; the callback fires on `finish` with everything concatenated.\n\n```js\nconst concat = require('@bybrave/concat-stream2');\nconst fs = require('fs');\n\nconst write = concat({ encoding: 'string' }, (data) => {\n  console.log(data);\n});\n\nfs.createReadStream('cat.png').pipe(write);\n```\n\n`encoding` decides the shape of the value handed to your callback. When omitted it is inferred from the first chunk written.\n\n| `encoding` | Callback receives |\n|---|---|\n| `'buffer'` (or inferred from a Buffer) | a `Buffer` |\n| `'string'` | a `string` |\n| `'array'` | a flat `Array` |\n| `'uint8array'` (aliases `'u8'`, `'uint8'`) | a `Uint8Array` |\n| `'object'` | an `Array` of the written objects |\n\n## Why this fork\n\n| Fixed / improved | Original issue |\n|---|---|\n| **Zero runtime dependencies** — `readable-stream`, `inherits`, `buffer-from`, `typedarray` replaced with native `node:stream`, `class`/`util.inherits`, `Buffer.from`, `Uint8Array` | [#69](https://github.com/maxogden/concat-stream/issues/69) |\n| **No more transitive-dependency audit alerts** — the whole dependency chain is gone | [#64](https://github.com/maxogden/concat-stream/issues/64) |\n| **No `Buffer()` deprecation warnings** — modern `Buffer.from` / zero-filled `Uint8Array` throughout | [#58](https://github.com/maxogden/concat-stream/issues/58), [#57](https://github.com/maxogden/concat-stream/issues/57), [#56](https://github.com/maxogden/concat-stream/issues/56), [#55](https://github.com/maxogden/concat-stream/issues/55) |\n| **Dual ESM + CommonJS** — `import` and `require` both work, from one implementation | — |\n| **Built-in TypeScript types** — replaces the separate `@types/concat-stream` package | — |\n\nThe core concatenation algorithm (`getBody`, `inferEncoding`, and the per-encoding concatenators) is unchanged from the original and gated by a byte-for-byte golden test that runs the original and the fork over the same inputs.\n\n## Migration\n\nDrop-in for the overwhelming majority of uses — change the dependency name and you're done:\n\n```diff\n- const concat = require('concat-stream');\n+ const concat = require('@bybrave/concat-stream2');\n```\n\n```diff\n- \"concat-stream\": \"^2.0.0\",\n- \"@types/concat-stream\": \"^2.0.0\",\n+ \"@bybrave/concat-stream2\": \"^3.0.0\",\n```\n\nRemove `@types/concat-stream` — the types ship with this package.\n\n**Requires Node.js >= 18.** If you need to run on legacy Node or bundle for old browsers, stay on the original `concat-stream`; that's exactly the environment its polyfills existed for.\n\n## Error handling (by design)\n\n`concat-stream` is **not** a transform stream and intentionally does not forward upstream errors ([#50](https://github.com/maxogden/concat-stream/issues/50), [#37](https://github.com/maxogden/concat-stream/issues/37)). The callback receives only the concatenated data — `cb(data)`, not `cb(err, data)`. Handle source errors on the pipeline, as you always did:\n\n```js\nsource.on('error', handleError);\nsource.pipe(concat(onData));\n```\n\nThis behaviour is preserved deliberately for drop-in compatibility. If you specifically want error propagation, use a pipeline: `stream.pipeline(source, concat(onData), done)`.\n\n## Native alternative\n\nIf you only target modern Node and don't need drop-in compatibility with packages that already depend on `concat-stream`, the built-in [`stream/consumers`](https://nodejs.org/api/webstreams.html#utility-consumer) covers the common cases directly ([#68](https://github.com/maxogden/concat-stream/issues/68)):\n\n```js\nconst consumers = require('node:stream/consumers');\nconst buf = await consumers.buffer(source);\nconst text = await consumers.text(source);\n```\n\nThis fork exists for the millions of dependents that use the `concat-stream` API and want it maintained, dependency-free, and typed.\n\n## Support\n\nIf this package saves you time, you can support maintenance:\n\n[![Ko-fi](https://img.shields.io/badge/Ko--fi-buy%20me%20a%20coffee-FF5E5B?logo=kofi&logoColor=white)](https://ko-fi.com/bybrave)\n[![Bitcoin](https://img.shields.io/badge/Bitcoin-BTC-F7931A?logo=bitcoin&logoColor=white)](#support)\n\nBitcoin (BTC): `bc1q37557q5jpeaxqydzwvf3jgj7zhnfpn2td3q40q`\n\n## License\n\nMIT. Copyright (c) 2013 Max Ogden (original `concat-stream`), copyright (c) 2026 bybrave (fork). See [LICENSE](./LICENSE).\n","readmeFilename":"README.md"}