0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-25 08:19:38 +01:00
nodejs/test/parallel/test-stream-transform-objectmode-falsey-value.js
isaacs 3e1b1dd4a9 Remove excessive copyright/license boilerplate
The copyright and license notice is already in the LICENSE file.  There
is no justifiable reason to also require that it be included in every
file, since the individual files are not individually distributed except
as part of the entire package.
2015-01-12 15:30:28 -08:00

33 lines
676 B
JavaScript

var common = require('../common');
var assert = require('assert');
var stream = require('stream');
var PassThrough = stream.PassThrough;
var src = new PassThrough({ objectMode: true });
var tx = new PassThrough({ objectMode: true });
var dest = new PassThrough({ objectMode: true });
var expect = [ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];
var results = [];
process.on('exit', function() {
assert.deepEqual(results, expect);
console.log('ok');
});
dest.on('data', function(x) {
results.push(x);
});
src.pipe(tx).pipe(dest);
var i = -1;
var int = setInterval(function() {
if (i > 10) {
src.end();
clearInterval(int);
} else {
src.write(i++);
}
});