![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 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_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /usr/local/lib/node_modules/browserify/node_modules/stream-splicer/test/ |
Upload File : |
var pipeline = require('../'); var through = require('through2'); var split = require('split'); var test = require('tape'); test('push', function (t) { var expected = {}; expected.first = [ 333, 444, 555, 666, 777 ]; expected.second = [ 6.66, 7.77 ]; expected.output = [ 3.33, 4.44, 5.55, 3, 2 ]; t.plan(5 + 2 + 5 + 3); var a = split(); var b = through.obj(function (row, enc, next) { this.push(JSON.parse(row)); next(); }); var c = through.obj(function (row, enc, next) { this.push(row.x); next() }); var d = through.obj(function (x, enc, next) { this.push(x * 111); next() }); var first = through.obj(function (row, enc, next) { if (expected.first.length === 2) { t.equal(p.length, 5); p.push(second); t.equal(p.length, 6); } var ex = expected.first.shift(); t.deepEqual(row, ex); this.push(row / 100); next(); }); var second = through.obj(function (row, enc, next) { var ex = expected.second.shift(); t.deepEqual(row, ex); this.push(Math.floor(10 - row)); next(); }); var p = pipeline.obj([ a, b, c, d, first ]); t.equal(p.length, 5); p.pipe(through.obj(function (row, enc, next) { var ex = expected.output.shift(); t.deepEqual(row, ex); next(); })); p.write('{"x":3}\n'); p.write('{"x":4}\n'); p.write('{"x":5}\n'); p.write('{"x":6}\n'); p.write('{"x":7}'); p.end(); });