1 var stream = require('stream')
2 var pump = require('./index')
4 var rs = new stream.Readable()
5 var ws = new stream.Writable()
7 rs._read = function (size) {
8 this.push(Buffer(size).fill('abc'))
11 ws._write = function (chunk, encoding, cb) {
12 setTimeout(function () {
17 var toHex = function () {
18 var reverse = new (require('stream').Transform)()
20 reverse._transform = function (chunk, enc, callback) {
21 reverse.push(chunk.toString('hex'))
30 var callbackCalled = false
32 var check = function () {
33 if (wsClosed && rsClosed && callbackCalled) {
34 console.log('test-browser.js passes')
39 ws.on('finish', function () {
44 rs.on('end', function () {
49 var res = pump(rs, toHex(), toHex(), toHex(), ws, function () {
55 throw new Error('should return last stream')
58 setTimeout(function () {
63 var timeout = setTimeout(function () {
65 throw new Error('timeout')