Skip to content

Commit

Permalink
WIP 5
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed May 1, 2018
1 parent 19c4962 commit c64aa2e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 29 deletions.
1 change: 1 addition & 0 deletions lib/readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ function _read(size) {
}

function readStdout(duplex, size) {
// TODO Ensure doesn't read again while awaiting 'readable' event
console.log('------------');
console.log(`readStdout() called: size ${size}`);

Expand Down
1 change: 1 addition & 0 deletions lib/writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ function writeStdin(duplex, chunk, cb) {
if (keepWriting) return cb(null);

// Stdin needs to drain - callback only once drained or stdin errors
// TODO Move listeners to be global rather than adding and removing
function done(err) {
stdin.removeListener('drain', done);
stdin.removeListener('error', done);
Expand Down
29 changes: 0 additions & 29 deletions test/all.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,4 @@ describe('Tests', function() {
it.skip('dummy', function() {
expect(DuplexChild).to.be.ok;
});

it('check Readable', function(cb) {
const {Readable} = require('stream');

const stream = new Readable();

let called = false,
calledTwice = false;
stream._read = function(size) {
console.log(`_read() called: ${size} bytes`);

if (called) {
calledTwice = true;
return this.push(null);
}

called = true;

const wantsMore = this.push(Buffer.alloc(1000, 'a'));
console.log(`wantsMore: ${wantsMore}`);
};

stream.resume();

stream.on('end', () => {
if (calledTwice) return cb(new Error('_read called again before .push returns false'));
cb();
});
});
});

0 comments on commit c64aa2e

Please sign in to comment.