Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stream-chain

Package Overview
Dependencies
Maintainers
0
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-chain - npm Package Compare versions

Comparing version 3.0.1 to 3.1.0

2

package.json
{
"name": "stream-chain",
"version": "3.0.1",
"version": "3.1.0",
"description": "Chain functions as transform streams.",

@@ -5,0 +5,0 @@ "type": "commonjs",

@@ -182,2 +182,4 @@ # stream-chain [![NPM version][npm-img]][npm-url]

* [readable.resume()](https://nodejs.org/api/stream.html#stream_readable_resume).
* *(Since 3.1.0)* If a value is a web stream object (like `ReadableStream` or `WritableStream`), it is adapted to a corresponding Node stream and included in the pipeline.
* Note that the support of web streams is still experimental in Node.
* `options` is an optional object detailed in the [Node's documentation](https://nodejs.org/api/stream.html#stream_new_stream_duplex_options).

@@ -209,2 +211,3 @@ * The default options is this object:

- 3.1.0 *Added a seamless support for web streams.*
- 3.0.1 *First release of 3.0. See [wiki](https://github.com/uhop/stream-chain/wiki) for details.*

@@ -211,0 +214,0 @@ - 3.0.0 *New major version. Unreleased.*

'use strict';
const {Duplex} = require('stream');
const {Readable, Writable,Duplex} = require('stream');
const defs = require('./defs');

@@ -31,2 +31,15 @@ const gen = require('./gen');

const isReadableWebStream = obj =>
obj && globalThis.ReadableStream && obj instanceof globalThis.ReadableStream;
const isWritableWebStream = obj =>
obj && globalThis.WritableStream && obj instanceof globalThis.WritableStream;
const isDuplexWebStream = obj =>
obj &&
globalThis.ReadableStream &&
obj.readable instanceof globalThis.ReadableStream &&
globalThis.WritableStream &&
obj.writable instanceof globalThis.WritableStream;
const groupFunctions = (output, fn, index, fns) => {

@@ -41,2 +54,14 @@ if (

}
if (isDuplexWebStream(fn)) {
output.push(Duplex.fromWeb(fn, {objectMode: true}));
return output;
}
if (!index && isReadableWebStream(fn)) {
output.push(Readable.fromWeb(fn, {objectMode: true}));
return output;
}
if (index === fns.length - 1 && isWritableWebStream(fn)) {
output.push(Writable.fromWeb(fn, {objectMode: true}));
return output;
}
if (typeof fn != 'function')

@@ -71,2 +96,11 @@ throw TypeError('Item #' + index + ' is not a proper stream, nor a function.');

}
if (isDuplexWebStream(fn)) {
return Duplex.fromWeb(fn, {objectMode: true});
}
if (!index && isReadableWebStream(fn)) {
return Readable.fromWeb(fn, {objectMode: true});
}
if (index === fns.length - 1 && isWritableWebStream(fn)) {
return Writable.fromWeb(fn, {objectMode: true});
}
if (typeof fn == 'function') return chain.asStream(fn); // a function

@@ -73,0 +107,0 @@ throw TypeError('Item #' + index + ' is not a proper stream, nor a function.');

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