Socket
Socket
Sign inDemoInstall

stream-collect

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-collect - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

2

package.json
{
"name": "stream-collect",
"version": "1.2.0",
"version": "1.2.1",
"description": "Collects the output of a stream as callback or promise",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -44,19 +44,14 @@ # Stream collect

## collect.PassThrough()
## `collect.stream()` / `collect.PassThrough()`
Creates a PassThrough stream that that has an additional 'collect' and acts as a Promise.
The `collect` event returns the collected data. It is called as part of the `end` event.
`collect.stream()` creates a `stream.PassThrough` with an additional 'collect' event that can also act as a Promise.
The PassThrough stream has `then` and `catch` methods added to acts like a Promise (or strictly a "thenable").
When piped, any errors from the source stream will be passed to this stream.
```js
// Using the collect event
var collect = require('stream-collect');
// Using the collect event
var file = fs.createReadableStream( 'myfile' );
file.pipe( new collect.PassThrough() )
file.pipe( collect.stream() )
.on( 'collect', function(data) {

@@ -68,3 +63,3 @@ // data = contents of the file

var file = fs.createReadableStream( 'myfile' );
file.pipe( new collect.PassThrough() )
file.pipe( collect.stream() )
.then(data) {

@@ -76,2 +71,9 @@ // data = contents of the file

The `collect` event is called as part of the `end` event.
When collect is piped, any errors from the source stream will be passed to this stream and can be caught in `then` and `catch` when used as a Promise.
`collect.PassThrough()` is an alternative name for `collect.stream`. Both can be used with or without the `new` operator.
## collect.addToStream(stream)

@@ -78,0 +80,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