Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: use const to define constants #541

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions lib/_debug_agent.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
'use strict';

var assert = require('assert');
var net = require('net');
var util = require('util');
var Buffer = require('buffer').Buffer;

var Transform = require('stream').Transform;
const assert = require('assert');
const net = require('net');
const util = require('util');
const Buffer = require('buffer').Buffer;
const Transform = require('stream').Transform;

exports.start = function start() {
var agent = new Agent();

// Do not let `agent.listen()` request listening from cluster master
var cluster = require('cluster');
const cluster = require('cluster');
cluster.isWorker = false;
cluster.isMaster = true;

Expand Down
56 changes: 28 additions & 28 deletions lib/_debugger.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict';

var util = require('util'),
path = require('path'),
net = require('net'),
vm = require('vm'),
module = require('module'),
repl = module.requireRepl(),
inherits = util.inherits,
assert = require('assert'),
spawn = require('child_process').spawn;
const util = require('util');
const path = require('path');
const net = require('net');
const vm = require('vm');
const module = require('module');
const repl = module.requireRepl();
const inherits = util.inherits;
const assert = require('assert');
const spawn = require('child_process').spawn;

exports.start = function(argv, stdin, stdout) {
argv || (argv = process.argv.slice(2));
Expand Down Expand Up @@ -137,7 +137,7 @@ Protocol.prototype.serialize = function(req) {
};


var NO_FRAME = -1;
const NO_FRAME = -1;

function Client() {
net.Stream.call(this);
Expand Down Expand Up @@ -176,7 +176,7 @@ Client.prototype._addHandle = function(desc) {
};


var natives = process.binding('natives');
const natives = process.binding('natives');


Client.prototype._addScript = function(desc) {
Expand Down Expand Up @@ -645,7 +645,7 @@ Client.prototype.fullTrace = function(cb) {



var commands = [
const commands = [
[
'run (r)',
'cont (c)',
Expand Down Expand Up @@ -772,22 +772,22 @@ function Interface(stdin, stdout, args) {
process.once('SIGTERM', process.exit.bind(process, 0));
process.once('SIGHUP', process.exit.bind(process, 0));

var proto = Interface.prototype,
ignored = ['pause', 'resume', 'exitRepl', 'handleBreak',
'requireConnection', 'killChild', 'trySpawn',
'controlEval', 'debugEval', 'print', 'childPrint',
'clearline'],
shortcut = {
'run': 'r',
'cont': 'c',
'next': 'n',
'step': 's',
'out': 'o',
'backtrace': 'bt',
'setBreakpoint': 'sb',
'clearBreakpoint': 'cb',
'pause_': 'pause'
};
var proto = Interface.prototype;
const ignored = ['pause', 'resume', 'exitRepl', 'handleBreak',
'requireConnection', 'killChild', 'trySpawn',
'controlEval', 'debugEval', 'print', 'childPrint',
'clearline'];
const shortcut = {
'run': 'r',
'cont': 'c',
'next': 'n',
'step': 's',
'out': 'o',
'backtrace': 'bt',
'setBreakpoint': 'sb',
'clearBreakpoint': 'cb',
'pause_': 'pause'
};

function defineProperty(key, protoKey) {
// Check arity
Expand Down
8 changes: 4 additions & 4 deletions lib/_http_agent.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

var net = require('net');
var util = require('util');
var EventEmitter = require('events').EventEmitter;
var debug = util.debuglog('http');
const net = require('net');
const util = require('util');
const EventEmitter = require('events').EventEmitter;
const debug = util.debuglog('http');

// New Agent code.

Expand Down
33 changes: 15 additions & 18 deletions lib/_http_client.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
'use strict';

var util = require('util');
var net = require('net');
var url = require('url');
var EventEmitter = require('events').EventEmitter;
var HTTPParser = process.binding('http_parser').HTTPParser;
var assert = require('assert').ok;

var common = require('_http_common');

var httpSocketSetup = common.httpSocketSetup;
var parsers = common.parsers;
var freeParser = common.freeParser;
var debug = common.debug;

var OutgoingMessage = require('_http_outgoing').OutgoingMessage;

var Agent = require('_http_agent');
const util = require('util');
const net = require('net');
const url = require('url');
const EventEmitter = require('events').EventEmitter;
const HTTPParser = process.binding('http_parser').HTTPParser;
const assert = require('assert').ok;
const common = require('_http_common');
const httpSocketSetup = common.httpSocketSetup;
const parsers = common.parsers;
const freeParser = common.freeParser;
const debug = common.debug;
const OutgoingMessage = require('_http_outgoing').OutgoingMessage;
const Agent = require('_http_agent');


function ClientRequest(options, cb) {
Expand Down Expand Up @@ -56,7 +52,8 @@ function ClientRequest(options, cb) {
'Expected "' + expectedProtocol + '".');
}

var defaultPort = options.defaultPort || self.agent && self.agent.defaultPort;
const defaultPort = options.defaultPort ||
self.agent && self.agent.defaultPort;

var port = options.port = options.port || defaultPort || 80;
var host = options.host = options.hostname || options.host || 'localhost';
Expand Down
24 changes: 12 additions & 12 deletions lib/_http_common.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
'use strict';

var FreeList = require('freelist').FreeList;
var HTTPParser = process.binding('http_parser').HTTPParser;
const FreeList = require('freelist').FreeList;
const HTTPParser = process.binding('http_parser').HTTPParser;

var incoming = require('_http_incoming');
var IncomingMessage = incoming.IncomingMessage;
var readStart = incoming.readStart;
var readStop = incoming.readStop;
const incoming = require('_http_incoming');
const IncomingMessage = incoming.IncomingMessage;
const readStart = incoming.readStart;
const readStop = incoming.readStop;

var isNumber = require('util').isNumber;
var debug = require('util').debuglog('http');
const isNumber = require('util').isNumber;
const debug = require('util').debuglog('http');
exports.debug = debug;

exports.CRLF = '\r\n';
exports.chunkExpression = /chunk/i;
exports.continueExpression = /100-continue/i;
exports.methods = HTTPParser.methods;

var kOnHeaders = HTTPParser.kOnHeaders | 0;
var kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0;
var kOnBody = HTTPParser.kOnBody | 0;
var kOnMessageComplete = HTTPParser.kOnMessageComplete | 0;
const kOnHeaders = HTTPParser.kOnHeaders | 0;
const kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0;
const kOnBody = HTTPParser.kOnBody | 0;
const kOnMessageComplete = HTTPParser.kOnMessageComplete | 0;

// Only called in the slow case where slow means
// that the request headers were either fragmented
Expand Down
4 changes: 2 additions & 2 deletions lib/_http_incoming.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

var util = require('util');
var Stream = require('stream');
const util = require('util');
const Stream = require('stream');

function readStart(socket) {
if (socket && !socket._paused && socket.readable)
Expand Down
40 changes: 19 additions & 21 deletions lib/_http_outgoing.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
'use strict';

var assert = require('assert').ok;
var Stream = require('stream');
var timers = require('timers');
var util = require('util');

var common = require('_http_common');

var CRLF = common.CRLF;
var chunkExpression = common.chunkExpression;
var debug = common.debug;


var connectionExpression = /Connection/i;
var transferEncodingExpression = /Transfer-Encoding/i;
var closeExpression = /close/i;
var contentLengthExpression = /Content-Length/i;
var dateExpression = /Date/i;
var expectExpression = /Expect/i;

var automaticHeaders = {
const assert = require('assert').ok;
const Stream = require('stream');
const timers = require('timers');
const util = require('util');
const common = require('_http_common');

const CRLF = common.CRLF;
const chunkExpression = common.chunkExpression;
const debug = common.debug;

const connectionExpression = /Connection/i;
const transferEncodingExpression = /Transfer-Encoding/i;
const closeExpression = /close/i;
const contentLengthExpression = /Content-Length/i;
const dateExpression = /Date/i;
const expectExpression = /Expect/i;

const automaticHeaders = {
connection: true,
'content-length': true,
'transfer-encoding': true,
Expand Down Expand Up @@ -477,7 +475,7 @@ OutgoingMessage.prototype.addTrailers = function(headers) {
};


var crlf_buf = new Buffer('\r\n');
const crlf_buf = new Buffer('\r\n');


OutgoingMessage.prototype.end = function(data, encoding, callback) {
Expand Down
35 changes: 16 additions & 19 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
'use strict';

var util = require('util');
var net = require('net');
var EventEmitter = require('events').EventEmitter;
var HTTPParser = process.binding('http_parser').HTTPParser;
var assert = require('assert').ok;

var common = require('_http_common');
var parsers = common.parsers;
var freeParser = common.freeParser;
var debug = common.debug;
var CRLF = common.CRLF;
var continueExpression = common.continueExpression;
var chunkExpression = common.chunkExpression;
var httpSocketSetup = common.httpSocketSetup;

var OutgoingMessage = require('_http_outgoing').OutgoingMessage;


var STATUS_CODES = exports.STATUS_CODES = {
const util = require('util');
const net = require('net');
const EventEmitter = require('events').EventEmitter;
const HTTPParser = process.binding('http_parser').HTTPParser;
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 STATUS_CODES = exports.STATUS_CODES = {
100 : 'Continue',
101 : 'Switching Protocols',
102 : 'Processing', // RFC 2518, obsoleted by RFC 4918
Expand Down
7 changes: 4 additions & 3 deletions lib/_stream_duplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
'use strict';

module.exports = Duplex;
var util = require('util');
var Readable = require('_stream_readable');
var Writable = require('_stream_writable');

const util = require('util');
const Readable = require('_stream_readable');
const Writable = require('_stream_writable');

util.inherits(Duplex, Readable);

Expand Down
4 changes: 2 additions & 2 deletions lib/_stream_passthrough.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

module.exports = PassThrough;

var Transform = require('_stream_transform');
var util = require('util');
const Transform = require('_stream_transform');
const util = require('util');
util.inherits(PassThrough, Transform);

function PassThrough(options) {
Expand Down
12 changes: 6 additions & 6 deletions lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
module.exports = Readable;
Readable.ReadableState = ReadableState;

var EE = require('events').EventEmitter;
var Stream = require('stream');
var util = require('util');
const EE = require('events').EventEmitter;
const Stream = require('stream');
const util = require('util');
const debug = util.debuglog('stream');
var StringDecoder;
var debug = util.debuglog('stream');

util.inherits(Readable, Stream);

Expand Down Expand Up @@ -189,7 +189,7 @@ Readable.prototype.setEncoding = function(enc) {
};

// Don't raise the hwm > 128MB
var MAX_HWM = 0x800000;
const MAX_HWM = 0x800000;
function roundUpToNextPowerOf2(n) {
if (n >= MAX_HWM) {
n = MAX_HWM;
Expand Down Expand Up @@ -781,7 +781,7 @@ Readable.prototype.wrap = function(stream) {
}

// proxy certain important events.
var events = ['error', 'close', 'destroy', 'pause', 'resume'];
const events = ['error', 'close', 'destroy', 'pause', 'resume'];
events.forEach(function(ev) {
stream.on(ev, self.emit.bind(self, ev));
});
Expand Down
4 changes: 2 additions & 2 deletions lib/_stream_transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@

module.exports = Transform;

var Duplex = require('_stream_duplex');
var util = require('util');
const Duplex = require('_stream_duplex');
const util = require('util');
util.inherits(Transform, Duplex);


Expand Down
Loading