Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ff9b5fc

Browse filesBrowse files
trivikrtargos
authored andcommitted
tls: for...of in _tls_common.js
PR-URL: #30961 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent c6be79a commit ff9b5fc
Copy full SHA for ff9b5fc

File tree

Expand file treeCollapse file tree

3 files changed

+14
-22
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+14
-22
lines changed
Open diff view settings
Collapse file

‎lib/_tls_common.js‎

Copy file name to clipboardExpand all lines: lib/_tls_common.js
+6-12Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,12 @@ exports.createSecureContext = function createSecureContext(options) {
100100

101101
const c = new SecureContext(options.secureProtocol, secureOptions,
102102
options.minVersion, options.maxVersion);
103-
let i;
104-
let val;
105103

106104
// Add CA before the cert to be able to load cert's issuer in C++ code.
107105
const { ca } = options;
108106
if (ca) {
109107
if (ArrayIsArray(ca)) {
110-
for (i = 0; i < ca.length; ++i) {
111-
val = ca[i];
108+
for (const val of ca) {
112109
validateKeyOrCertOption('ca', val);
113110
c.context.addCACert(val);
114111
}
@@ -123,8 +120,7 @@ exports.createSecureContext = function createSecureContext(options) {
123120
const { cert } = options;
124121
if (cert) {
125122
if (ArrayIsArray(cert)) {
126-
for (i = 0; i < cert.length; ++i) {
127-
val = cert[i];
123+
for (const val of cert) {
128124
validateKeyOrCertOption('cert', val);
129125
c.context.setCert(val);
130126
}
@@ -142,8 +138,7 @@ exports.createSecureContext = function createSecureContext(options) {
142138
const passphrase = options.passphrase;
143139
if (key) {
144140
if (ArrayIsArray(key)) {
145-
for (i = 0; i < key.length; ++i) {
146-
val = key[i];
141+
for (const val of key) {
147142
// eslint-disable-next-line eqeqeq
148143
const pem = (val != undefined && val.pem !== undefined ? val.pem : val);
149144
validateKeyOrCertOption('key', pem);
@@ -242,8 +237,8 @@ exports.createSecureContext = function createSecureContext(options) {
242237

243238
if (options.crl) {
244239
if (ArrayIsArray(options.crl)) {
245-
for (i = 0; i < options.crl.length; i++) {
246-
c.context.addCRL(options.crl[i]);
240+
for (const crl of options.crl) {
241+
c.context.addCRL(crl);
247242
}
248243
} else {
249244
c.context.addCRL(options.crl);
@@ -259,8 +254,7 @@ exports.createSecureContext = function createSecureContext(options) {
259254
toBuf = require('internal/crypto/util').toBuf;
260255

261256
if (ArrayIsArray(options.pfx)) {
262-
for (i = 0; i < options.pfx.length; i++) {
263-
const pfx = options.pfx[i];
257+
for (const pfx of options.pfx) {
264258
const raw = pfx.buf ? pfx.buf : pfx;
265259
const buf = toBuf(raw);
266260
const passphrase = pfx.passphrase || options.passphrase;
Collapse file

‎lib/_tls_wrap.js‎

Copy file name to clipboardExpand all lines: lib/_tls_wrap.js
+4-5Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,9 @@ function makeMethodProxy(name) {
530530
return this._parent[name].apply(this._parent, args);
531531
};
532532
}
533-
for (let n = 0; n < proxiedMethods.length; n++) {
534-
tls_wrap.TLSWrap.prototype[proxiedMethods[n]] =
535-
makeMethodProxy(proxiedMethods[n]);
533+
for (const proxiedMethod of proxiedMethods) {
534+
tls_wrap.TLSWrap.prototype[proxiedMethod] =
535+
makeMethodProxy(proxiedMethod);
536536
}
537537

538538
tls_wrap.TLSWrap.prototype.close = function close(cb) {
@@ -1412,8 +1412,7 @@ Server.prototype[EE.captureRejectionSymbol] = function(
14121412
function SNICallback(servername, callback) {
14131413
const contexts = this.server._contexts;
14141414

1415-
for (let i = 0; i < contexts.length; i++) {
1416-
const elem = contexts[i];
1415+
for (const elem of contexts) {
14171416
if (elem[0].test(servername)) {
14181417
callback(null, elem[1]);
14191418
return;
Collapse file

‎lib/internal/tls.js‎

Copy file name to clipboardExpand all lines: lib/internal/tls.js
+4-5Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ const {
99
// C=US\nST=CA\nL=SF\nO=Joyent\nOU=Node.js\nCN=ca1\nemailAddress=ry@clouds.org
1010
function parseCertString(s) {
1111
const out = ObjectCreate(null);
12-
const parts = s.split('\n');
13-
for (let i = 0, len = parts.length; i < len; i++) {
14-
const sepIndex = parts[i].indexOf('=');
12+
for (const part of s.split('\n')) {
13+
const sepIndex = part.indexOf('=');
1514
if (sepIndex > 0) {
16-
const key = parts[i].slice(0, sepIndex);
17-
const value = parts[i].slice(sepIndex + 1);
15+
const key = part.slice(0, sepIndex);
16+
const value = part.slice(sepIndex + 1);
1817
if (key in out) {
1918
if (!ArrayIsArray(out[key])) {
2019
out[key] = [out[key]];

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.