{
"_from": "get-stream@",
"_id": "get-stream@4.1.0",
"_inBundle": false,
"_integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==",
"_location": "/npm/get-stream",
"_phantomChildren": {},
"_requested": {
"escapedName": "get-stream",
"fetchSpec": "latest",
"name": "get-stream",
"raw": "get-stream@",
"rawSpec": "",
"registry": true,
"saveSpec": null,
"type": "tag"
},
"_requiredBy": [
"#DEV:/",
"#USER",
"/npm/libnpmaccess",
"/npm/libnpmhook",
"/npm/libnpmorg",
"/npm/libnpmpublish",
"/npm/libnpmsearch",
"/npm/libnpmteam",
"/npm/pacote"
],
"_resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz",
"_shasum": "c1b255575f3dc21d59bfc79cd3d2b46b1c3a54b5",
"_shrinkwrap": null,
"_spec": "get-stream@",
"_where": "/Users/zkat/Documents/code/work/npm",
"author": {
"email": "sindresorhus@gmail.com",
"name": "Sindre Sorhus",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/get-stream/issues"
},
"bundleDependencies": false,
"dependencies": {
"pump": "^3.0.0"
},
"deprecated": false,
"description": "Get a stream as a string, buffer, or array",
"devDependencies": {
"ava": "*",
"into-stream": "^3.0.0",
"xo": "*"
},
"engines": {
"node": ">=6"
},
"files": [
"buffer-stream.js",
"index.js"
],
"homepage": "https://github.com/sindresorhus/get-stream#readme",
"keywords": [
"array",
"buffer",
"concat",
"consume",
"data",
"get",
"object",
"promise",
"read",
"readable",
"readablestream",
"stream",
"string",
"text"
],
"license": "MIT",
"name": "get-stream",
"optionalDependencies": {},
"readme": "# get-stream [](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 get-stream\n```\n\n\n## Usage\n\n```js\nconst fs = require('fs');\nconst getStream = require('get-stream');\n\n(async () => {\n\tconst stream = fs.createReadStream('unicorn.txt');\n\n\tconsole.log(await getStream(stream));\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\nType: `Object`\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 with a `getStream.MaxBufferError` error.\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\n(async () => {\n\ttry {\n\t\tawait getStream(streamThatErrorsAtTheEnd('unicorn'));\n\t} catch (error) {\n\t\tconsole.log(error.bufferedData);\n\t\t//=> 'unicorn'\n\t}\n})()\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",
"readmeFilename": "readme.md",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/get-stream.git"
},
"scripts": {
"test": "xo && ava"
},
"version": "4.1.0"
}