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
|
||||
added: v0.9.4
|
||||
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
|
||||
pr-url: https://github.com/nodejs/node/pull/11608
|
||||
description: The `chunk` argument can now be a `Uint8Array` instance.
|
||||
@ -366,6 +369,7 @@ changes:
|
||||
other than `null`.
|
||||
* `encoding` {string} The encoding, if `chunk` is a string
|
||||
* `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
|
||||
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.
|
||||
if (!state.ending)
|
||||
endWritable(this, state, cb);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Object.defineProperty(Writable.prototype, 'writableLength', {
|
||||
|
@ -24,11 +24,14 @@ writable.on('finish', () => {
|
||||
testStates(true, true, true);
|
||||
});
|
||||
|
||||
writable.end('testing function end()', () => {
|
||||
const result = writable.end('testing function end()', () => {
|
||||
// ending, finished, ended = true.
|
||||
testStates(true, true, true);
|
||||
});
|
||||
|
||||
// end returns the writable instance
|
||||
assert.strictEqual(result, writable);
|
||||
|
||||
// ending, ended = true.
|
||||
// finished = false.
|
||||
testStates(true, false, true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user