This commit is contained in:
Simon Priet
2021-09-05 22:53:58 +02:00
commit 9e2991e668
17888 changed files with 1263126 additions and 0 deletions

31
node_modules/stream-splicer/test/combiner.js generated vendored Normal file
View File

@@ -0,0 +1,31 @@
var pipeline = require('../');
var through = require('through2');
var stringify = require('JSONStream').stringify;
var split = require('split');
var concat = require('concat-stream');
var test = require('tape');
test('combiner', function (t) {
t.plan(1);
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 e = stringify();
var input = through();
var output = through();
output.pipe(concat(function (body) {
t.deepEqual(body.toString(), '[\n333\n,\n444\n,\n555\n]\n');
}));
pipeline([ input, a, b, c, d, e, output ]);
input.write('{"x":3}\n');
input.write('{"x":4}\n');
input.write('{"x":5}');
input.end();
});

29
node_modules/stream-splicer/test/combiner_stream.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
var pipeline = require('../');
var through = require('through2');
var stringify = require('JSONStream').stringify;
var split = require('split');
var concat = require('concat-stream');
var test = require('tape');
test('combiner returned stream', function (t) {
t.plan(1);
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 e = stringify();
var stream = pipeline([ a, b, c, d, e ]);
stream.pipe(concat(function (body) {
t.deepEqual(body.toString(), '[\n333\n,\n444\n,\n555\n]\n');
}));
stream.write('{"x":3}\n');
stream.write('{"x":4}\n');
stream.write('{"x":5}');
stream.end();
});

17
node_modules/stream-splicer/test/empty.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
var pipeline = require('../');
var concat = require('concat-stream');
var test = require('tape');
test('empty passthrough stream', function (t) {
t.plan(1);
var stream = pipeline([]);
stream.pipe(concat(function (body) {
t.deepEqual(body.toString(), 'abc');
}));
stream.write('a');
stream.write('b');
stream.write('c');
stream.end();
});

13
node_modules/stream-splicer/test/empty_no_data.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
var pipeline = require('../');
var concat = require('concat-stream');
var test = require('tape');
test('empty with no data', function (t) {
t.plan(1);
var stream = pipeline([]);
stream.end();
stream.pipe(concat(function (body) {
t.deepEqual(body.toString(), '');
}));
});

41
node_modules/stream-splicer/test/get.js generated vendored Normal file
View File

@@ -0,0 +1,41 @@
var pipeline = require('../');
var through = require('through2');
var test = require('tape');
test('get', function (t) {
var a = through.obj();
var b = through.obj();
var c = through.obj();
var pipe = pipeline([ a, b, c ]);
t.equal(pipe.get(0), a, '0');
t.equal(pipe.get(1), b, '1');
t.equal(pipe.get(2), c, '2');
t.equal(pipe.get(3), undefined, '3');
t.equal(pipe.get(4), undefined, '4');
t.equal(pipe.get(5), undefined, '5');
t.equal(pipe.get(-1), c, '-1');
t.equal(pipe.get(-1), c, '-1');
t.equal(pipe.get(-2), b, '-2');
t.equal(pipe.get(-3), a, '-3');
t.equal(pipe.get(-4), undefined, '-4');
t.equal(pipe.get(-5), undefined, '-5');
t.end();
});
test('nested get', function (t) {
var a = through.obj();
var b = through.obj();
var c = through.obj();
var d = through.obj();
var e = through.obj();
var f = through.obj();
var g = through.obj();
var pipe = pipeline([ a, [ b, c, [ d, [ e ], f ] ], g ]);
t.equal(pipe.get(0), a);
t.equal(pipe.get(1, -1, 1, 0), e);
t.equal(pipe.get(1, 3), undefined);
t.equal(pipe.get(4, 3), undefined);
t.end();
});

31
node_modules/stream-splicer/test/multipush.js generated vendored Normal file
View File

