Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80540 views
1
var pipeline = require('../');
2
var through = require('through2');
3
var test = require('tape');
4
5
test('get', function (t) {
6
var a = through.obj();
7
var b = through.obj();
8
var c = through.obj();
9
10
var pipe = pipeline([ a, b, c ]);
11
t.equal(pipe.get(0), a, '0');
12
t.equal(pipe.get(1), b, '1');
13
t.equal(pipe.get(2), c, '2');
14
t.equal(pipe.get(3), undefined, '3');
15
t.equal(pipe.get(4), undefined, '4');
16
t.equal(pipe.get(5), undefined, '5');
17
t.equal(pipe.get(-1), c, '-1');
18
t.equal(pipe.get(-1), c, '-1');
19
t.equal(pipe.get(-2), b, '-2');
20
t.equal(pipe.get(-3), a, '-3');
21
t.equal(pipe.get(-4), undefined, '-4');
22
t.equal(pipe.get(-5), undefined, '-5');
23
t.end();
24
});
25
26
test('nested get', function (t) {
27
var a = through.obj();
28
var b = through.obj();
29
var c = through.obj();
30
var d = through.obj();
31
var e = through.obj();
32
var f = through.obj();
33
var g = through.obj();
34
35
var pipe = pipeline([ a, [ b, c, [ d, [ e ], f ] ], g ]);
36
t.equal(pipe.get(0), a);
37
t.equal(pipe.get(1, -1, 1, 0), e);
38
t.equal(pipe.get(1, 3), undefined);
39
t.equal(pipe.get(4, 3), undefined);
40
t.end();
41
});
42
43