Skip to content

Commit

Permalink
Fix isStream.transform detection
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jul 26, 2021
1 parent 23a6c15 commit 2070240
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
1 change: 0 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference types="node"/>
import * as stream from 'stream';

declare const isStream: {
Expand Down
3 changes: 1 addition & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ isStream.duplex = stream =>

isStream.transform = stream =>
isStream.duplex(stream) &&
typeof stream._transform === 'function' &&
typeof stream._transformState === 'object';
typeof stream._transform === 'function';

module.exports = isStream;
4 changes: 2 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ test('isStream.writable()', t => {
t.true(isStream.writable(new Stream.Transform()));
t.true(isStream.writable(new Stream.PassThrough()));
t.true(isStream.writable(fs.createWriteStream(tempy.file())));
t.true(isStream.writable(new net.Socket()));
t.false(isStream.writable(new Stream.Stream()));
t.false(isStream.writable(new Stream.Readable()));
t.false(isStream.writable(fs.createReadStream('test.js')));
t.false(isStream.writable(new net.Socket()));
});

test('isStream.readable()', t => {
Expand All @@ -39,10 +39,10 @@ test('isStream.readable()', t => {
t.true(isStream.readable(new Stream.Transform()));
t.true(isStream.readable(new Stream.PassThrough()));
t.true(isStream.readable(fs.createReadStream('test.js')));
t.true(isStream.readable(new net.Socket()));
t.false(isStream.readable(new Stream.Stream()));
t.false(isStream.readable(new Stream.Writable()));
t.false(isStream.readable(fs.createWriteStream(tempy.file())));
t.false(isStream.readable(new net.Socket()));
});

test('isStream.duplex()', t => {
Expand Down

0 comments on commit 2070240

Please sign in to comment.