{"maintainers":[{"name":"jamestalmage","email":"james@talmage.io"},{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"keywords":["get","stream","promise","concat","string","str","text","buffer","read","data","consume","readable","readablestream","array","object","obj"],"dist-tags":{"latest":"3.0.0"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"description":"Get a stream as a string, buffer, or array","readme":"# get-stream [![Build Status](https://travis-ci.org/sindresorhus/get-stream.svg?branch=master)](https://travis-ci.org/sindresorhus/get-stream)\n\n> Get a stream as a string, buffer, or array\n\n\n## Install\n\n```\n$ npm install --save get-stream\n```\n\n\n## Usage\n\n```js\nconst fs = require('fs');\nconst getStream = require('get-stream');\nconst stream = fs.createReadStream('unicorn.txt');\n\ngetStream(stream).then(str => {\n\tconsole.log(str);\n\t/*\n\t              ,,))))))));,\n\t           __)))))))))))))),\n\t\\|/       -\\(((((''''((((((((.\n\t-*-==//////((''  .     `)))))),\n\t/|\\      ))| o    ;-.    '(((((                                  ,(,\n\t         ( `|    /  )    ;))))'                               ,_))^;(~\n\t            |   |   |   ,))((((_     _____------~~~-.        %,;(;(>';'~\n\t            o_);   ;    )))(((` ~---~  `::           \\      %%~~)(v;(`('~\n\t                  ;    ''''````         `:       `:::|\\,__,%%    );`'; ~\n\t                 |   _                )     /      `:|`----'     `-'\n\t           ______/\\/~    |                 /        /\n\t         /~;;.____/;;'  /          ___--,-(   `;;;/\n\t        / //  _;______;'------~~~~~    /;;/\\    /\n\t       //  | |                        / ;   \\;;,\\\n\t      (<_  | ;                      /',/-----'  _>\n\t       \\_| ||_                     //~;~~~~~~~~~\n\t           `\\_|                   (,~~\n\t                                   \\~\\\n\t                                    ~~\n\t*/\n});\n```\n\n\n## API\n\nThe methods returns a promise that resolves when the `end` event fires on the stream, indicating that there is no more data to be read. The stream is switched to flowing mode.\n\n### getStream(stream, [options])\n\nGet the `stream` as a string.\n\n#### options\n\n##### encoding\n\nType: `string`<br>\nDefault: `utf8`\n\n[Encoding](https://nodejs.org/api/buffer.html#buffer_buffer) of the incoming stream.\n\n##### maxBuffer\n\nType: `number`<br>\nDefault: `Infinity`\n\nMaximum length of the returned string. If it exceeds this value before the stream ends, the promise will be rejected.\n\n### getStream.buffer(stream, [options])\n\nGet the `stream` as a buffer.\n\nIt honors the `maxBuffer` option as above, but it refers to byte length rather than string length.\n\n### getStream.array(stream, [options])\n\nGet the `stream` as an array of values.\n\nIt honors both the `maxBuffer` and `encoding` options. The behavior changes slightly based on the encoding chosen:\n\n- When `encoding` is unset, it assumes an [object mode stream](https://nodesource.com/blog/understanding-object-streams/) and collects values emitted from `stream` unmodified. In this case `maxBuffer` refers to the number of items in the array (not the sum of their sizes).\n\n- When `encoding` is set to `buffer`, it collects an array of buffers. `maxBuffer` refers to the summed byte lengths of every buffer in the array.\n\n- When `encoding` is set to anything else, it collects an array of strings. `maxBuffer` refers to the summed character lengths of every string in the array.\n\n\n## Errors\n\nIf the input stream emits an `error` event, the promise will be rejected with the error. The buffered data will be attached to the `bufferedData` property of the error.\n\n```js\ngetStream(streamThatErrorsAtTheEnd('unicorn'))\n\t.catch(err => {\n\t\tconsole.log(err.bufferedData);\n\t\t//=> 'unicorn'\n\t});\n```\n\n\n## FAQ\n\n### How is this different from [`concat-stream`](https://github.com/maxogden/concat-stream)?\n\nThis module accepts a stream instead of being one and returns a promise instead of using a callback. The API is simpler and it only supports returning a string, buffer, or array. It doesn't have a fragile type inference. You explicitly choose what you want. And it doesn't depend on the huge `readable-stream` package.\n\n\n## Related\n\n- [get-stdin](https://github.com/sindresorhus/get-stdin) - Get stdin as a string or buffer\n\n\n## License\n\nMIT © [Sindre Sorhus](https://sindresorhus.com)\n","repository":{"type":"git","url":"git+https://github.com/sindresorhus/get-stream.git"},"users":{"rubiadias":true,"rocket0191":true},"bugs":{"url":"https://github.com/sindresorhus/get-stream/issues"},"license":"MIT","versions":{"1.0.0":{"name":"get-stream","version":"1.0.0","description":"Get a stream as a string or buffer","license":"MIT","repository":{"type":"git","url":"https://github.com/sindresorhus/get-stream"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=0.12.0"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["get","stream","concat","string","str","text","buffer","process","read","data","readable"],"devDependencies":{"ava":"*","buffer-equals":"^1.0.3","xo":"*"},"xo":{"ignores":["test.js"]},"gitHead":"56bf66ad5a924be824a6603d000c68ca394f71f5","bugs":{"url":"https://github.com/sindresorhus/get-stream/issues"},"homepage":"https://github.com/sindresorhus/get-stream","_id":"get-stream@1.0.0","_shasum":"556ef2adce7c20faf0d60aa627ccfd9d03406d81","_from":".","_npmVersion":"2.14.4","_nodeVersion":"4.1.1","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"556ef2adce7c20faf0d60aa627ccfd9d03406d81","tarball":"http://nexus.dui88.com:8081/nexus/content/repositories/npm-registry/get-stream/-/get-stream-1.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"directories":{}},"1.1.0":{"name":"get-stream","version":"1.1.0","description":"Get a stream as a string or buffer","license":"MIT","repository":{"type":"git","url":"https://github.com/sindresorhus/get-stream"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=0.12.0"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["get","stream","concat","string","str","text","buffer","process","read","data","readable"],"devDependencies":{"ava":"*","buffer-equals":"^1.0.3","xo":"*"},"xo":{"ignores":["test.js"]},"gitHead":"05c19972d3556efa6e44eb8182118c9410422caf","bugs":{"url":"https://github.com/sindresorhus/get-stream/issues"},"homepage":"https://github.com/sindresorhus/get-stream","_id":"get-stream@1.1.0","_shasum":"554659093606c1b5284218be65f68385c9f0c18b","_from":".","_npmVersion":"2.14.7","_nodeVersion":"4.2.1","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"554659093606c1b5284218be65f68385c9f0c18b","tarball":"http://nexus.dui88.com:8081/nexus/content/repositories/npm-registry/get-stream/-/get-stream-1.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"directories":{}},"2.0.0":{"name":"get-stream","version":"2.0.0","description":"Get a stream as a string or buffer","license":"MIT","repository":{"type":"git","url":"https://github.com/sindresorhus/get-stream"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=0.10.0"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["get","stream","concat","string","str","text","buffer","process","read","data","readable"],"dependencies":{"pinkie-promise":"^2.0.0"},"devDependencies":{"ava":"*","buffer-equals":"^1.0.3","xo":"*"},"gitHead":"5477c3887b7af31f49c276e5c82b733fd1f6c5cf","bugs":{"url":"https://github.com/sindresorhus/get-stream/issues"},"homepage":"https://github.com/sindresorhus/get-stream","_id":"get-stream@2.0.0","_shasum":"c6457200c1b5d3291cf45711217d9f2f87d43af5","_from":".","_npmVersion":"2.14.12","_nodeVersion":"4.3.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"c6457200c1b5d3291cf45711217d9f2f87d43af5","tarball":"http://nexus.dui88.com:8081/nexus/content/repositories/npm-registry/get-stream/-/get-stream-2.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"packages-13-west.internal.npmjs.com","tmp":"tmp/get-stream-2.0.0.tgz_1456982714460_0.6460716719739139"},"directories":{}},"2.1.0":{"name":"get-stream","version":"2.1.0","description":"Get a stream as a string, buffer, or array","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/get-stream.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=0.10.0"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["get","stream","concat","string","str","text","buffer","read","data","readable","readablestream","array","object","obj"],"dependencies":{"pinkie-promise":"^2.0.0"},"devDependencies":{"ava":"*","buffer-equals":"^1.0.3","into-stream":"^2.0.1","xo":"*"},"gitHead":"52f695aa78add2c6e6731e5f292dc82ce2e02b8a","bugs":{"url":"https://github.com/sindresorhus/get-stream/issues"},"homepage":"https://github.com/sindresorhus/get-stream#readme","_id":"get-stream@2.1.0","_shasum":"5a39f4167aae4f30433f95cf211e315baefc62c9","_from":".","_npmVersion":"2.15.0","_nodeVersion":"4.4.2","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"5a39f4167aae4f30433f95cf211e315baefc62c9","tarball":"http://nexus.dui88.com:8081/nexus/content/repositories/npm-registry/get-stream/-/get-stream-2.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/get-stream-2.1.0.tgz_1461857619841_0.05684150545857847"},"directories":{}},"2.2.0":{"name":"get-stream","version":"2.2.0","description":"Get a stream as a string, buffer, or array","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/get-stream.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=0.10.0"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["get","stream","concat","string","str","text","buffer","read","data","readable","readablestream","array","object","obj"],"dependencies":{"object-assign":"^4.0.1","pinkie-promise":"^2.0.0"},"devDependencies":{"ava":"*","buffer-equals":"^1.0.3","into-stream":"^2.0.1","xo":"*"},"gitHead":"162fa9978a4bfaa9c04581495e0303132af95035","bugs":{"url":"https://github.com/sindresorhus/get-stream/issues"},"homepage":"https://github.com/sindresorhus/get-stream#readme","_id":"get-stream@2.2.0","_shasum":"9073a42b9fbebb2411ed7f1c04b2f5c3d5be289d","_from":".","_npmVersion":"3.8.9","_nodeVersion":"4.4.2","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"9073a42b9fbebb2411ed7f1c04b2f5c3d5be289d","tarball":"http://nexus.dui88.com:8081/nexus/content/repositories/npm-registry/get-stream/-/get-stream-2.2.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/get-stream-2.2.0.tgz_1462049442368_0.29556937725283206"},"directories":{}},"2.2.1":{"name":"get-stream","version":"2.2.1","description":"Get a stream as a string, buffer, or array","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/get-stream.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=0.10.0"},"scripts":{"test":"xo && ava"},"files":["index.js","buffer-stream.js"],"keywords":["get","stream","promise","concat","string","str","text","buffer","read","data","readable","readablestream","array","object","obj"],"dependencies":{"object-assign":"^4.0.1","pinkie-promise":"^2.0.0"},"devDependencies":{"ava":"*","buffer-equals":"^1.0.3","into-stream":"^2.0.1","xo":"*"},"gitHead":"4e75377d963f6ee4fb9022baf2ffe46cba350110","bugs":{"url":"https://github.com/sindresorhus/get-stream/issues"},"homepage":"https://github.com/sindresorhus/get-stream#readme","_id":"get-stream@2.2.1","_shasum":"ed7e336824f09ab00e37f0296ba42274590ad1c6","_from":".","_npmVersion":"2.15.0","_nodeVersion":"4.4.2","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"ed7e336824f09ab00e37f0296ba42274590ad1c6","tarball":"http://nexus.dui88.com:8081/nexus/content/repositories/npm-registry/get-stream/-/get-stream-2.2.1.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/get-stream-2.2.1.tgz_1465235691565_0.8080171663314104"},"directories":{}},"2.3.0":{"name":"get-stream","version":"2.3.0","description":"Get a stream as a string, buffer, or array","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/get-stream.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=0.10.0"},"scripts":{"test":"xo && ava"},"files":["index.js","buffer-stream.js"],"keywords":["get","stream","promise","concat","string","str","text","buffer","read","data","readable","readablestream","array","object","obj"],"dependencies":{"object-assign":"^4.0.1","pinkie-promise":"^2.0.0"},"devDependencies":{"ava":"*","buffer-equals":"^1.0.3","into-stream":"^2.0.1","xo":"*"},"gitHead":"80081b6fe8bcacdef062ac54e0de4a3b8ec6e61c","bugs":{"url":"https://github.com/sindresorhus/get-stream/issues"},"homepage":"https://github.com/sindresorhus/get-stream#readme","_id":"get-stream@2.3.0","_shasum":"3790b4977e742dd3ad9d61e9fe711865f690c010","_from":".","_npmVersion":"3.8.6","_nodeVersion":"5.10.1","_npmUser":{"name":"jamestalmage","email":"james@talmage.io"},"dist":{"shasum":"3790b4977e742dd3ad9d61e9fe711865f690c010","tarball":"http://nexus.dui88.com:8081/nexus/content/repositories/npm-registry/get-stream/-/get-stream-2.3.0.tgz"},"maintainers":[{"name":"jamestalmage","email":"james@talmage.io"},{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/get-stream-2.3.0.tgz_1465263104906_0.18662143824622035"},"directories":{}},"2.3.1":{"name":"get-stream","version":"2.3.1","description":"Get a stream as a string, buffer, or array","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/get-stream.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=0.10.0"},"scripts":{"test":"xo && ava"},"files":["index.js","buffer-stream.js"],"keywords":["get","stream","promise","concat","string","str","text","buffer","read","data","readable","readablestream","array","object","obj"],"dependencies":{"object-assign":"^4.0.1","pinkie-promise":"^2.0.0"},"devDependencies":{"ava":"*","buffer-equals":"^1.0.3","into-stream":"^2.0.1","xo":"*"},"gitHead":"1607196593ead1d000caae8aec37ea4bed5f0797","bugs":{"url":"https://github.com/sindresorhus/get-stream/issues"},"homepage":"https://github.com/sindresorhus/get-stream#readme","_id":"get-stream@2.3.1","_shasum":"5f38f93f346009666ee0150a054167f91bdd95de","_from":".","_npmVersion":"2.15.9","_nodeVersion":"4.5.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"5f38f93f346009666ee0150a054167f91bdd95de","tarball":"http://nexus.dui88.com:8081/nexus/content/repositories/npm-registry/get-stream/-/get-stream-2.3.1.tgz"},"maintainers":[{"name":"jamestalmage","email":"james@talmage.io"},{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/get-stream-2.3.1.tgz_1473873226777_0.8189526884816587"},"directories":{}},"3.0.0":{"name":"get-stream","version":"3.0.0","description":"Get a stream as a string, buffer, or array","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/get-stream.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=4"},"scripts":{"test":"xo && ava"},"files":["index.js","buffer-stream.js"],"keywords":["get","stream","promise","concat","string","str","text","buffer","read","data","consume","readable","readablestream","array","object","obj"],"devDependencies":{"ava":"*","into-stream":"^3.0.0","xo":"*"},"xo":{"esnext":true},"gitHead":"3023bc31dec6680dda4f935a2b320b3a4f18c815","bugs":{"url":"https://github.com/sindresorhus/get-stream/issues"},"homepage":"https://github.com/sindresorhus/get-stream#readme","_id":"get-stream@3.0.0","_shasum":"8e943d1358dc37555054ecbe2edb05aa174ede14","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.6.2","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"8e943d1358dc37555054ecbe2edb05aa174ede14","tarball":"http://nexus.dui88.com:8081/nexus/content/repositories/npm-registry/get-stream/-/get-stream-3.0.0.tgz"},"maintainers":[{"name":"jamestalmage","email":"james@talmage.io"},{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/get-stream-3.0.0.tgz_1479869385406_0.47692562686279416"},"directories":{}}},"name":"get-stream","time":{"modified":"2017-03-10T09:08:58.816Z","created":"2015-10-14T17:28:21.024Z","1.0.0":"2015-10-14T17:28:21.024Z","1.1.0":"2015-11-20T18:41:32.705Z","2.0.0":"2016-03-03T05:25:15.334Z","2.1.0":"2016-04-28T15:33:42.239Z","2.2.0":"2016-04-30T20:50:42.753Z","2.2.1":"2016-06-06T17:54:54.123Z","2.3.0":"2016-06-07T01:31:47.069Z","2.3.1":"2016-09-14T17:13:47.014Z","3.0.0":"2016-11-23T02:49:47.220Z"},"readmeFilename":"readme.md","homepage":"https://github.com/sindresorhus/get-stream#readme"}