@@ -0,0 +1,31 @@
var pipeline = require('../');
var through = require('through2');
var stringify = require('JSONStream').stringify;
var split = require('split');
var concat = require('concat-stream');
var test = require('tape');
test('multipush', function (t) {
t.plan(1);
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 e = stringify();
var stream = pipeline();
stream.push(a, b, c);
stream.push(d, e);
stream.pipe(concat(function (body) {
t.deepEqual(body.toString(), '[\n333\n,\n444\n,\n555\n]\n');
}));
stream.write('{"x":3}\n');
stream.write('{"x":4}\n');
stream.write('{"x":5}');
stream.end();
});

31
node_modules/stream-splicer/test/multiunshift.js generated vendored Normal file
View File

@@ -0,0 +1,31 @@
var pipeline = require('../');
var through = require('through2');
var stringify = require('JSONStream').stringify;
var split = require('split');
var concat = require('concat-stream');
var test = require('tape');
test('multiunshift', function (t) {
t.plan(1);
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 e = stringify();
var stream = pipeline();
stream.unshift(d, e);
stream.unshift(a, b, c);
stream.pipe(concat(function (body) {
t.deepEqual(body.toString(), '[\n333\n,\n444\n,\n555\n]\n');
}));
stream.write('{"x":3}\n');
stream.write('{"x":4}\n');
stream.write('{"x":5}');
stream.end();
});

36
node_modules/stream-splicer/test/nested.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
var pipeline = require('../');
var through = require('through2');
var split = require('split');
var concat = require('concat-stream');
var test = require('tape');
test('nested splicer', function (t) {
t.plan(1);
var addNewLines = through(function (buf, enc, next) {
this.push(buf + '\n');
next();
});
var stream = pipeline.obj([
[ split(), addNewLines ],
through(function (buf, enc, next) {
this.push('> ' + buf);
next()
})
]);
stream.get(0).unshift(through(function (buf, enc, next) {
this.push(buf.toString('utf8').toUpperCase());
next();
}));
stream.pipe(concat(function (body) {
t.deepEqual(body.toString(), '> A\n> B\n> C\n');
}));
stream.write('a\n');
stream.write('b\n');
stream.write('c');
stream.end();
});

42
node_modules/stream-splicer/test/nested_middle.js generated vendored Normal file
View File

@@ -0,0 +1,42 @@
var pipeline = require('../');
var through = require('through2');
var split = require('split');
var concat = require('concat-stream');
var test = require('tape');
test('nested middle splicer', function (t) {
t.plan(1);
var addNewLines = through(function (buf, enc, next) {
this.push(buf + '\n');
next();
});
var stream = pipeline.obj([
through.obj(function (str, enc, next) {
this.push(str.replace(/^./, function (c) {
return String.fromCharCode(c.charCodeAt(0) + 5);
}));
next();
}),
[ split(), addNewLines ],
through(function (buf, enc, next) {
this.push('> ' + buf);
next()
})
]);
stream.get(1).unshift(through(function (buf, enc, next) {
this.push(buf.toString('utf8').toUpperCase());
next();
}));
stream.pipe(concat(function (body) {
t.deepEqual(body.toString(), '> F\n> G\n> H\n');
}));
stream.write('a\n');
stream.write('b\n');
stream.write('c');
stream.end();
});

46
node_modules/stream-splicer/test/pop.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
var pipeline = require('../');
var through = require('through2');
var split = require('split');
var concat = require('concat-stream');
var test = require('tape');
test('pop', function (t) {
var expected = {};
expected.replacer = [ '333', '444' ];
t.plan(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(String(x * 111));
next();
});
var replacer = through(function (buf, enc, next) {
var ex = expected.replacer.shift();
t.equal(buf.toString(), ex);
this.push(buf.toString('hex') + '\n');
if (expected.replacer.length === 0) {
stream.pop();
}
next();
});
var stream = pipeline([ a, b, c, d, replacer ]);
stream.pipe(concat(function (body) {
t.deepEqual(body.toString(), '333333\n343434\n555666');
}));
stream.write('{"x":3}\n');
stream.write('{"x":4}\n');
stream.write('{"x":5}\n');
stream.write('{"x":6}');
stream.end();
});

