Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80540 views
1
var pipeline = require('../');
2
var through = require('through2');
3
var stringify = require('JSONStream').stringify;
4
var split = require('split');
5
var concat = require('concat-stream');
6
var test = require('tape');
7
8
test('combiner returned stream', function (t) {
9
t.plan(1);
10
11
var a = split();
12
var b = through.obj(function (row, enc, next) {
13
this.push(JSON.parse(row));
14
next();
15
});
16
var c = through.obj(function (row, enc, next) { this.push(row.x); next() });
17
var d = through.obj(function (x, enc, next) { this.push(x * 111); next() });
18
var e = stringify();
19
20
var stream = pipeline([ a, b, c, d, e ]);
21
stream.pipe(concat(function (body) {
22
t.deepEqual(body.toString(), '[\n333\n,\n444\n,\n555\n]\n');
23
}));
24
25
stream.write('{"x":3}\n');
26
stream.write('{"x":4}\n');
27
stream.write('{"x":5}');
28
stream.end();
29
});
30
31