net: return this from destroy() · nodejs/node@69f806c · GitHub
Skip to content

Commit 69f806c

Browse files
sam-githubaddaleax
authored andcommitted
net: return this from destroy()
PR-URL: #13530 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent e2d3254 commit 69f806c

4 files changed

Lines changed: 10 additions & 3 deletions

File tree

doc/api/net.md

Lines changed: 2 additions & 0 deletions

doc/api/stream.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,10 @@ A Writable stream in object mode will always ignore the `encoding` argument.
515515
added: v8.0.0
516516
-->
517517

518+
* Returns: `this`
519+
518520
Destroy the stream, and emit the passed error. After this call, the
519-
writible stream has ended. Implementors should not override this method,
521+
writable stream has ended. Implementors should not override this method,
520522
but instead implement [`writable._destroy`][writable-_destroy].
521523

522524
### Readable Streams

lib/internal/streams/destroy.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function destroy(err, cb) {
1414
(!this._writableState || !this._writableState.errorEmitted)) {
1515
process.nextTick(emitErrorNT, this, err);
1616
}
17-
return;
17+
return this;
1818
}
1919

2020
// we set destroyed to true before firing error callbacks in order
@@ -39,6 +39,8 @@ function destroy(err, cb) {
3939
cb(err);
4040
}
4141
});
42+
43+
return this;
4244
}
4345

4446
function undestroy() {

test/parallel/test-net-socket-destroy-send.js

Lines changed: 2 additions & 1 deletion

0 commit comments

Comments
 (0)