var stream=require("stream"),pump=require("./index"),rs=new stream.Readable,ws=new stream.Writable;rs._read=function(e){this.push(Buffer(e).fill("abc"))},ws._write=function(e,r,s){setTimeout(function(){s()},100)};var toHex=function(){var e=new(require("stream").Transform);return e._transform=function(r,s,t){e.push(r.toString("hex")),t()},e},wsClosed=!1,rsClosed=!1,callbackCalled=!1,check=function(){wsClosed&&rsClosed&&callbackCalled&&(console.log("test-browser.js passes"),clearTimeout(timeout))};ws.on("finish",function(){wsClosed=!0,check()}),rs.on("end",function(){rsClosed=!0,check()});var res=pump(rs,toHex(),toHex(),toHex(),ws,function(){callbackCalled=!0,check()});if(res!==ws)throw new Error("should return last stream");setTimeout(function(){rs.push(null),rs.emit("close")},1e3);var timeout=setTimeout(function(){throw check(),new Error("timeout")},5e3);