mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
1e0f3315c7
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>
31 lines
565 B
JavaScript
31 lines
565 B
JavaScript
'use strict';
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const net = require('net');
|
|
|
|
const uv = process.binding('uv');
|
|
|
|
const s = new net.Socket({
|
|
handle: {
|
|
readStart: function() {
|
|
setImmediate(() => this.onread(uv.UV_EOF, null));
|
|
},
|
|
close: (cb) => setImmediate(cb)
|
|
},
|
|
writable: false
|
|
});
|
|
assert.strictEqual(s, s.resume());
|
|
|
|
const events = [];
|
|
|
|
s.on('end', () => {
|
|
events.push('end');
|
|
});
|
|
s.on('close', () => {
|
|
events.push('close');
|
|
});
|
|
|
|
process.on('exit', () => {
|
|
assert.deepStrictEqual(events, [ 'end', 'close' ]);
|
|
});
|