mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
724 B
37 lines
724 B
'use strict';
|
|
const common = require('../common');
|
|
var R = require('_stream_readable');
|
|
var W = require('_stream_writable');
|
|
var assert = require('assert');
|
|
|
|
var src = new R({encoding: 'base64'});
|
|
var dst = new W();
|
|
var hasRead = false;
|
|
var accum = [];
|
|
var timeout;
|
|
|
|
src._read = function(n) {
|
|
if (!hasRead) {
|
|
hasRead = true;
|
|
process.nextTick(function() {
|
|
src.push(Buffer.from('1'));
|
|
src.push(null);
|
|
});
|
|
}
|
|
};
|
|
|
|
dst._write = function(chunk, enc, cb) {
|
|
accum.push(chunk);
|
|
cb();
|
|
};
|
|
|
|
src.on('end', function() {
|
|
assert.equal(Buffer.concat(accum) + '', 'MQ==');
|
|
clearTimeout(timeout);
|
|
});
|
|
|
|
src.pipe(dst);
|
|
|
|
timeout = setTimeout(function() {
|
|
common.fail('timed out waiting for _write');
|
|
}, 100);
|
|
|