57
node_modules/stream-splicer/test/push.js generated vendored Normal file
View File

@@ -0,0 +1,57 @@
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();
});

46
node_modules/stream-splicer/test/shift.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
var pipeline = require('../');
var through = require('through2');
var test = require('tape');
test('shift', function (t) {
var expected = {};
expected.a = [ 3, 4 ];
expected.b = [ 300, 400, 5, 6 ];
expected.c = [ 310, 410, 15, 16 ];
expected.output = [ 155, 205, 15/2, 8 ];
t.plan(2 + 4 + 4 + 4);
var a = through.obj(function (x, enc, next) {
var ex = expected.a.shift();
t.equal(x, ex, 'a');
this.push(x * 100);
next();
});
var b = through.obj(function (x, enc, next) {
var ex = expected.b.shift();
t.equal(x, ex, 'b');
if (expected.b.length === 2) p.shift()
this.push(x + 10);
next();
});
var c = through.obj(function (x, enc, next) {
var ex = expected.c.shift();
t.equal(x, ex, 'c');
this.push(x / 2);
next();
});
var p = pipeline.obj([ a, b, c ]);
p.pipe(through.obj(function (x, enc, next) {
var ex = expected.output.shift();
t.equal(x, ex);
next();
}));
p.write(3);
p.write(4);
p.write(5);
p.write(6);
p.end();
});

58
node_modules/stream-splicer/test/splice.js generated vendored Normal file
View File

@@ -0,0 +1,58 @@
var pipeline = require('../');
var through = require('through2');
var split = require('split');
var concat = require('concat-stream');
var test = require('tape');
test('splice', function (t) {
var expected = {};
expected.replacer = [ '333', '444', '5000', '6000' ];
expected.d = [ 3, 4 ];
expected.thousander = [ 5, 6 ];
t.plan(4 + 2 + 2 + 1);
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) {
t.equal(x, expected.d.shift(), 'd');
this.push(String(x * 111));
next();
});
var thousander = through.obj(function (x, enc, next) {
t.equal(x, expected.thousander.shift(), 'thousander');
this.push(String(x * 1000));
next();
});
var replacer = through(function (buf, enc, next) {
var ex = expected.replacer.shift();
t.equal(buf.toString(), ex);
if (expected.replacer.length === 2) {
stream.splice(3, 1, thousander);
}
this.push(buf.toString('hex') + '\n');
next();
});
var stream = pipeline([ a, b, c, d, replacer ]);
stream.pipe(concat(function (body) {
t.deepEqual(
body.toString(),
'333333\n343434\n35303030\n36303030\n'
);
}));
stream.write('{"x":3}\n');
stream.write('{"x":4}\n');
stream.write('{"x":5}\n');
stream.write('{"x":6}');
stream.end();
});

46
node_modules/stream-splicer/test/unshift.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
var pipeline = require('../');
var through = require('through2');
var test = require('tape');
test('unshift', function (t) {
var expected = {};
expected.a = [ 5, 6 ];
expected.b = [ 3, 4, 500, 600 ];
expected.c = [ 13, 14, 510, 610 ];
expected.output = [ 13/2, 7, 255, 305 ];
t.plan(2 + 4 + 4 + 4);
var a = through.obj(function (x, enc, next) {
var ex = expected.a.shift();
t.equal(x, ex, 'a');
this.push(x * 100);
next();
});
var b = through.obj(function (x, enc, next) {
var ex = expected.b.shift();
t.equal(x, ex, 'b');
if (expected.b.length === 2) p.unshift(a)
this.push(x + 10);
next();
});
var c = through.obj(function (x, enc, next) {
var ex = expected.c.shift();
t.equal(x, ex, 'c');
this.push(x / 2);
next();
});
var p = pipeline.obj([ b, c ]);
p.pipe(through.obj(function (x, enc, next) {
var ex = expected.output.shift();
t.equal(x, ex);
next();
}));
p.write(3);
p.write(4);
p.write(5);
p.write(6);
p.end();
});