stdin = stdin || process.stdin;
stdout = stdout || process.stdout;
- var args = ['--debug-brk'].concat(argv),
- interface_ = new Interface(stdin, stdout, args);
+ const args = ['--debug-brk'].concat(argv);
+ const interface_ = new Interface(stdin, stdout, args);
stdin.resume();
Client.prototype._onResponse = function(res) {
- var cb,
- index = -1;
+ var cb;
+ var index = -1;
this._reqCallbacks.some(function(fn, i) {
if (fn.request_seq == res.body.request_seq) {
};
Client.prototype.reqScopes = function(cb) {
- var self = this,
- req = {
- command: 'scopes',
- arguments: {}
- };
+ const self = this;
+ const req = {
+ command: 'scopes',
+ arguments: {}
+ };
cb = cb || function() {};
this.req(req, function(err, res) {
return;
}
- var mirror,
- waiting = 1;
+ var mirror;
+ var waiting = 1;
if (handle.className == 'Array') {
mirror = [];
function SourceUnderline(sourceText, position, repl) {
if (!sourceText) return '';
- var head = sourceText.slice(0, position),
- tail = sourceText.slice(position);
+ const head = sourceText.slice(0, position);
+ var tail = sourceText.slice(position);
// Colourize char if stdout supports colours
if (repl.useColors) {
if (body.script) {
if (body.script.name) {
- var name = body.script.name,
- dir = path.resolve() + '/';
+ var name = body.script.name;
+ const dir = path.resolve() + '/';
// Change path to relative, if possible
if (name.indexOf(dir) === 0) {
Interface.prototype.debugEval = function(code, context, filename, callback) {
if (!this.requireConnection()) return;
- var self = this,
- client = this.client;
+ const self = this;
+ const client = this.client;
// Repl asked for scope variables
if (code === '.scope') {
// Adds spaces and prefix to number
// maxN is a maximum number we should have space for
function leftPad(n, prefix, maxN) {
- var s = n.toString(),
- nchars = Math.max(2, String(maxN).length) + 1,
- nspaces = nchars - s.length - 1;
+ const s = n.toString();
+ const nchars = Math.max(2, String(maxN).length) + 1;
+ const nspaces = nchars - s.length - 1;
for (var i = 0; i < nspaces; i++) {
prefix += ' ';
delta || (delta = 5);
- var self = this,
- client = this.client,
- from = client.currentSourceLine - delta + 1,
- to = client.currentSourceLine + delta + 1;
+ const self = this;
+ const client = this.client;
+ const from = client.currentSourceLine - delta + 1;
+ const to = client.currentSourceLine + delta + 1;
self.pause();
client.reqSource(from, to, function(err, res) {
var lineno = res.fromLine + i + 1;
if (lineno < from || lineno > to) continue;
- var current = lineno == 1 + client.currentSourceLine,
- breakpoint = client.breakpoints.some(function(bp) {
- return (bp.scriptReq === client.currentScript ||
- bp.script === client.currentScript) &&
- bp.line == lineno;
- });
+ const current = lineno == 1 + client.currentSourceLine;
+ const breakpoint = client.breakpoints.some(function(bp) {
+ return (bp.scriptReq === client.currentScript ||
+ bp.script === client.currentScript) &&
+ bp.line == lineno;
+ });
if (lineno == 1) {
// The first line needs to have the module wrapper filtered out of
Interface.prototype.backtrace = function() {
if (!this.requireConnection()) return;
- var self = this,
- client = this.client;
+ const self = this;
+ const client = this.client;
self.pause();
client.fullTrace(function(err, bt) {
if (bt.totalFrames == 0) {
self.print('(empty stack)');
} else {
- var trace = [],
- firstFrameNative = bt.frames[0].script.isNative;
+ const trace = [];
+ const firstFrameNative = bt.frames[0].script.isNative;
for (var i = 0; i < bt.frames.length; i++) {
var frame = bt.frames[i];
Interface.prototype.scripts = function() {
if (!this.requireConnection()) return;
- var client = this.client,
- displayNatives = arguments[0] || false,
- scripts = [];
+ const client = this.client;
+ const displayNatives = arguments[0] || false;
+ const scripts = [];
this.pause();
for (var id in client.scripts) {
condition, silent) {
if (!this.requireConnection()) return;
- var self = this,
- scriptId,
- ambiguous;
+ const self = this;
+ var scriptId;
+ var ambiguous;
// setBreakpoint() should insert breakpoint on current line
if (script === undefined) {
Interface.prototype.clearBreakpoint = function(script, line) {
if (!this.requireConnection()) return;
- var ambiguous,
- breakpoint,
- scriptId,
- index;
+ var ambiguous;
+ var breakpoint;
+ var scriptId;
+ var index;
this.client.breakpoints.some(function(bp, i) {
if (bp.scriptId === script ||
return this.error('Breakpoint not found on line ' + line);
}
- var self = this,
- req = {
- breakpoint: breakpoint
- };
+ var self = this;
+ const req = {breakpoint};
self.pause();
self.client.clearBreakpoint(req, function(err, res) {
Interface.prototype.pause_ = function() {
if (!this.requireConnection()) return;
- var self = this,
- cmd = 'process._debugPause();';
+ const self = this;
+ const cmd = 'process._debugPause();';
this.pause();
this.client.reqFrameEval(cmd, NO_FRAME, function(err, res) {
// Spawns child process (and restores breakpoints)
Interface.prototype.trySpawn = function(cb) {
- var self = this,
- breakpoints = this.breakpoints || [],
- port = exports.port,
- host = '127.0.0.1',
- childArgs = this.args;
+ const self = this;
+ const breakpoints = this.breakpoints || [];
+ var port = exports.port;
+ var host = '127.0.0.1';
+ var childArgs = this.args;
this.killChild();
assert(!this.child);
this.pause();
- var client = self.client = new Client(),
- connectionAttempts = 0;
+ const client = self.client = new Client();
+ var connectionAttempts = 0;
client.once('ready', function() {
self.stdout.write(' ok\n');
426 : 'Upgrade Required', // RFC 2817
428 : 'Precondition Required', // RFC 6585
429 : 'Too Many Requests', // RFC 6585
- 431 : 'Request Header Fields Too Large',// RFC 6585
+ 431 : 'Request Header Fields Too Large', // RFC 6585
500 : 'Internal Server Error',
501 : 'Not Implemented',
502 : 'Bad Gateway',
CryptoStream.prototype._writePending = function writePending() {
- var data = this._pending,
- encoding = this._pendingEncoding,
- cb = this._pendingCallback;
+ const data = this._pending;
+ const encoding = this._pendingEncoding;
+ const cb = this._pendingCallback;
this._pending = null;
this._pendingEncoding = '';
out = this.pair.ssl.encOut;
}
- var bytesRead = 0,
- start = this._buffer.offset,
- last = start;
+ var bytesRead = 0;
+ const start = this._buffer.offset;
+ var last = start;
do {
assert(last === this._buffer.offset);
var read = this._buffer.use(this.pair.ssl, out, size - bytesRead);
function onclienthello(hello) {
- var self = this,
- once = false;
+ const self = this;
+ var once = false;
this._resumingSession = true;
function callback(err, session) {
// For clients, we will always have either a given ca list or be using
// default one
- var requestCert = !!options.requestCert || !options.isServer,
- rejectUnauthorized = !!options.rejectUnauthorized;
+ const requestCert = !!options.requestCert || !options.isServer;
+ const rejectUnauthorized = !!options.rejectUnauthorized;
this._requestCert = requestCert;
this._rejectUnauthorized = rejectUnauthorized;
};
TLSSocket.prototype.renegotiate = function(options, callback) {
- var requestCert = this._requestCert,
- rejectUnauthorized = this._rejectUnauthorized;
+ var requestCert = this._requestCert;
+ var rejectUnauthorized = this._rejectUnauthorized;
if (this.destroyed)
return;
var hostname = options.servername ||
options.host ||
(options.socket && options.socket._host) ||
- 'localhost',
- NPN = {},
- context = tls.createSecureContext(options);
+ 'localhost';
+ const NPN = {};
+ const context = tls.createSecureContext(options);
tls.convertNPNProtocols(options.NPNProtocols, NPN);
var socket = new TLSSocket(options.socket, {
return a === b;
if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
return false;
- var aIsArgs = isArguments(a),
- bIsArgs = isArguments(b);
+ const aIsArgs = isArguments(a);
+ const bIsArgs = isArguments(b);
if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
return false;
if (aIsArgs) {
b = pSlice.call(b);
return _deepEqual(a, b, strict);
}
- var ka = Object.keys(a),
- kb = Object.keys(b),
- key, i;
+ const ka = Object.keys(a);
+ const kb = Object.keys(b);
+ var key, i;
// having the same number of owned properties (keys incorporates
// hasOwnProperty)
if (ka.length !== kb.length)
fs.read = function(fd, buffer, offset, length, position, callback) {
if (!(buffer instanceof Buffer)) {
// legacy string interface (fd, length, position, encoding, callback)
- var cb = arguments[4],
- encoding = arguments[3];
+ const cb = arguments[4];
+ const encoding = arguments[3];
assertEncoding(encoding);
return cache[p];
}
- var original = p,
- seenLinks = {},
- knownHard = {};
+ const original = p;
+ const seenLinks = {};
+ const knownHard = {};
// current character position in p
var pos;
return process.nextTick(cb.bind(null, null, cache[p]));
}
- var original = p,
- seenLinks = {},
- knownHard = {};
+ const original = p;
+ const seenLinks = {};
+ const knownHard = {};
// current character position in p
var pos;
// Export
Object.defineProperty(fs, 'SyncWriteStream', {
- configurable: true,
- writable: true,
- value: SyncWriteStream
+ configurable: true,
+ writable: true,
+ value: SyncWriteStream
});
SyncWriteStream.prototype.write = function(data, arg1, arg2) {
ChildProcess.prototype.spawn = function(options) {
- var self = this,
- ipc,
- ipcFd,
- // If no `stdio` option was given - use default
- stdio = options.stdio || 'pipe';
+ const self = this;
+ var ipc;
+ var ipcFd;
+ // If no `stdio` option was given - use default
+ var stdio = options.stdio || 'pipe';
stdio = _validateStdio(stdio, false);
function nop() { }
function _validateStdio(stdio, sync) {
- var ipc,
- ipcFd;
+ var ipc;
+ var ipcFd;
// Replace shortcut with an array
if (typeof stdio === 'string') {
Socket.prototype.__defineGetter__('bytesWritten', function() {
- var bytes = this._bytesDispatched,
- state = this._writableState,
- data = this._pendingData,
- encoding = this._pendingEncoding;
+ var bytes = this._bytesDispatched;
+ const state = this._writableState;
+ const data = this._pendingData;
+ const encoding = this._pendingEncoding;
if (!state)
return undefined;
return handle.listen(backlog || 511);
}
-var createServerHandle = exports._createServerHandle =
- function(address, port, addressType, fd) {
+function createServerHandle(address, port, addressType, fd) {
var err = 0;
// assign handle in listen, and clean up if bind or listen fails
var handle;
return handle;
};
+exports._createServerHandle = createServerHandle;
Server.prototype._listen2 = function(address, port, addressType, backlog, fd) {
}
// Poll slaves
- var left = this._slaves.length,
- total = this._connections;
+ var left = this._slaves.length;
+ var total = this._connections;
function oncount(err, count) {
if (err) {
}
if (this._usingSlaves) {
- var self = this,
- left = this._slaves.length;
+ var self = this;
+ var left = this._slaves.length;
// Increment connections to be sure that, even if all sockets will be closed
// during polling of slaves, `close` event will be emitted only once.
// Function to split a filename into [root, dir, basename, ext]
function win32SplitPath(filename) {
// Separate device+slash from tail
- var result = splitDeviceRe.exec(filename),
- device = (result[1] || '') + (result[2] || ''),
- tail = result[3];
+ const result = splitDeviceRe.exec(filename);
+ const device = (result[1] || '') + (result[2] || '');
+ const tail = result[3];
// Split the tail into dir, basename and extension
- var result2 = splitTailRe.exec(tail),
- dir = result2[1],
- basename = result2[2],
- ext = result2[3];
+ const result2 = splitTailRe.exec(tail);
+ const dir = result2[1];
+ const basename = result2[2];
+ const ext = result2[3];
return [device, dir, basename, ext];
}
function win32StatPath(path) {
- var result = splitDeviceRe.exec(path),
- device = result[1] || '',
- isUnc = !!device && device[1] !== ':';
+ const result = splitDeviceRe.exec(path);
+ const device = result[1] || '';
+ const isUnc = !!device && device[1] !== ':';
return {
device,
isUnc,
// path.resolve([from ...], to)
win32.resolve = function() {
- var resolvedDevice = '',
- resolvedTail = '',
- resolvedAbsolute = false;
+ var resolvedDevice = '';
+ var resolvedTail = '';
+ var resolvedAbsolute = false;
for (var i = arguments.length - 1; i >= -1; i--) {
var path;
continue;
}
- var result = win32StatPath(path),
- device = result.device,
- isUnc = result.isUnc,
- isAbsolute = result.isAbsolute,
- tail = result.tail;
+ const result = win32StatPath(path);
+ const device = result.device;
+ var isUnc = result.isUnc;
+ const isAbsolute = result.isAbsolute;
+ const tail = result.tail;
if (device &&
resolvedDevice &&
win32.normalize = function(path) {
assertPath(path);
- var result = win32StatPath(path),
- device = result.device,
- isUnc = result.isUnc,
- isAbsolute = result.isAbsolute,
- tail = result.tail,
- trailingSlash = /[\\\/]$/.test(tail);
+ const result = win32StatPath(path);
+ var device = result.device;
+ const isUnc = result.isUnc;
+ const isAbsolute = result.isAbsolute;
+ var tail = result.tail;
+ const trailingSlash = /[\\\/]$/.test(tail);
// Normalize the tail path
tail = normalizeArray(tail.split(/[\\\/]+/), !isAbsolute).join('\\');
win32.dirname = function(path) {
- var result = win32SplitPath(path),
- root = result[0],
- dir = result[1];
+ const result = win32SplitPath(path);
+ const root = result[0];
+ var dir = result[1];
if (!root && !dir) {
// No dirname whatsoever
// path.resolve([from ...], to)
// posix version
posix.resolve = function() {
- var resolvedPath = '',
- resolvedAbsolute = false;
+ var resolvedPath = '';
+ var resolvedAbsolute = false;
for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
var path = (i >= 0) ? arguments[i] : process.cwd();
posix.normalize = function(path) {
assertPath(path);
- var isAbsolute = posix.isAbsolute(path),
- trailingSlash = path && path[path.length - 1] === '/';
+ const isAbsolute = posix.isAbsolute(path);
+ const trailingSlash = path && path[path.length - 1] === '/';
// Normalize the path
path = normalizeArray(path.split('/'), !isAbsolute).join('/');
posix.dirname = function(path) {
- var result = posixSplitPath(path),
- root = result[0],
- dir = result[1];
+ const result = posixSplitPath(path);
+ const root = result[0];
+ var dir = result[1];
if (!root && !dir) {
// No dirname whatsoever
var keys = [];
for (var i = 0; i < len; ++i) {
- var x = qs[i].replace(regexp, '%20'),
- idx = x.indexOf(eq),
- k, v;
+ const x = qs[i].replace(regexp, '%20');
+ const idx = x.indexOf(eq);
+ var k, v;
if (idx >= 0) {
k = decodeStr(x.substring(0, idx), decode);
return;
}
- var completions = rv[0],
- completeOn = rv[1]; // the text that was completed
+ const completions = rv[0];
+ const completeOn = rv[1]; // the text that was completed
if (completions && completions.length) {
// Apply/show completions.
if (completions.length === 1) {
return new RegExp('^' + re + '$', 'i');
}
- var dnsNames = [],
- uriNames = [],
- ips = [],
- matchCN = true,
- valid = false,
- reason = 'Unknown reason';
+ var dnsNames = [];
+ var uriNames = [];
+ const ips = [];
+ var matchCN = true;
+ var valid = false;
+ var reason = 'Unknown reason';
// There're several names to perform check against:
// CN and altnames in certificate extension
// Copy chrome, IE, opera backslash-handling behavior.
// Back slashes before the query string get converted to forward slashes
// See: https://code.google.com/p/chromium/issues/detail?id=25916
- var queryIndex = url.indexOf('?'),
- splitter =
- (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#',
- uSplit = url.split(splitter),
- slashRegex = /\\/g;
+ const queryIndex = url.indexOf('?');
+ const splitter =
+ (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#';
+ const uSplit = url.split(splitter);
+ const slashRegex = /\\/g;
uSplit[0] = uSplit[0].replace(slashRegex, '/');
url = uSplit.join(splitter);
auth += '@';
}
- var protocol = this.protocol || '',
- pathname = this.pathname || '',
- hash = this.hash || '',
- host = false,
- query = '';
+ var protocol = this.protocol || '';
+ var pathname = this.pathname || '';
+ var hash = this.hash || '';
+ var host = false;
+ var query = '';
if (this.host) {
host = auth + this.host;
return result;
}
- var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
- isRelAbs = (
- relative.host ||
- relative.pathname && relative.pathname.charAt(0) === '/'
- ),
- mustEndAbs = (isRelAbs || isSourceAbs ||
- (result.host && relative.pathname)),
- removeAllDots = mustEndAbs,
- srcPath = result.pathname && result.pathname.split('/') || [],
- relPath = relative.pathname && relative.pathname.split('/') || [],
- psychotic = result.protocol && !slashedProtocol[result.protocol];
+ const isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/');
+ const isRelAbs = (
+ relative.host ||
+ relative.pathname && relative.pathname.charAt(0) === '/'
+ );
+ var mustEndAbs = (isRelAbs || isSourceAbs ||
+ (result.host && relative.pathname));
+ const removeAllDots = mustEndAbs;
+ var srcPath = result.pathname && result.pathname.split('/') || [];
+ var relPath = relative.pathname && relative.pathname.split('/') || [];
+ const psychotic = result.protocol && !slashedProtocol[result.protocol];
// if the url is a non-slashed url, then relative
// links like ../.. should be able