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('nested splicer', function (t) {
9
t.plan(1);
10
11
var addNewLines = through(function (buf, enc, next) {
12
this.push(buf + '\n');
13
next();
14
});
15
16
var stream = pipeline.obj([
17
[ split(), addNewLines ],
18
through(function (buf, enc, next) {
19
this.push('> ' + buf);
20
next()
21
})
22
]);
23
24
stream.get(0).unshift(through(function (buf, enc, next) {
25
this.push(buf.toString('utf8').toUpperCase());
26
next();
27
}));
28
29
stream.pipe(concat(function (body) {
30
t.deepEqual(body.toString(), '> A\n> B\n> C\n');
31
}));
32
33
stream.write('a\n');
34
stream.write('b\n');
35
stream.write('c');
36
stream.end();
37
});
38
39