diff options
author | Matteo Collina <hello@matteocollina.com> | 2018-01-04 18:06:56 +0100 |
---|---|---|
committer | Matteo Collina <hello@matteocollina.com> | 2018-01-10 10:48:03 +0100 |
commit | 1e0f3315c77033ef0e01bb37c3d41c8e1d65e686 (patch) | |
tree | b529e81c0e3fda479f2ba69996f484490fb098ca /test/parallel/test-stream2-transform.js | |
parent | 800caac2362e602d80b5c61fe1cb288bbcdb316a (diff) | |
download | android-node-v8-1e0f3315c77033ef0e01bb37c3d41c8e1d65e686.tar.gz android-node-v8-1e0f3315c77033ef0e01bb37c3d41c8e1d65e686.tar.bz2 android-node-v8-1e0f3315c77033ef0e01bb37c3d41c8e1d65e686.zip |
stream: always defer 'readable' with nextTick
Emit 'readable' always in the next tick, resulting in a single
call to _read() per microtick. This removes the need for the
user to implement buffering if they wanted to call this.push()
multiple times in an asynchronous fashion, as this.push() triggers
this._read() call.
PR-URL: https://github.com/nodejs/node/pull/17979
Fixes: https://github.com/nodejs/node/issues/3203
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Diffstat (limited to 'test/parallel/test-stream2-transform.js')
-rw-r--r-- | test/parallel/test-stream2-transform.js | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/test/parallel/test-stream2-transform.js b/test/parallel/test-stream2-transform.js index d085926542..68c25141aa 100644 --- a/test/parallel/test-stream2-transform.js +++ b/test/parallel/test-stream2-transform.js @@ -306,25 +306,26 @@ const Transform = require('_stream_transform'); pt.write(Buffer.from('foog')); pt.write(Buffer.from('bark')); - assert.strictEqual(emits, 1); + assert.strictEqual(emits, 0); assert.strictEqual(pt.read(5).toString(), 'foogb'); assert.strictEqual(String(pt.read(5)), 'null'); + assert.strictEqual(emits, 0); pt.write(Buffer.from('bazy')); pt.write(Buffer.from('kuel')); - assert.strictEqual(emits, 2); + assert.strictEqual(emits, 0); assert.strictEqual(pt.read(5).toString(), 'arkba'); assert.strictEqual(pt.read(5).toString(), 'zykue'); assert.strictEqual(pt.read(5), null); pt.end(); - assert.strictEqual(emits, 3); + assert.strictEqual(emits, 1); assert.strictEqual(pt.read(5).toString(), 'l'); assert.strictEqual(pt.read(5), null); - assert.strictEqual(emits, 3); + assert.strictEqual(emits, 1); } { @@ -338,7 +339,7 @@ const Transform = require('_stream_transform'); pt.write(Buffer.from('foog')); pt.write(Buffer.from('bark')); - assert.strictEqual(emits, 1); + assert.strictEqual(emits, 0); assert.strictEqual(pt.read(5).toString(), 'foogb'); assert.strictEqual(pt.read(5), null); @@ -352,7 +353,7 @@ const Transform = require('_stream_transform'); pt.once('readable', common.mustCall(function() { assert.strictEqual(pt.read(5).toString(), 'l'); assert.strictEqual(pt.read(5), null); - assert.strictEqual(emits, 4); + assert.strictEqual(emits, 3); })); pt.end(); })); |