node/test/parallel/test-stream-push-order.js
Gibson Fahnestock 7a0e462f9f test: use eslint to fix var->const/let
Manually fix issues that eslint --fix couldn't do automatically.

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-01-11 11:43:52 +00:00

32 lines
577 B
JavaScript

'use strict';
require('../common');
const Readable = require('stream').Readable;
const assert = require('assert');
const s = new Readable({
highWaterMark: 20,
encoding: 'ascii'
});
const list = ['1', '2', '3', '4', '5', '6'];
s._read = function(n) {
const one = list.shift();
if (!one) {
s.push(null);
} else {
const two = list.shift();
s.push(one);
s.push(two);
}
};
s.read(0);
// ACTUALLY [1, 3, 5, 6, 4, 2]
process.on('exit', function() {
assert.deepStrictEqual(s._readableState.buffer.join(','), '1,2,3,4,5,6');
console.log('ok');
});