mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 20:08:02 +00:00

Use assert.strictEqual instead of assert.equal in tests, manually convert types where necessary. PR-URL: https://github.com/nodejs/node/pull/10698 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
37 lines
735 B
JavaScript
37 lines
735 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const R = require('_stream_readable');
|
|
const W = require('_stream_writable');
|
|
const assert = require('assert');
|
|
|
|
const src = new R({encoding: 'base64'});
|
|
const dst = new W();
|
|
let hasRead = false;
|
|
const accum = [];
|
|
|
|
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.strictEqual(Buffer.concat(accum) + '', 'MQ==');
|
|
clearTimeout(timeout);
|
|
});
|
|
|
|
src.pipe(dst);
|
|
|
|
const timeout = setTimeout(function() {
|
|
common.fail('timed out waiting for _write');
|
|
}, 100);
|