Node.js: returning "this" from writeHead() to allow chaining.

In Node.js version 11.10.0 and later, the writeHead() function returns "this".
This commit is contained in:
Valentin Bartenev
2019-08-06 16:24:11 +03:00
parent c7210eaa5a
commit 7fd9444728
11 changed files with 16 additions and 20 deletions

View File

@@ -6,8 +6,7 @@ require('unit-http').createServer(function (req, res) {
res.end();
if (req.headers['x-write-call']) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('blah');
res.writeHead(200, {'Content-Type': 'text/plain'}).write('blah');
}
Promise.resolve().then(() => {