Skip to content
This repository was archived by the owner on Jun 24, 2024. It is now read-only.

Commit 2b02535

Browse files
Walkerdigitalsadhu
authored andcommitted
fix(errors): Fix error messages
1 parent 4648b16 commit 2b02535

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

lib/reader.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { Readable, PassThrough, Transform } = require('stream');
1+
const { Readable, PassThrough, Transform, Stream } = require('stream');
22
const { stringify, parse } = require('JSONStream');
33
const mergeStream = require('merge-stream');
44
const { dedupe, sort, setOrder } = require('./util');
@@ -9,7 +9,7 @@ module.exports = class Reader extends Readable {
99
super();
1010

1111
assert(
12-
streams,
12+
streams instanceof Stream || Array.isArray(streams),
1313
`Expected first argument to new Reader() to be a stream or array of streams.
1414
Instead got ${typeof stream}`
1515
);
@@ -18,6 +18,11 @@ module.exports = class Reader extends Readable {
1818
streams = [streams];
1919
}
2020

21+
assert(
22+
streams.every(stream => stream instanceof Stream),
23+
`Expected any/all arguments given to Reader constructor to be subclasses of Stream.`
24+
);
25+
2126
assert(
2227
streams.length,
2328
`Expected at least one stream to be provided to new Reader(). Got none.`

test/__snapshots__/reader.test.js.snap

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ exports[`new Reader(): throws on no input 1`] = `
77

88
exports[`new Reader([]): throws on empty array 1`] = `"Expected at least one stream to be provided to new Reader(). Got none."`;
99

10-
exports[`new Reader([1,2,3]): throws on array containing non stream items 1`] = `"readStream.on is not a function"`;
10+
exports[`new Reader([1,2,3]): throws on array containing non stream items 1`] = `"Expected any/all arguments given to Reader constructor to be subclasses of Stream."`;
1111

12-
exports[`new Reader(123): throws on non stream or array input 1`] = `"readStream.on is not a function"`;
12+
exports[`new Reader(123): throws on non stream or array input 1`] = `
13+
"Expected first argument to new Reader() to be a stream or array of streams.
14+
Instead got undefined"
15+
`;

0 commit comments

Comments
 (0)