{"_id":"which-stream","_rev":"299748","name":"which-stream","description":"A small Node.JS library to determine which stream to use.","dist-tags":{"latest":"1.2.1"},"maintainers":[{"name":"zvr","email":""}],"time":{"modified":"2024-01-31T16:04:21.000Z","created":"2018-08-11T21:12:54.387Z","1.2.1":"2019-08-03T00:30:36.812Z","1.2.0":"2019-08-03T00:28:30.903Z","1.1.0":"2019-04-19T20:05:17.074Z","1.0.1":"2018-09-01T00:15:18.120Z","1.0.0":"2018-08-11T21:12:54.387Z"},"users":{},"author":{"name":"Anton","email":"anton@adc.sh"},"repository":{"type":"git","url":"git://github.com/artdecocode/which-stream.git"},"versions":{"1.2.1":{"name":"which-stream","version":"1.2.1","description":"A small Node.JS library to determine which stream to use.","main":"compile/index.js","module":"src/index.js","scripts":{"t":"zoroaster -a","test":"yarn t test/spec","test-compile":"ALAMODE_ENV=test-compile yarn test","compile":"depack-dev src/depack -o compile/which-stream.js -a -c -p -s -O 2018 --source_map_include_content","lint":"eslint .","doc":"NODE_DEBUG=doc doc -o README.md","rec":"NODE_DEBUG=appshot appshot -T 23 -a Terminal -y 150 -f","e":"node example","d1":"typal compile/index.js -c","externs":"typal types/externs.js -e","d":"yarn-s d1 externs"},"externs":"types/externs.js","repository":{"type":"git","url":"git://github.com/artdecocode/which-stream.git"},"keywords":["which-stream","stream","stdout","stderr","source","destination","io","input","output","Writable","Readable","ReadStream","WriteStream","fs","filesystem","file","-"],"author":{"name":"Anton","email":"anton@adc.sh"},"license":"MIT","bugs":{"url":"https://github.com/artdecocode/which-stream/issues"},"homepage":"https://github.com/artdecocode/which-stream#readme","devDependencies":{"@wrote/ensure-path":"^1.1.0","alamode":"^2.3.6","documentary":"^1.29.0","eslint-config-artdeco":"1.0.1","yarn-s":"1.1.0","zoroaster":"^4.1.1-alpha"},"srcDependencies":{"catchment":"^3.3.0"},"licenseText":"MIT License\n\nCopyright (c) 2018 Art Deco Code Limited\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"which-stream@1.2.1","dist":{"shasum":"5c33c86102453634e11f336c1d32dcaee391d906","size":14298,"noattachment":false,"key":"/which-stream/-/which-stream-1.2.1.tgz","tarball":"http://name.csiicloud.com:7001/which-stream/download/which-stream-1.2.1.tgz"},"maintainers":[{"name":"zvr","email":""}],"_npmUser":{"name":"zvr","email":"anton@adc.sh"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/which-stream_1.2.1_1564792236638_0.03060044142240481"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-19T19:19:16.493Z","publish_time":1564792236812,"_cnpm_publish_time":1564792236812},"1.2.0":{"name":"which-stream","version":"1.2.0","description":"A small Node.JS library to determine which stream to use.","main":"compile/index.js","module":"src/index.js","scripts":{"t":"zoroaster -a","test":"yarn t test/spec","test-compile":"ALAMODE_ENV=test-compile yarn test","compile":"depack-dev src/depack -o compile/which-stream.js -a -c -p -s -O 2018 --source_map_include_content","lint":"eslint .","doc":"NODE_DEBUG=doc doc -o README.md","rec":"NODE_DEBUG=appshot appshot -T 23 -a Terminal -y 150 -f","e":"node example","d1":"typal compile/index.js -c","externs":"typal types/externs.js -e","d":"yarn-s d1 externs"},"externs":"externs.js","repository":{"type":"git","url":"git://github.com/artdecocode/which-stream.git"},"keywords":["which-stream","stream","stdout","stderr","source","destination","io","input","output","Writable","Readable","ReadStream","WriteStream","fs","filesystem","file","-"],"author":{"name":"Anton","email":"anton@adc.sh"},"license":"MIT","bugs":{"url":"https://github.com/artdecocode/which-stream/issues"},"homepage":"https://github.com/artdecocode/which-stream#readme","devDependencies":{"@wrote/ensure-path":"^1.1.0","alamode":"^2.3.6","documentary":"^1.29.0","eslint-config-artdeco":"1.0.1","yarn-s":"1.1.0","zoroaster":"^4.1.1-alpha"},"srcDependencies":{"catchment":"^3.3.0"},"licenseText":"MIT License\n\nCopyright (c) 2018 Art Deco Code Limited\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"which-stream@1.2.0","dist":{"shasum":"378b2bfad780365c2395a3198e9bfec564a75076","size":14283,"noattachment":false,"key":"/which-stream/-/which-stream-1.2.0.tgz","tarball":"http://name.csiicloud.com:7001/which-stream/download/which-stream-1.2.0.tgz"},"maintainers":[{"name":"zvr","email":""}],"_npmUser":{"name":"zvr","email":"anton@adc.sh"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/which-stream_1.2.0_1564792110695_0.6141330340677311"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-19T19:19:15.623Z","publish_time":1564792110903,"_cnpm_publish_time":1564792110903},"1.1.0":{"name":"which-stream","version":"1.1.0","description":"A small Node.JS library to determine which stream to use.","main":"build/index.js","module":"src/index.js","scripts":{"t":"zoroaster -a","test":"yarn t test/spec","test-build":"ALAMODE_ENV=test-build yarn test","test-all":"yarn-s test test-build","test-watch":"yarn test -w","lint":"eslint .","doc":"NODE_DEBUG=doc doc documentary -o README.md","rec":"NODE_DEBUG=appshot appshot -T 23 -a Terminal -y 150 -f","e":"node example","d1":"typal src -c","externs":"typal externs.js -e","d":"yarn-s d1 externs","example/source-destination.js":"yarn e example/source-destination.js","example/source-writable.js":"yarn e example/source-writable.js","example/source-stdout.js":"yarn e example/source-stdout.js","example/readable-destination.js":"yarn e example/readable-destination.js","example/readable-destination-overwrite.js":"yarn e example/readable-destination-overwrite.js","example/readable-writable.js":"yarn e example/readable-writable.js","example/readable-stdout.js":"yarn e example/readable-stdout.js","build":"yarn-s b doc","b":"alamode src -o build -s"},"externs":"externs.js","repository":{"type":"git","url":"git://github.com/artdecocode/which-stream.git"},"keywords":["which-stream","stream","stdout","stderr","source","destination","io","input","output","Writable","Readable","ReadStream","WriteStream","fs","filesystem","file","-"],"author":{"name":"Anton","email":"anton@adc.sh"},"license":"MIT","bugs":{"url":"https://github.com/artdecocode/which-stream/issues"},"homepage":"https://github.com/artdecocode/which-stream#readme","devDependencies":{"@wrote/ensure-path":"^1.0.8","alamode":"^1.9.3","documentary":"^1.24.1","eslint-config-artdeco":"1.0.1","yarn-s":"1.1.0","zoroaster":"^3.11.6"},"dependencies":{"catchment":"^3.3.0"},"licenseText":"MIT License\n\nCopyright (c) 2018 Art Deco Code Limited\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"which-stream@1.1.0","dist":{"shasum":"7a57ddf20b8b33d27df7e1706760294aa931ea8a","size":5819,"noattachment":false,"key":"/which-stream/-/which-stream-1.1.0.tgz","tarball":"http://name.csiicloud.com:7001/which-stream/download/which-stream-1.1.0.tgz"},"maintainers":[{"name":"zvr","email":""}],"_npmUser":{"name":"zvr","email":"anton@adc.sh"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/which-stream_1.1.0_1555704316948_0.4688968195148693"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-19T19:19:14.735Z","publish_time":1555704317074,"_cnpm_publish_time":1555704317074},"1.0.1":{"name":"which-stream","version":"1.0.1","description":"A small Node.js library to determine which stream to use.","main":"build","scripts":{"t":"zoroaster -a","test":"yarn t test/spec","test-build":"ALAMODE_ENV=test-build yarn test","test-all":"yarn-s test test-build","test-watch":"yarn test -w","lint":"eslint .","doc":"NODE_DEBUG=doc doc documentary -o README.md","rec":"NODE_DEBUG=appshot appshot -T 23 -a Terminal -y 150 -f","e":"node example","example/source-destination.js":"yarn e example/source-destination.js","example/source-writable.js":"yarn e example/source-writable.js","example/source-stdout.js":"yarn e example/source-stdout.js","example/readable-destination.js":"yarn e example/readable-destination.js","example/readable-destination-overwrite.js":"yarn e example/readable-destination-overwrite.js","example/readable-writable.js":"yarn e example/readable-writable.js","example/readable-stdout.js":"yarn e example/readable-stdout.js","build":"yarn-s b doc","b":"alamode src -o build","postpublish":"git push --follow-tags"},"repository":{"type":"git","url":"git://github.com/artdecocode/which-stream.git"},"keywords":["which-stream","stream","stdout","stderr","source","destination","io","input","output","Writable","Readable","ReadStream","WriteStream","fs","filesystem","file","-"],"author":{"name":"Anton","email":"anton@adc.sh"},"license":"MIT","bugs":{"url":"https://github.com/artdecocode/which-stream/issues"},"homepage":"https://github.com/artdecocode/which-stream#readme","devDependencies":{"@wrote/ensure-path":"1.0.2","alamode":"1.3.0","documentary":"1.10.0","eslint-config-artdeco":"1.0.1","yarn-s":"1.1.0","zoroaster":"2.4.0"},"dependencies":{"catchment":"3.0.1"},"licenseText":"MIT License\n\nCopyright (c) 2018 Art Deco Code Limited\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"which-stream@1.0.1","dist":{"shasum":"2b495b083b1c31ff68dd4d770b0caa7f86e769af","size":5915,"noattachment":false,"key":"/which-stream/-/which-stream-1.0.1.tgz","tarball":"http://name.csiicloud.com:7001/which-stream/download/which-stream-1.0.1.tgz"},"maintainers":[{"name":"zvr","email":""}],"_npmUser":{"name":"zvr","email":"anton@adc.sh"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/which-stream_1.0.1_1535760917979_0.019151886664123374"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-19T19:19:13.788Z","publish_time":1535760918120,"_cnpm_publish_time":1535760918120},"1.0.0":{"name":"which-stream","version":"1.0.0","description":"A small Node.js library to determine which stream to use.","main":"build","scripts":{"t":"zoroaster -b","test":"zoroaster -b test/spec","test-build":"BABEL_ENV=test-build yarn test","test-all":"yarn-s test test-build","test-watch":"yarn test -w","lint":"eslint .","doc":"NODE_DEBUG=doc doc documentary -o README.md","rec":"NODE_DEBUG=appshot appshot -T 23 -a Terminal -y 150 -f","e":"node example","example/source-destination.js":"yarn e example/source-destination.js","example/source-writable.js":"yarn e example/source-writable.js","example/source-stdout.js":"yarn e example/source-stdout.js","example/readable-destination.js":"yarn e example/readable-destination.js","example/readable-destination-overwrite.js":"yarn e example/readable-destination-overwrite.js","example/readable-writable.js":"yarn e example/readable-writable.js","example/readable-stdout.js":"yarn e example/readable-stdout.js","build":"yarn-s b doc","b":"b --source-maps"},"files":["build"],"repository":{"type":"git","url":"git://github.com/artdecocode/which-stream.git"},"keywords":["which-stream","stream","stdout","stderr","source","destination","io","input","output","Writable","Readable","ReadStream","WriteStream","fs","filesystem","file","-"],"author":{"name":"Anton","email":"anton@adc.sh"},"license":"MIT","bugs":{"url":"https://github.com/artdecocode/which-stream/issues"},"homepage":"https://github.com/artdecocode/which-stream#readme","devDependencies":{"@wrote/ensure-path":"1.0.2","documentary":"1.8.2","eslint-config-artdeco":"1.0.1","yarn-s":"1.1.0","zoroaster":"2.1.0"},"dependencies":{"catchment":"3.0.0"},"licenseText":"MIT License\n\nCopyright (c) 2018 Art Deco Code Limited\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"which-stream@1.0.0","dist":{"shasum":"1c28212ce6a1d590619ad8683bfc58c17bf63b3d","size":4956,"noattachment":false,"key":"/which-stream/-/which-stream-1.0.0.tgz","tarball":"http://name.csiicloud.com:7001/which-stream/download/which-stream-1.0.0.tgz"},"maintainers":[{"name":"zvr","email":""}],"_npmUser":{"name":"zvr","email":"anton@adc.sh"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/which-stream_1.0.0_1534021974286_0.6743123983323622"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-19T19:19:12.934Z","publish_time":1534021974387,"_cnpm_publish_time":1534021974387}},"readme":"# which-stream\n\n[![npm version](https://badge.fury.io/js/which-stream.svg)](https://npmjs.org/package/which-stream)\n\n`which-stream` is a small Node.JS library to pipe an input stream to an output one. It can create filesystem's read and write streams, or use provided ones, as well as piping output to the `stdout`.\n\n```sh\nyarn add which-stream\n```\n\n<p align=\"center\"><a href=\"#table-of-contents\">\n  <img src=\"/.documentary/section-breaks/0.svg?sanitize=true\">\n</a></p>\n\n## Table Of Contents\n\n- [Table Of Contents](#table-of-contents)\n- [API](#api)\n- [`async whichStream(config: Config)`](#async-whichstreamconfig-config-void)\n  * [`_whichStream.Config`](#type-_whichstreamconfig)\n- [Use Cases](#use-cases)\n  * [Source to Destination](#source-to-destination)\n  * [Source to Writable](#source-to-writable)\n  * [Source to Stdout](#source-to-stdout)\n  * [Readable to Destination](#readable-to-destination)\n  * [Readable to Destination (Overwriting)](#readable-to-destination-overwriting)\n  * [Readable to Writable](#readable-to-writable)\n  * [Readable to Stdout](#readable-to-stdout)\n- [Copyright](#copyright)\n\n<p align=\"center\"><a href=\"#table-of-contents\">\n  <img src=\"/.documentary/section-breaks/1.svg?sanitize=true\">\n</a></p>\n\n## API\n\nThe package is available by importing its default function:\n\n```js\nimport whichStream from 'which-stream'\n```\n\nThe types and [externs](externs.js) for _Google Closure Compiler_ via [**_Depack_**](https://github.com/dpck/depack) are defined in the `_whichStream` namespace.\n\n<p align=\"center\"><a href=\"#table-of-contents\">\n  <img src=\"/.documentary/section-breaks/2.svg?sanitize=true\">\n</a></p>\n\n## `async whichStream(`<br/>&nbsp;&nbsp;`config: Config,`<br/>`): void`\n\nThe `whichStream` function will determine which streams to use by creating readable and writable streams when source and/or destination are passed as strings, pipe the input to the output, and wait for the output to finish.\n\n<strong><a name=\"type-_whichstreamconfig\">`_whichStream.Config`</a></strong>: The configuration object.\n\n\n|    Name     |                                             Type                                             |                                                                                                                                                                                        Description                                                                                                                                                                                        |\n| ----------- | -------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| source      | <em>string</em>                                                                              | The path to a source file from which to read data.                                                                                                                                                                                                                                                                                                                                        |\n| readable    | <em>[!stream.Readable](https://nodejs.org/api/stream.html#stream_class_stream_readable)</em> | An optional input stream, if the `source` is not given.                                                                                                                                                                                                                                                                                                                                   |\n| destination | <em>string</em>                                                                              | The path to an output file. If `-` is given, `process.stdout` will be used. If the path of the input stream is the same as of the output one, the result will be first written to the memory, and only then to the destination file. Moreover, when used with the `readable` specified to overwrite the file from which data is originally read from, the `source` should also be passed. |\n| writable    | <em>[!stream.Writable](https://nodejs.org/api/stream.html#stream_class_stream_writable)</em> | A stream into which to pipe the input stream, if `destination` is not given.                                                                                                                                                                                                                                                                                                              |\n\n<p align=\"center\"><a href=\"#table-of-contents\">\n  <img src=\"/.documentary/section-breaks/3.svg?sanitize=true\">\n</a></p>\n\n## Use Cases\n\nBelow is the list of possible use cases when `which-stream` package could be used.\n\n### Source to Destination\n\nWhen the `source` and `destination` are passed, a file is be copied as it is.\n\n```js\n/* yarn example/source-destination.js */\nimport whichStream from 'which-stream'\nimport { createReadStream } from 'fs'\n\n(async () => {\n  const source = 'example/millet.txt'\n  const destination = 'example/millet-out.txt'\n  await whichStream({\n    source,\n    destination,\n  })\n  // verify\n  const rs = createReadStream(destination)\n  rs.pipe(process.stdout)\n})()\n```\n\n```\nMillet (gluten-free):\nAn excellet source of manganese, magnesioum, and phosphorus.\n```\n\n### Source to Writable\n\nWhen the `source` and `writable` are supplied, a stream pushing input text from the source file will be piped into the given output writable stream.\n\n```js\n/* yarn example/source-writable.js */\nimport whichStream from 'which-stream'\nimport { Transform } from 'stream';\n\n(async () => {\n  const source = 'example/brown-rice.txt'\n  const writable = new Transform({\n    transform(data, encoding, next) {\n      const d = `${data}`.toUpperCase()\n      this.push(d)\n      next()\n    },\n  })\n  writable.pipe(process.stdout) // to verify\n  await whichStream({\n    source,\n    writable,\n  })\n})()\n```\n\n```\nBROWN RICE (GLUTEN-FREE):\nUNLIKE WHITE RICE, BROWN RICE IS REACH WITH VITAMINS,\nMINERALS, FIBRE AND FATTY ACIDS.\n```\n\n### Source to Stdout\n\nTo print a file to `stdout`, the destination should be set to `-` .\n\n```js\n/* yarn example/source-stdout.js */\nimport whichStream from 'which-stream'\n\n(async () => {\n  await whichStream({\n    source: 'example/zinc.txt',\n    destination: '-',\n  })\n})()\n```\n\n```\nZINC: an often-overlooked essential mineral, zinc is the\nmost common mineral found in the body after iron.\n```\n\n### Readable to Destination\n\nPassing both the `readable` and `destination` properties will ensure that the input stream is written to the destination on the disk.\n\n```js\n/* yarn example/readable-destination.js */\nimport whichStream from 'which-stream'\nimport { createReadStream } from 'fs'\nimport { Readable } from 'stream';\n\n(async () => {\n  const destination = 'example/thiamine-out.txt'\n  const readable = new Readable({\n    read() {\n      this.push(`\nVitamin B1 (Thiamine): essential for proper functioning of\nthe heart, muscles and nervous system.\n`.trim()\n      )\n      this.push(null)\n    },\n  })\n  await whichStream({\n    readable,\n    destination,\n  })\n  // verify\n  const rs = createReadStream(destination)\n  rs.pipe(process.stdout)\n})()\n```\n\n```\nVitamin B1 (Thiamine): essential for proper functioning of\nthe heart, muscles and nervous system.\n```\n\n### Readable to Destination (Overwriting)\n\nIf `readable`'s data initially comes from the same source as the destination to which it will be written, the `source` property must also be set to make sure that the file is overwritten properly. The stream's data will first be buffered in memory, and upon the readable stream's end it will be released to the destination. This is useful when using transform streams which don't necessary read from the source themselves, but are being piped into by another readable.\n\n```js\n/* yarn example/readable-destination-overwrite.js */\nimport whichStream from 'which-stream'\nimport { createReadStream } from 'fs'\nimport { Transform } from 'stream'\n\n(async () => {\n  const source = 'example/onions.txt'\n  const readable = new Transform({\n    transform(data, encoding, next) {\n      const d = `${data}`.replace(\n        /Modified: (.+)/m,\n        `Modified: ${new Date().toDateString()}`,\n      )\n      this.push(d)\n      next()\n    },\n  })\n  const rs = createReadStream(source)\n  rs.pipe(readable)\n  await whichStream({\n    source,\n    readable,\n    destination: source,\n  })\n  // verify\n  const vrs = createReadStream(source)\n  vrs.pipe(process.stdout)\n})()\n```\n\n```\nBuy a bag of onions, chop in food processor, toss into\nplastic zip bag, and stow in freezer.\nModified: Sat Aug 03 2019\n```\n\nIn case the `source` is not passed, the file will become empty.\n\n### Readable to Writable\n\nIn the scenario when the `readable` and `writable` are specified, the former will be piped into the latter, and the function's promise will be resolved when the writable finishes.\n\n```js\n/* yarn example/readable-writable.js */\nimport whichStream from 'which-stream'\nimport { Readable, Transform } from 'stream';\n\n(async () => {\n  const readable = new Readable({\n    read() {\n      this.push(`\nOmega-3 fatty acids boost heart health, lower\ntriglycerides, and may help in the treatment\nand prevention of depression.\n`.trim()\n      )\n      this.push(null)\n    },\n  })\n  const writable = new Transform({\n    transform(data, encoding, next) {\n      const d = `*${data}*`\n      this.push(d)\n      next()\n    },\n  })\n  writable.pipe(process.stdout) // to verify\n  await whichStream({\n    readable,\n    writable,\n  })\n})()\n```\n\n```markdown\n*Omega-3 fatty acids boost heart health, lower\ntriglycerides, and may help in the treatment\nand prevention of depression.*\n```\n\n### Readable to Stdout\n\nWhen a _Readable_ stream needs to be output to the `stdout`, the destination should be set to `-`.\n\n```js\n/* yarn example/readable-stdout.js */\nimport whichStream from 'which-stream'\nimport { Readable } from 'stream';\n\n(async () => {\n  const readable = new Readable({\n    read() {\n      this.push(`\n> Use microwave to quickly steam your veggies:\nplace in a bowl, add a few tablespoons of water,\ncover and cook in 3 to 5 minutes increments.\n`.trim()\n      )\n      this.push(null)\n    },\n  })\n  await whichStream({\n    readable,\n    destination: '-',\n  })\n})()\n```\n```markdown\n> Use microwave to quickly steam your veggies:\nplace in a bowl, add a few tablespoons of water,\ncover and cook in 3 to 5 minutes increments.\n```\n\n<p align=\"center\"><a href=\"#table-of-contents\">\n  <img src=\"/.documentary/section-breaks/-1.svg?sanitize=true\">\n</a></p>\n\n## Copyright\n\n<table>\n  <tr>\n    <th>\n      <a href=\"https://artd.eco\">\n        <img width=\"100\" src=\"https://raw.githubusercontent.com/wrote/wrote/master/images/artdeco.png\"\n          alt=\"Art Deco\">\n      </a>\n    </th>\n    <th>© <a href=\"https://artd.eco\">Art Deco</a>   2019</th>\n    <th>\n      <a href=\"https://www.technation.sucks\" title=\"Tech Nation Visa\">\n        <img width=\"100\" src=\"https://raw.githubusercontent.com/idiocc/cookies/master/wiki/arch4.jpg\"\n          alt=\"Tech Nation Visa\">\n      </a>\n    </th>\n    <th><a href=\"https://www.technation.sucks\">Tech Nation Visa Sucks</a></th>\n  </tr>\n</table>","_attachments":{},"homepage":"https://github.com/artdecocode/which-stream#readme","bugs":{"url":"https://github.com/artdecocode/which-stream/issues"},"license":"MIT"}