@ -1,15 +1,9 @@
'use strict' ;
'use strict' ;
var common = require ( '../common' ) ;
require ( '../common' ) ;
var assert = require ( 'assert' ) ;
const assert = require ( 'assert' ) ;
var stream = require ( 'stream' ) ;
if ( ! common . hasCrypto ) {
const stream = require ( 'stream' ) ;
common . skip ( 'missing crypto' ) ;
const util = require ( 'util' ) ;
return ;
}
var crypto = require ( 'crypto' ) ;
var util = require ( 'util' ) ;
function TestWriter ( ) {
function TestWriter ( ) {
stream . Writable . call ( this ) ;
stream . Writable . call ( this ) ;
@ -21,7 +15,7 @@ TestWriter.prototype._write = function(buffer, encoding, callback) {
// super slow write stream (callback never called)
// super slow write stream (callback never called)
} ;
} ;
var dest = new TestWriter ( ) ;
const dest = new TestWriter ( ) ;
function TestReader ( id ) {
function TestReader ( id ) {
stream . Readable . call ( this ) ;
stream . Readable . call ( this ) ;
@ -31,11 +25,11 @@ util.inherits(TestReader, stream.Readable);
TestReader . prototype . _ read = function ( size ) {
TestReader . prototype . _ read = function ( size ) {
this . reads += 1 ;
this . reads += 1 ;
this . push ( crypto . randomBytes ( size ) ) ;
this . push ( Buffer . alloc ( size ) ) ;
} ;
} ;
var src1 = new TestReader ( ) ;
const src1 = new TestReader ( ) ;
var src2 = new TestReader ( ) ;
const src2 = new TestReader ( ) ;
src1 . pipe ( dest ) ;
src1 . pipe ( dest ) ;
@ -55,6 +49,6 @@ src1.once('readable', function() {
process . on ( 'exit' , function ( ) {
process . on ( 'exit' , function ( ) {
assert . e qual( src1 . reads , 2 ) ;
assert . strictE qual( src1 . reads , 2 ) ;
assert . e qual( src2 . reads , 2 ) ;
assert . strictE qual( src2 . reads , 2 ) ;
} ) ;
} ) ;