mirror of
https://github.com/nodejs/node.git
synced 2024-11-30 07:27:22 +01:00
9ed7261b57
Add a test for _writableState.needDrain. PR-URL: https://github.com/nodejs/node/pull/8799 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Related: https://github.com/nodejs/node/issues/8686
24 lines
576 B
JavaScript
24 lines
576 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const stream = require('stream');
|
|
const assert = require('assert');
|
|
|
|
const transform = new stream.Transform({
|
|
transform: _transform,
|
|
highWaterMark: 1
|
|
});
|
|
|
|
function _transform(chunk, encoding, cb) {
|
|
assert.strictEqual(transform._writableState.needDrain, true);
|
|
cb();
|
|
}
|
|
|
|
assert.strictEqual(transform._writableState.needDrain, false);
|
|
|
|
transform.write('asdasd', common.mustCall(() => {
|
|
assert.strictEqual(transform._writableState.needDrain, false);
|
|
}));
|
|
|
|
assert.strictEqual(transform._writableState.needDrain, true);
|