Sha256: bfdd31d421d9975519122715df56e81662abf283e386bda1d7141ef277f70191

Contents?: true

Size: 1.14 KB

Versions: 32

Compression:

Stored size: 1.14 KB

Contents

var stream = require('stream')
var pump = require('./index')

var rs = new stream.Readable()
var ws = new stream.Writable()

rs._read = function (size) {
  this.push(Buffer(size).fill('abc'))
}

ws._write = function (chunk, encoding, cb) {
  setTimeout(function () {
    cb()
  }, 100)
}

var toHex = function () {
  var reverse = new (require('stream').Transform)()

  reverse._transform = function (chunk, enc, callback) {
    reverse.push(chunk.toString('hex'))
    callback()
  }

  return reverse
}

var wsClosed = false
var rsClosed = false
var callbackCalled = false

var check = function () {
  if (wsClosed && rsClosed && callbackCalled) {
    console.log('test-browser.js passes')
    clearTimeout(timeout)
  }
}

ws.on('finish', function () {
  wsClosed = true
  check()
})

rs.on('end', function () {
  rsClosed = true
  check()
})

var res = pump(rs, toHex(), toHex(), toHex(), ws, function () {
  callbackCalled = true
  check()
})

if (res !== ws) {
  throw new Error('should return last stream')
}

setTimeout(function () {
  rs.push(null)
  rs.emit('close')
}, 1000)

var timeout = setTimeout(function () {
  check()
  throw new Error('timeout')
}, 5000)

Version data entries

32 entries across 31 versions & 9 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/pump/test-browser.js
disco_app-0.18.0 test/dummy/node_modules/pump/test-browser.js
disco_app-0.18.2 test/dummy/node_modules/pump/test-browser.js
disco_app-0.16.1 test/dummy/node_modules/pump/test-browser.js
isomorfeus-puppetmaster-0.5.5 node_modules/pump/test-browser.js
isomorfeus-puppetmaster-0.5.4 node_modules/pump/test-browser.js
disco_app-0.15.2 test/dummy/node_modules/pump/test-browser.js
isomorfeus-puppetmaster-0.5.3 node_modules/pump/test-browser.js
disco_app-0.18.4 test/dummy/node_modules/pump/test-browser.js
disco_app-0.18.1 test/dummy/node_modules/pump/test-browser.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/pump/test-browser.js
disco_app-0.14.0 test/dummy/node_modules/pump/test-browser.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/pump/test-browser.js
isomorfeus-puppetmaster-0.5.2 node_modules/pump/test-browser.js
isomorfeus-puppetmaster-0.5.1 node_modules/pump/test-browser.js
isomorfeus-puppetmaster-0.5.0 node_modules/pump/test-browser.js
tang-0.2.1 spec/tang_app/node_modules/pump/test-browser.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/pump/test-browser.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/pump/test-browser.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/pump/test-browser.js