stream: writable.end should return this.
PR-URL: https://github.com/nodejs/node/pull/18780 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
e91ea21411
commit
f6721c20df
@ -355,6 +355,9 @@ See also: [`writable.uncork()`][].
|
|||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v0.9.4
|
added: v0.9.4
|
||||||
changes:
|
changes:
|
||||||
|
- version: REPLACEME
|
||||||
|
pr-url: https://github.com/nodejs/node/pull/18780
|
||||||
|
description: This method now returns a reference to `writable`.
|
||||||
- version: v8.0.0
|
- version: v8.0.0
|
||||||
pr-url: https://github.com/nodejs/node/pull/11608
|
pr-url: https://github.com/nodejs/node/pull/11608
|
||||||
description: The `chunk` argument can now be a `Uint8Array` instance.
|
description: The `chunk` argument can now be a `Uint8Array` instance.
|
||||||
@ -366,6 +369,7 @@ changes:
|
|||||||
other than `null`.
|
other than `null`.
|
||||||
* `encoding` {string} The encoding, if `chunk` is a string
|
* `encoding` {string} The encoding, if `chunk` is a string
|
||||||
* `callback` {Function} Optional callback for when the stream is finished
|
* `callback` {Function} Optional callback for when the stream is finished
|
||||||
|
* Returns: {this}
|
||||||
|
|
||||||
Calling the `writable.end()` method signals that no more data will be written
|
Calling the `writable.end()` method signals that no more data will be written
|
||||||
to the [Writable][]. The optional `chunk` and `encoding` arguments allow one
|
to the [Writable][]. The optional `chunk` and `encoding` arguments allow one
|
||||||
|
@ -570,6 +570,8 @@ Writable.prototype.end = function(chunk, encoding, cb) {
|
|||||||
// ignore unnecessary end() calls.
|
// ignore unnecessary end() calls.
|
||||||
if (!state.ending)
|
if (!state.ending)
|
||||||
endWritable(this, state, cb);
|
endWritable(this, state, cb);
|
||||||
|
|
||||||
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.defineProperty(Writable.prototype, 'writableLength', {
|
Object.defineProperty(Writable.prototype, 'writableLength', {
|
||||||
|
@ -24,11 +24,14 @@ writable.on('finish', () => {
|
|||||||
testStates(true, true, true);
|
testStates(true, true, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
writable.end('testing function end()', () => {
|
const result = writable.end('testing function end()', () => {
|
||||||
// ending, finished, ended = true.
|
// ending, finished, ended = true.
|
||||||
testStates(true, true, true);
|
testStates(true, true, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// end returns the writable instance
|
||||||
|
assert.strictEqual(result, writable);
|
||||||
|
|
||||||
// ending, ended = true.
|
// ending, ended = true.
|
||||||
// finished = false.
|
// finished = false.
|
||||||
testStates(true, false, true);
|
testStates(true, false, true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user