{"name":"bufferstreams","version":"5.0.0","keywords":["buffer","streaming","stream","async","abstract"],"author":{"url":"http://insertafter.com/en/index.html","name":"Nicolas Froidure","email":"nicolas.froidure@insertafter.com"},"license":"MIT","_id":"bufferstreams@5.0.0","maintainers":[{"name":"nfroidure","email":"nicolas.froidure@insertafter.com"},{"name":"shinnn","email":"snnskwtnb@gmail.com"}],"contributors":[],"homepage":"https://github.com/nfroidure/BufferStreams","bugs":{"url":"https://github.com/nfroidure/BufferStreams/issues"},"dist":{"shasum":"0fbc028798e0bd2706601c49a47ebdd6bf165a43","tarball":"http://registry-npm.ywwl.com/bufferstreams/download/bufferstreams-5.0.0.tgz","fileCount":12,"integrity":"sha512-wXeD2OUyCb6K8akKT1+A7y/daw7Cii7v8idSK7/pV18VwKZW65uczCoCjM0buyQPilUPV7S6PrKqLipQ4HXcXQ==","signatures":[{"sig":"MEQCICCnVPfdneHrfyorDf7GGPLSdACgRMPqkHqGa87k5dXEAiAR1vmllRyhge1x7mYQu8r8Wq6bwzjGnB0BtQ8Df1E6Kw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":67868,"size":13486,"noattachment":false,"key":"/bufferstreams/-/bufferstreams-5.0.0.tgz"},"jest":{"roots":["<rootDir>/src"],"transform":{"^.+\\.tsx?$":["@swc/jest",{}]},"prettierPath":null,"testEnvironment":"node","moduleNameMapper":{"(.+)\\.js":"$1"},"coverageReporters":["lcov"],"extensionsToTreatAsEsm":[".ts"],"testPathIgnorePatterns":["/node_modules/"]},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"engines":{"node":">=22.16.0"},"funding":{"url":"https://github.com/sponsors/nfroidure","type":"individual"},"gitHead":"fd774b616de1171c86df137b1673f3bdcf4b5bf3","metapak":{"data":{"files":"'src/**/*.ts'","ignore":["dist"],"distFiles":"'dist/**/*.js'","testsFiles":"'src/**/*.tests.ts'","bundleFiles":["dist","src"]},"configs":["main","readme","eslint","tsesm","jest","jsdocs","codeclimate","coveralls","ghactions"]},"scripts":{"cz":"env NODE_ENV=${NODE_ENV:-cli} git cz","cli":"env NODE_ENV=${NODE_ENV:-cli}","doc":"echo \"# API\" > API.md; jsdoc2md 'dist/**/*.js' >> API.md && git add API.md","jest":"NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest","lint":"eslint 'src/**/*.ts'","test":"node --run jest","build":"rimraf 'dist' && tsc --outDir dist","cover":"node --run jest -- --coverage","precz":"node --run test && node --run lint && node --run build && node --run doc && node --run metapak -- -s","format":"npm run prettier","metapak":"metapak","rebuild":"swc ./src -s -d dist -C jsc.target=es2022","version":"node --run changelog","prettier":"prettier --write 'src/**/*.ts'","changelog":"conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md","preversion":"node --run test && node --run lint && node --run build && node --run doc && node --run metapak -- -s"},"_npmUser":{"name":"nfroidure","email":"nicolas.froidure@insertafter.com"},"prettier":{"semi":true,"proseWrap":"always","printWidth":80,"singleQuote":true,"trailingComma":"all"},"repository":{"url":"git+https://github.com/nfroidure/bufferstreams.git","type":"git"},"_npmVersion":"10.9.2","description":"Abstract streams to deal with the whole buffered contents.","directories":{},"greenkeeper":{"ignore":["commitizen","cz-conventional-changelog","conventional-changelog-cli","eslint","prettier","eslint-config-prettier","eslint-plugin-prettier","typescript-eslint","typescript","rimraf","@swc/cli","@swc/core","@swc/helpers","jest","@swc/jest","jsdoc-to-markdown"]},"_nodeVersion":"22.16.0","dependencies":{"yerror":"^8.0.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^30.0.0","eslint":"^9.29.0","rimraf":"^6.0.1","metapak":"^6.0.3","@swc/cli":"^0.7.7","prettier":"^3.5.3","@swc/core":"^1.12.1","@swc/jest":"^0.2.38","@eslint/js":"^9.29.0","commitizen":"^4.3.1","streamtest":"^3.0.1","typescript":"^5.8.3","@swc/helpers":"^0.5.17","jsdoc-to-markdown":"^9.1.1","metapak-nfroidure":"20.0.4","typescript-eslint":"^8.34.0","eslint-plugin-jest":"^28.14.0","eslint-config-prettier":"^10.1.5","eslint-plugin-prettier":"^5.4.1","cz-conventional-changelog":"^3.3.0","conventional-changelog-cli":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/bufferstreams_5.0.0_1750086105078_0.38136279589509536","host":"s3://npm-registry-packages-npm-production"},"readme":"[//]: # ( )\n[//]: # (This file is automatically generated by a `metapak`)\n[//]: # (module. Do not change it  except between the)\n[//]: # (`content:start/end` flags, your changes would)\n[//]: # (be overridden.)\n[//]: # ( )\n# bufferstreams\n> Abstract streams to deal with the whole buffered contents.\n\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/nfroidure/bufferstreams/blob/main/LICENSE)\n[![Coverage Status](https://coveralls.io/repos/github/nfroidure/bufferstreams/badge.svg?branch=main)](https://coveralls.io/github/nfroidure/bufferstreams?branch=main)\n\n\n[//]: # (::contents:start)\n\n`bufferstreams` abstracts streams to allow you to deal with their whole content\nin a single buffer when it becomes necessary (by example: a legacy library that\ndo not support streams).\n\nIt is not a good practice (dealing with the whole stream content means you need\nto keep the whole stream content in memory which is probably not what you intent\nby using streams), just some glue. Using `bufferstreams` means:\n\n- there is no library dealing with streams for your needs\n- you filled an issue to the wrapped library to support streams\n\n`bufferstreams` can also be used to control the whole stream content in a single\npoint of a streaming pipeline for testing purposes.\n\n## Usage\n\nInstall the [npm module](https://npmjs.org/package/bufferstreams):\n\n```sh\nnpm install bufferstreams --save\n```\n\nThen, in your scripts:\n\n```js\nimport fs from 'fs';\nimport { BufferStream } from 'bufferstreams';\n\nfs.createReadStream('input.txt')\n  .pipe(\n    new BufferStream((err, buf, cb) => {\n      // err will be filled with an error if the piped in stream emits one.\n      if (err) {\n        throw err;\n      }\n\n      // buf will contain the whole piped in stream contents\n      buf = Buffer.from(buf.toString('utf-8').replace('foo', 'bar'));\n\n      // cb is a callback to pass the result back to the piped out stream\n      // first argument is an error that will be emitted if any\n      // the second argument is the modified buffer\n      cb(null, buf);\n    }),\n  )\n  .pipe(fs.createWriteStream('output.txt'));\n```\n\nNote that you can use `bufferstreams` with the objectMode option. In this case,\nthe given buffer will be an array containing the streamed objects:\n\n```js\nnew BufferStreams(myCallback, { objectMode: true });\n```\n\n`bufferstreams` exposes a utility function for functional programming:\n\n```js\nimport { streamBuffer } from 'bufferstreams';\n\nprocess.stdin.pipe(streamBuffer(myCallback)).pipe(process.stdout);\n```\n\nFinally `bufferstreams` exposes another function for objects mode buffering:\n\n```js\nimport { bufferObjects } from 'bufferstreams';\n\nprocess.stdin.pipe(bufferObjects(myCallback)).pipe(process.stdout);\n```\n\n## Contributing\n\nFeel free to contribute with your code if you agree with publishing it under the\nMIT license.\n\n[//]: # (::contents:end)\n\n# API\n## Classes\n\n<dl>\n<dt><a href=\"#BufferStream\">BufferStream</a></dt>\n<dd><p>Buffer the stream content and bring it into the provided callback</p>\n</dd>\n</dl>\n\n## Functions\n\n<dl>\n<dt><a href=\"#bufferStream\">bufferStream(bufferCallback, options)</a> ⇒</dt>\n<dd><p>Utility function if you prefer a functional way of using this lib</p>\n</dd>\n<dt><a href=\"#bufferObjects\">bufferObjects(bufferCallback, options)</a> ⇒</dt>\n<dd><p>Utility function to buffer objet mode streams</p>\n</dd>\n</dl>\n\n<a name=\"BufferStream\"></a>\n\n## BufferStream\nBuffer the stream content and bring it into the provided callback\n\n**Kind**: global class  \n<a name=\"new_BufferStream_new\"></a>\n\n### new BufferStream(bufferCallback, options)\n\n| Param | Type | Description |\n| --- | --- | --- |\n| bufferCallback | <code>function</code> | A function to handle the buffered content. |\n| options | <code>Object</code> | inherits of Stream.Duplex, the options are passed to the parent constructor so you can use it's options too. |\n| options.objectMode | <code>boolean</code> | Use if piped in streams are in object mode. In this case, an array of the buffered will be transmitted to the callback function. |\n\n<a name=\"bufferStream\"></a>\n\n## bufferStream(bufferCallback, options) ⇒\nUtility function if you prefer a functional way of using this lib\n\n**Kind**: global function  \n**Returns**: Stream  \n\n| Param |\n| --- |\n| bufferCallback | \n| options | \n\n<a name=\"bufferObjects\"></a>\n\n## bufferObjects(bufferCallback, options) ⇒\nUtility function to buffer objet mode streams\n\n**Kind**: global function  \n**Returns**: Stream  \n\n| Param |\n| --- |\n| bufferCallback | \n| options | \n\n\n# Authors\n- [Nicolas Froidure](http://insertafter.com/en/index.html)\n\n# License\n[MIT](https://github.com/nfroidure/bufferstreams/blob/main/LICENSE)\n","publish_time":1750086105307,"_cnpm_publish_time":1750086105307,"dist-tags":{"latest":"6.0.1"}}