Socket
Socket
Sign inDemoInstall

get-stream

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-stream - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

28

index.js

@@ -64,1 +64,29 @@ 'use strict';

};
module.exports.array = function (stream) {
if (!stream) {
return Promise.reject(new Error('Expected a stream'));
}
var ret = [];
function onData(obj) {
ret.push(obj);
}
var p = new Promise(function (resolve, reject) {
stream.on('data', onData);
stream.on('error', reject);
stream.on('end', resolve);
});
var clean = function () {
stream.removeListener('data', onData);
};
p.then(clean, clean);
return p.then(function () {
return ret;
});
};

12

package.json
{
"name": "get-stream",
"version": "2.0.0",
"description": "Get a stream as a string or buffer",
"version": "2.1.0",
"description": "Get a stream as a string, buffer, or array",
"license": "MIT",

@@ -29,6 +29,9 @@ "repository": "sindresorhus/get-stream",

"buffer",
"process",
"read",
"data",
"readable"
"readable",
"readablestream",
"array",
"object",
"obj"
],

@@ -41,4 +44,5 @@ "dependencies": {

"buffer-equals": "^1.0.3",
"into-stream": "^2.0.1",
"xo": "*"
}
}
# get-stream [![Build Status](https://travis-ci.org/sindresorhus/get-stream.svg?branch=master)](https://travis-ci.org/sindresorhus/get-stream)
> Get a stream as a string or buffer
> Get a stream as a string, buffer, or array

@@ -49,7 +49,7 @@

Both methods returns a promise that is resolved 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.
The methods returns a promise that is resolved 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.
### getStream(stream, [options])
Get the stream as a string.
Get the `stream` as a string.

@@ -67,5 +67,11 @@ #### options

Get the stream as a buffer.
Get the `stream` as a buffer.
### getStream.array(stream)
Get the `stream` as an array of values.
Especially useful for [object mode streams](https://nodesource.com/blog/understanding-object-streams/).
## FAQ

@@ -75,3 +81,3 @@

This one 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 or buffer. 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.
This 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.

@@ -78,0 +84,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc