Skip to content

Commit

Permalink
tls: change loop var to let
Browse files Browse the repository at this point in the history
PR-URL: #30445
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
  • Loading branch information
Xavier-Redondo authored and BridgeAR committed Nov 19, 2019
1 parent 0130d2b commit 5869f2b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion lib/internal/tls.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { Object } = primordials;
function parseCertString(s) {
const out = Object.create(null);
const parts = s.split('\n');
for (var i = 0, len = parts.length; i < len; i++) {
for (let i = 0, len = parts.length; i < len; i++) {
const sepIndex = parts[i].indexOf('=');
if (sepIndex > 0) {
const key = parts[i].slice(0, sepIndex);
Expand Down
70 changes: 35 additions & 35 deletions lib/internal/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class URLSearchParams {
// Need to use reflection APIs for full spec compliance.
this[searchParams] = [];
const keys = Reflect.ownKeys(init);
for (var i = 0; i < keys.length; i++) {
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
const desc = Reflect.getOwnPropertyDescriptor(init, key);
if (desc !== undefined && desc.enumerable) {
Expand Down Expand Up @@ -203,7 +203,7 @@ class URLSearchParams {

const list = this[searchParams];
const output = [];
for (var i = 0; i < list.length; i += 2)
for (let i = 0; i < list.length; i += 2)
output.push(`${innerInspect(list[i])} => ${innerInspect(list[i + 1])}`);

const length = output.reduce(
Expand Down Expand Up @@ -390,7 +390,7 @@ Object.defineProperties(URL.prototype, {
...options
};
const ctx = this[context];
var ret = ctx.scheme;
let ret = ctx.scheme;
if (ctx.host !== null) {
ret += '//';
const has_username = ctx.username !== '';
Expand Down Expand Up @@ -539,7 +539,7 @@ Object.defineProperties(URL.prototype, {
configurable: true,
get() {
const ctx = this[context];
var ret = ctx.host || '';
let ret = ctx.host || '';
if (ctx.port !== null)
ret += `:${ctx.port}`;
return ret;
Expand Down Expand Up @@ -707,13 +707,13 @@ function initSearchParams(url, init) {
// Ref: https://url.spec.whatwg.org/#concept-urlencoded-parser
function parseParams(qs) {
const out = [];
var pairStart = 0;
var lastPos = 0;
var seenSep = false;
var buf = '';
var encoded = false;
var encodeCheck = 0;
var i;
let pairStart = 0;
let lastPos = 0;
let seenSep = false;
let buf = '';
let encoded = false;
let encodeCheck = 0;
let i;
for (i = 0; i < qs.length; ++i) {
const code = qs.charCodeAt(i);

Expand Down Expand Up @@ -834,7 +834,7 @@ function serializeParams(array) {
const firstEncodedValue = encodeStr(array[1], noEscape, paramHexTable);
let output = `${firstEncodedParam}=${firstEncodedValue}`;

for (var i = 2; i < len; i += 2) {
for (let i = 2; i < len; i += 2) {
const encodedParam = encodeStr(array[i], noEscape, paramHexTable);
const encodedValue = encodeStr(array[i + 1], noEscape, paramHexTable);
output += `&${encodedParam}=${encodedValue}`;
Expand Down Expand Up @@ -876,7 +876,7 @@ function defineIDLClass(proto, classStr, obj) {
function merge(out, start, mid, end, lBuffer, rBuffer) {
const sizeLeft = mid - start;
const sizeRight = end - mid;
var l, r, o;
let l, r, o;

for (l = 0; l < sizeLeft; l++)
lBuffer[l] = out[start + l];
Expand Down Expand Up @@ -926,7 +926,7 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams', {

const list = this[searchParams];
name = toUSVString(name);
for (var i = 0; i < list.length;) {
for (let i = 0; i < list.length;) {
const cur = list[i];
if (cur === name) {
list.splice(i, 2);
Expand All @@ -947,7 +947,7 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams', {

const list = this[searchParams];
name = toUSVString(name);
for (var i = 0; i < list.length; i += 2) {
for (let i = 0; i < list.length; i += 2) {
if (list[i] === name) {
return list[i + 1];
}
Expand All @@ -966,7 +966,7 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams', {
const list = this[searchParams];
const values = [];
name = toUSVString(name);
for (var i = 0; i < list.length; i += 2) {
for (let i = 0; i < list.length; i += 2) {
if (list[i] === name) {
values.push(list[i + 1]);
}
Expand All @@ -984,7 +984,7 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams', {

const list = this[searchParams];
name = toUSVString(name);
for (var i = 0; i < list.length; i += 2) {
for (let i = 0; i < list.length; i += 2) {
if (list[i] === name) {
return true;
}
Expand All @@ -1007,8 +1007,8 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams', {
// If there are any name-value pairs whose name is `name`, in `list`, set
// the value of the first such name-value pair to `value` and remove the
// others.
var found = false;
for (var i = 0; i < list.length;) {
let found = false;
for (let i = 0; i < list.length;) {
const cur = list[i];
if (cur === name) {
if (!found) {
Expand Down Expand Up @@ -1042,10 +1042,10 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams', {
// 100 is found through testing.
// Simple stable in-place insertion sort
// Derived from v8/src/js/array.js
for (var i = 2; i < len; i += 2) {
var curKey = a[i];
var curVal = a[i + 1];
var j;
for (let i = 2; i < len; i += 2) {
const curKey = a[i];
const curVal = a[i + 1];
let j;
for (j = i - 2; j >= 0; j -= 2) {
if (a[j] > curKey) {
a[j + 2] = a[j];
Expand All @@ -1061,10 +1061,10 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams', {
// Bottom-up iterative stable merge sort
const lBuffer = new Array(len);
const rBuffer = new Array(len);
for (var step = 2; step < len; step *= 2) {
for (var start = 0; start < len - 2; start += 2 * step) {
var mid = start + step;
var end = mid + step;
for (let step = 2; step < len; step *= 2) {
for (let start = 0; start < len - 2; start += 2 * step) {
const mid = start + step;
let end = mid + step;
end = end < len ? end : len;
if (mid > end)
continue;
Expand Down Expand Up @@ -1097,7 +1097,7 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams', {

let list = this[searchParams];

var i = 0;
let i = 0;
while (i < list.length) {
const key = list[i];
const value = list[i + 1];
Expand Down Expand Up @@ -1279,10 +1279,10 @@ const forwardSlashRegEx = /\//g;

function getPathFromURLWin32(url) {
const hostname = url.hostname;
var pathname = url.pathname;
for (var n = 0; n < pathname.length; n++) {
let pathname = url.pathname;
for (let n = 0; n < pathname.length; n++) {
if (pathname[n] === '%') {
var third = pathname.codePointAt(n + 2) | 0x20;
const third = pathname.codePointAt(n + 2) | 0x20;
if ((pathname[n + 1] === '2' && third === 102) || // 2f 2F /
(pathname[n + 1] === '5' && third === 99)) { // 5c 5C \
throw new ERR_INVALID_FILE_URL_PATH(
Expand All @@ -1303,8 +1303,8 @@ function getPathFromURLWin32(url) {
return `\\\\${domainToUnicode(hostname)}${pathname}`;
} else {
// Otherwise, it's a local path that requires a drive letter
var letter = pathname.codePointAt(1) | 0x20;
var sep = pathname[2];
const letter = pathname.codePointAt(1) | 0x20;
const sep = pathname[2];
if (letter < CHAR_LOWERCASE_A || letter > CHAR_LOWERCASE_Z || // a..z A..Z
(sep !== ':')) {
throw new ERR_INVALID_FILE_URL_PATH('must be absolute');
Expand All @@ -1318,9 +1318,9 @@ function getPathFromURLPosix(url) {
throw new ERR_INVALID_FILE_URL_HOST(platform);
}
const pathname = url.pathname;
for (var n = 0; n < pathname.length; n++) {
for (let n = 0; n < pathname.length; n++) {
if (pathname[n] === '%') {
var third = pathname.codePointAt(n + 2) | 0x20;
const third = pathname.codePointAt(n + 2) | 0x20;
if (pathname[n + 1] === '2' && third === 102) {
throw new ERR_INVALID_FILE_URL_PATH(
'must not include encoded / characters'
Expand Down

0 comments on commit 5869f2b

Please sign in to comment.