Updated the files.
This commit is contained in:
parent
1553e6b971
commit
753967d4f5
23418 changed files with 3784666 additions and 0 deletions
29
my-app/node_modules/@ljharb/through/test/async.js
generated
vendored
Executable file
29
my-app/node_modules/@ljharb/through/test/async.js
generated
vendored
Executable file
|
@ -0,0 +1,29 @@
|
|||
'use strict';
|
||||
|
||||
var from = require('from');
|
||||
var through = require('../');
|
||||
|
||||
var tape = require('tape');
|
||||
|
||||
tape('simple async example', function (t) {
|
||||
var expected = [1, 2, 3, 4, 5];
|
||||
var actual = [];
|
||||
from(expected)
|
||||
.pipe(through(function (data) {
|
||||
this.pause();
|
||||
|
||||
setTimeout(function () {
|
||||
console.log('pushing data', data);
|
||||
this.push(data);
|
||||
this.resume();
|
||||
}.bind(this), 300);
|
||||
})).pipe(through(function (data) {
|
||||
console.log('pushing data second time', data);
|
||||
this.push(data);
|
||||
})).on('data', function (d) {
|
||||
actual.push(d);
|
||||
}).on('end', function () {
|
||||
t.deepEqual(actual, expected);
|
||||
t.end();
|
||||
});
|
||||
});
|
33
my-app/node_modules/@ljharb/through/test/auto-destroy.js
generated
vendored
Executable file
33
my-app/node_modules/@ljharb/through/test/auto-destroy.js
generated
vendored
Executable file
|
@ -0,0 +1,33 @@
|
|||
'use strict';
|
||||
|
||||
var test = require('tape');
|
||||
var through = require('../');
|
||||
|
||||
// must emit end before close.
|
||||
|
||||
test('end before close', function (assert) {
|
||||
var ts = through();
|
||||
ts.autoDestroy = false;
|
||||
var ended = false;
|
||||
var closed = false;
|
||||
|
||||
ts.on('end', function () {
|
||||
assert.ok(!closed);
|
||||
ended = true;
|
||||
});
|
||||
ts.on('close', function () {
|
||||
assert.ok(ended);
|
||||
closed = true;
|
||||
});
|
||||
|
||||
ts.write(1);
|
||||
ts.write(2);
|
||||
ts.write(3);
|
||||
ts.end();
|
||||
assert.ok(ended);
|
||||
assert.notOk(closed);
|
||||
ts.destroy();
|
||||
assert.ok(closed);
|
||||
assert.end();
|
||||
});
|
||||
|
70
my-app/node_modules/@ljharb/through/test/buffering.js
generated
vendored
Executable file
70
my-app/node_modules/@ljharb/through/test/buffering.js
generated
vendored
Executable file
|
@ -0,0 +1,70 @@
|
|||
'use strict';
|
||||
|
||||
var test = require('tape');
|
||||
var through = require('../');
|
||||
|
||||
// must emit end before close.
|
||||
|
||||
test('buffering', function (assert) {
|
||||
var ts = through(function (data) {
|
||||
this.queue(data);
|
||||
}, function () {
|
||||
this.queue(null);
|
||||
});
|
||||
|
||||
var ended = false;
|
||||
var actual = [];
|
||||
|
||||
ts.on('data', actual.push.bind(actual));
|
||||
ts.on('end', function () {
|
||||
ended = true;
|
||||
});
|
||||
|
||||
ts.write(1);
|
||||
ts.write(2);
|
||||
ts.write(3);
|
||||
assert.deepEqual(actual, [1, 2, 3]);
|
||||
ts.pause();
|
||||
ts.write(4);
|
||||
ts.write(5);
|
||||
ts.write(6);
|
||||
assert.deepEqual(actual, [1, 2, 3]);
|
||||
ts.resume();
|
||||
assert.deepEqual(actual, [1, 2, 3, 4, 5, 6]);
|
||||
ts.pause();
|
||||
ts.end();
|
||||
assert.ok(!ended);
|
||||
ts.resume();
|
||||
assert.ok(ended);
|
||||
assert.end();
|
||||
});
|
||||
|
||||
test('buffering has data in queue, when ends', function (assert) {
|
||||
// If stream ends while paused with data in the queue, stream should still emit end after all data is written on resume.
|
||||
|
||||
var ts = through(function (data) {
|
||||
this.queue(data);
|
||||
}, function () {
|
||||
this.queue(null);
|
||||
});
|
||||
|
||||
var ended = false;
|
||||
var actual = [];
|
||||
|
||||
ts.on('data', actual.push.bind(actual));
|
||||
ts.on('end', function () {
|
||||
ended = true;
|
||||
});
|
||||
|
||||
ts.pause();
|
||||
ts.write(1);
|
||||
ts.write(2);
|
||||
ts.write(3);
|
||||
ts.end();
|
||||
assert.deepEqual(actual, [], 'no data written yet, still paused');
|
||||
assert.ok(!ended, 'end not emitted yet, still paused');
|
||||
ts.resume();
|
||||
assert.deepEqual(actual, [1, 2, 3], 'resumed, all data should be delivered');
|
||||
assert.ok(ended, 'end should be emitted once all data was delivered');
|
||||
assert.end();
|
||||
});
|
47
my-app/node_modules/@ljharb/through/test/end.js
generated
vendored
Executable file
47
my-app/node_modules/@ljharb/through/test/end.js
generated
vendored
Executable file
|
@ -0,0 +1,47 @@
|
|||
'use strict';
|
||||
|
||||
var test = require('tape');
|
||||
var through = require('../');
|
||||
|
||||
// must emit end before close.
|
||||
|
||||
test('end before close', function (assert) {
|
||||
var ts = through();
|
||||
var ended = false;
|
||||
var closed = false;
|
||||
|
||||
ts.on('end', function () {
|
||||
assert.ok(!closed);
|
||||
ended = true;
|
||||
});
|
||||
ts.on('close', function () {
|
||||
assert.ok(ended);
|
||||
closed = true;
|
||||
});
|
||||
|
||||
ts.write(1);
|
||||
ts.write(2);
|
||||
ts.write(3);
|
||||
ts.end();
|
||||
assert.ok(ended);
|
||||
assert.ok(closed);
|
||||
assert.end();
|
||||
});
|
||||
|
||||
test('end only once', function (t) {
|
||||
var ts = through();
|
||||
var ended = false;
|
||||
|
||||
ts.on('end', function () {
|
||||
t.equal(ended, false);
|
||||
ended = true;
|
||||
});
|
||||
|
||||
ts.queue(null);
|
||||
ts.queue(null);
|
||||
ts.queue(null);
|
||||
|
||||
ts.resume();
|
||||
|
||||
t.end();
|
||||
});
|
129
my-app/node_modules/@ljharb/through/test/index.js
generated
vendored
Executable file
129
my-app/node_modules/@ljharb/through/test/index.js
generated
vendored
Executable file
|
@ -0,0 +1,129 @@
|
|||
'use strict';
|
||||
|
||||
var test = require('tape');
|
||||
var spec = require('stream-spec');
|
||||
var through = require('../');
|
||||
|
||||
/*
|
||||
*I'm using these two functions, and not streams and pipe
|
||||
*so there is less to break. if this test fails it must be
|
||||
*the implementation of _through_
|
||||
*/
|
||||
|
||||
function write(array, stream) {
|
||||
array = array.slice();
|
||||
function next() {
|
||||
while (array.length) { if (stream.write(array.shift()) === false) { return stream.once('drain', next); } }
|
||||
|
||||
stream.end();
|
||||
}
|
||||
|
||||
next();
|
||||
}
|
||||
|
||||
function read(stream, callback) {
|
||||
var actual = [];
|
||||
stream.on('data', function (data) {
|
||||
actual.push(data);
|
||||
});
|
||||
stream.once('end', function () {
|
||||
callback(null, actual);
|
||||
});
|
||||
stream.once('error', function (err) {
|
||||
callback(err);
|
||||
});
|
||||
}
|
||||
|
||||
test('simple defaults', function (assert) {
|
||||
var l = 1000;
|
||||
var expected = [];
|
||||
|
||||
while (l--) { expected.push(l * Math.random()); }
|
||||
|
||||
var t = through();
|
||||
var s = spec(t).through().pausable();
|
||||
|
||||
read(t, function (err, actual) {
|
||||
assert.ifError(err);
|
||||
assert.deepEqual(actual, expected);
|
||||
assert.end();
|
||||
});
|
||||
|
||||
t.on('close', s.validate);
|
||||
|
||||
write(expected, t);
|
||||
});
|
||||
|
||||
test('simple functions', function (assert) {
|
||||
var l = 1000;
|
||||
var expected = [];
|
||||
|
||||
while (l--) { expected.push(l * Math.random()); }
|
||||
|
||||
var t = through(function (data) {
|
||||
this.emit('data', data * 2);
|
||||
});
|
||||
var s = spec(t).through().pausable();
|
||||
|
||||
read(t, function (err, actual) {
|
||||
assert.ifError(err);
|
||||
assert.deepEqual(actual, expected.map(function (data) {
|
||||
return data * 2;
|
||||
}));
|
||||
assert.end();
|
||||
});
|
||||
|
||||
t.on('close', s.validate);
|
||||
|
||||
write(expected, t);
|
||||
});
|
||||
|
||||
test('pauses', function (assert) {
|
||||
|
||||
var l = 1000;
|
||||
var expected = [];
|
||||
|
||||
while (l--) { expected.push(l); } // Math.random())
|
||||
|
||||
var t = through();
|
||||
|
||||
var s = spec(t)
|
||||
.through()
|
||||
.pausable();
|
||||
|
||||
t.on('data', function () {
|
||||
if (Math.random() > 0.1) { return; }
|
||||
t.pause();
|
||||
process.nextTick(function () {
|
||||
t.resume();
|
||||
});
|
||||
});
|
||||
|
||||
read(t, function (err, actual) {
|
||||
assert.ifError(err);
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
t.on('close', function () {
|
||||
s.validate();
|
||||
assert.end();
|
||||
});
|
||||
|
||||
write(expected, t);
|
||||
});
|
||||
|
||||
test('does not soft-end on `undefined`', function (assert) {
|
||||
var stream = through();
|
||||
var count = 0;
|
||||
|
||||
stream.on('data', function () {
|
||||
count += 1;
|
||||
});
|
||||
|
||||
stream.write(undefined);
|
||||
stream.write(undefined);
|
||||
|
||||
assert.equal(count, 2);
|
||||
|
||||
assert.end();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue