1'use strict'; 2 3const common = require('../common'); 4const stream = require('stream'); 5const assert = require('assert'); 6 7const transform = new stream.Transform({ 8 transform: _transform, 9 highWaterMark: 1 10}); 11 12function _transform(chunk, encoding, cb) { 13 process.nextTick(() => { 14 assert.strictEqual(transform._writableState.needDrain, true); 15 cb(); 16 }); 17} 18 19assert.strictEqual(transform._writableState.needDrain, false); 20 21transform.write('asdasd', common.mustCall(() => { 22 assert.strictEqual(transform._writableState.needDrain, false); 23})); 24 25assert.strictEqual(transform._writableState.needDrain, true); 26