lib: use destructuring for some constants

This change is to unify the declaration for constants into using
destructuring on the top-level-module scope, reducing some redundant
code.

PR-URL: https://github.com/nodejs/node/pull/16063
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
This commit is contained in:
Weijia Wang authored and Tobias Nießen committed 2017-10-16 23:34:32 +02:00
1 parent a3a106865a
commit 212de3c5ec
35 files changed
+132 -135

No files matched your search

+13 -11
View File
@@ -23,17 +23,19 @@
const util = require('util');
const net = require('net');
const HTTPParser = process.binding('http_parser').HTTPParser;
const { HTTPParser } = process.binding('http_parser');
const assert = require('assert').ok;
const common = require('_http_common');
const parsers = common.parsers;
const freeParser = common.freeParser;
const debug = common.debug;
const CRLF = common.CRLF;
const continueExpression = common.continueExpression;
const chunkExpression = common.chunkExpression;
const httpSocketSetup = common.httpSocketSetup;
const OutgoingMessage = require('_http_outgoing').OutgoingMessage;
const {
parsers,
freeParser,
debug,
CRLF,
continueExpression,
chunkExpression,
httpSocketSetup,
_checkInvalidHeaderChar: checkInvalidHeaderChar
} = require('_http_common');
const { OutgoingMessage } = require('_http_outgoing');
const { outHeadersKey, ondrain } = require('internal/http');
const errors = require('internal/errors');
@@ -223,7 +225,7 @@ function writeHead(statusCode, reason, obj) {
headers = obj;
}
if (common._checkInvalidHeaderChar(this.statusMessage))
if (checkInvalidHeaderChar(this.statusMessage))
throw new errors.Error('ERR_INVALID_CHAR', 'statusMessage');
var statusLine = 'HTTP/1.1 ' + statusCode + ' ' + this.statusMessage + CRLF;