Files
node/test/parallel/test-stream-transform-objectmode-falsey-value.js
Gibson Fahnestock db61c952de test: use eslint to fix var->const/let
Manually fix issues that eslint --fix couldn't do automatically.

Backport-PR-URL: https://github.com/nodejs/node/pull/11775
PR-URL: https://github.com/nodejs/node/pull/10685
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
2017-04-18 20:01:49 -04:00

34 lines
704 B
JavaScript

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