Server IP : 185.86.78.101 / Your IP : 216.73.216.124 Web Server : Apache System : Linux 675867-vds-valikoshka1996.gmhost.pp.ua 5.4.0-150-generic #167-Ubuntu SMP Mon May 15 17:35:05 UTC 2023 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,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,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /www/wwwroot/mifepriston.org/node_modules/through/test/ |
Upload File : |
var test = require('tape') var spec = require('stream-spec') var through = require('../') /* I'm using these two functions, and not streams and pipe so there is less to break. if this test fails it must be the implementation of _through_ */ function write(array, stream) { array = array.slice() function next() { while(array.length) if(stream.write(array.shift()) === false) return stream.once('drain', next) stream.end() } next() } function read(stream, callback) { var actual = [] stream.on('data', function (data) { actual.push(data) }) stream.once('end', function () { callback(null, actual) }) stream.once('error', function (err) { callback(err) }) } test('simple defaults', function(assert) { var l = 1000 , expected = [] while(l--) expected.push(l * Math.random()) var t = through() var s = spec(t).through().pausable() read(t, function (err, actual) { assert.ifError(err) assert.deepEqual(actual, expected) assert.end() }) t.on('close', s.validate) write(expected, t) }); test('simple functions', function(assert) { var l = 1000 , expected = [] while(l--) expected.push(l * Math.random()) var t = through(function (data) { this.emit('data', data*2) }) var s = spec(t).through().pausable() read(t, function (err, actual) { assert.ifError(err) assert.deepEqual(actual, expected.map(function (data) { return data*2 })) assert.end() }) t.on('close', s.validate) write(expected, t) }) test('pauses', function(assert) { var l = 1000 , expected = [] while(l--) expected.push(l) //Math.random()) var t = through() var s = spec(t) .through() .pausable() t.on('data', function () { if(Math.random() > 0.1) return t.pause() process.nextTick(function () { t.resume() }) }) read(t, function (err, actual) { assert.ifError(err) assert.deepEqual(actual, expected) }) t.on('close', function () { s.validate() assert.end() }) write(expected, t) }) test('does not soft-end on `undefined`', function(assert) { var stream = through() , count = 0 stream.on('data', function (data) { count++ }) stream.write(undefined) stream.write(undefined) assert.equal(count, 2) assert.end() })