Socket
Socket
Sign inDemoInstall

stream-chain

Package Overview
Dependencies
0
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.2.4 to 2.2.5

38

index.js

@@ -42,3 +42,6 @@ 'use strict';

// thenable
result.then(result => (Chain.sanitize(result, this), callback(null)), error => callback(error));
result.then(
result => (Chain.sanitize(result, this), callback(null)),
error => callback(error)
);
return;

@@ -48,3 +51,6 @@ }

// generator
runAsyncGenerator(result, this).then(() => callback(null), error => callback(error));
runAsyncGenerator(result, this).then(
() => callback(null),
error => callback(error)
);
return;

@@ -87,2 +93,19 @@ }

// is*NodeStream functions taken from https://github.com/nodejs/node/blob/master/lib/internal/streams/utils.js
const isReadableNodeStream = obj =>
obj &&
typeof obj.pipe === 'function' &&
typeof obj.on === 'function' &&
(!obj._writableState || (typeof obj._readableState === 'object' ? obj._readableState.readable : null) !== false) && // Duplex
(!obj._writableState || obj._readableState); // Writable has .pipe.
const isWritableNodeStream = obj =>
obj &&
typeof obj.write === 'function' &&
typeof obj.on === 'function' &&
(!obj._readableState || (typeof obj._writableState === 'object' ? obj._writableState.writable : null) !== false); // Duplex
const isDuplexNodeStream = obj =>
obj && typeof obj.pipe === 'function' && obj._readableState && typeof obj.on === 'function' && typeof obj.write === 'function';
class Chain extends Duplex {

@@ -100,8 +123,3 @@ constructor(fns, options) {

if (typeof fn === 'function' || fn instanceof Array) return Chain.convertToTransform(fn);
if (
fn instanceof Duplex ||
fn instanceof Transform ||
(!index && fn instanceof Readable) ||
(index === fns.length - 1 && fn instanceof Writable)
) {
if (isDuplexNodeStream(fn) || (!index && isReadableNodeStream(fn)) || (index === fns.length - 1 && isWritableNodeStream(fn))) {
return fn;

@@ -115,3 +133,3 @@ }

if (!(this.input instanceof Writable)) {
if (!isWritableNodeStream(this.input)) {
this._write = (_1, _2, callback) => callback(null);

@@ -122,3 +140,3 @@ this._final = callback => callback(null); // unavailable in Node 6

if (this.output instanceof Readable) {
if (isReadableNodeStream(this.output)) {
this.output.on('data', chunk => !this.push(chunk) && this.output.pause());

@@ -125,0 +143,0 @@ this.output.on('end', () => this.push(null));

{
"name": "stream-chain",
"version": "2.2.4",
"version": "2.2.5",
"description": "Chain functions as transform streams.",

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

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

- 2.2.5 *Relaxed the definition of a stream (thx [Rich Hodgkins](https://github.com/rhodgkins)).*
- 2.2.4 *Bugfix: wrong `const`-ness in the async generator branch (thx [Patrick Pang](https://github.com/patrickpang)).*

@@ -322,0 +323,0 @@ - 2.2.3 *Technical release. No need to upgrade.*

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc