Server IP : 108.163.255.210 / Your IP : 3.139.80.194 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/goodmoreearnings.com/nnm/node_modules/from2/ |
Upload File : |
var test = require('tape') var path = require('path') var from = require('./') var fs = require('fs') var tmp = path.resolve( __dirname, 'tmp.txt' ) function fromString(string) { return from(function(size, next) { if (string.length <= 0) return next(null, null) var chunk = string.slice(0, size) string = string.slice(size) next(null, chunk) }) } test('from2', function(t) { var contents = fs.readFileSync(__filename, 'utf8') var stream = fromString(contents) stream .pipe(fs.createWriteStream(tmp)) .on('close', function() { t.equal(fs.readFileSync(tmp, 'utf8'), contents) fs.unlinkSync(tmp) t.end() }) }) test('old mode', function(t) { var contents = fs.readFileSync(__filename, 'utf8') var stream = fromString(contents) var buffer = '' stream.on('data', function(data) { buffer += data }).on('end', function() { t.equal(buffer, contents) t.end() }) }) test('destroy', function(t) { var stream = from(function(size, next) { process.nextTick(function() { next(null, 'no') }) }) stream.on('data', function(data) { t.ok(false) }).on('close', function() { t.ok(true) t.end() }) stream.destroy() }) test('arrays', function (t) { var input = ['a', 'b', 'c'] var stream = from(input) var output = [] stream.on('data', function (letter) { output.push(letter.toString()) }) stream.on('end', function () { t.deepEqual(input, output) t.end() }) }) test('obj arrays', function (t) { var input = [{foo:'a'}, {foo:'b'}, {foo:'c'}] var stream = from.obj(input) var output = [] stream.on('data', function (letter) { output.push(letter) }) stream.on('end', function () { t.deepEqual(input, output) t.end() }) }) test('arrays can emit errors', function (t) { var input = ['a', 'b', new Error('ooops'), 'c'] var stream = from(input) var output = [] stream.on('data', function (letter) { output.push(letter.toString()) }) stream.on('error', function(e){ t.deepEqual(['a', 'b'], output) t.equal('ooops', e.message) t.end() }) stream.on('end', function () { t.fail('the stream should have errored') }) }) test('obj arrays can emit errors', function (t) { var input = [{foo:'a'}, {foo:'b'}, new Error('ooops'), {foo:'c'}] var stream = from.obj(input) var output = [] stream.on('data', function (letter) { output.push(letter) }) stream.on('error', function(e){ t.deepEqual([{foo:'a'}, {foo:'b'}], output) t.equal('ooops', e.message) t.end() }) stream.on('end', function () { t.fail('the stream should have errored') }) })