blob: 9d41191da7a7c70d0e44238f767bed537769610e [file] [log] [blame]
Leo Repp58b9f112021-11-22 11:57:47 +01001
2var _Readable = require('readable-stream/readable');
3var _Writable = require('readable-stream/writable');
4var util = require('util');
5
6module.exports = {
7 DummyReadable: DummyReadable,
8 DummyWritable: DummyWritable
9};
10
11function DummyReadable(strings) {
12 _Readable.call(this);
13 this.strings = strings;
14 this.emit('readable');
15}
16
17util.inherits(DummyReadable, _Readable);
18
19DummyReadable.prototype._read = function _read(n) {
20 if (this.strings.length) {
21 this.push(new Buffer(this.strings.shift()));
22 } else {
23 this.push(null);
24 }
25};
26
27function DummyWritable(strings) {
28 _Writable.call(this);
29 this.strings = strings;
30 this.emit('writable');
31}
32
33util.inherits(DummyWritable, _Writable);
34
35DummyWritable.prototype._write = function _write(chunk, encoding, callback) {
36 this.strings.push(chunk.toString());
37 if (callback) callback();
38};
39