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 e31baca

Browse filesBrowse files
LiviaMedeirosdanielleadams
authored andcommitted
tls: use kEmptyObject
PR-URL: #43159 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent fecad7a commit e31baca
Copy full SHA for e31baca

File tree

Expand file treeCollapse file tree

4 files changed

+16
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+16
-6
lines changed
Open diff view settings
Collapse file

‎lib/_tls_common.js‎

Copy file name to clipboardExpand all lines: lib/_tls_common.js
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ const {
4747
},
4848
} = internalBinding('constants');
4949

50+
const {
51+
kEmptyObject,
52+
} = require('internal/util');
53+
5054
const {
5155
validateInteger,
5256
} = require('internal/validators');
@@ -93,7 +97,7 @@ function SecureContext(secureProtocol, secureOptions, minVersion, maxVersion) {
9397
}
9498

9599
function createSecureContext(options) {
96-
if (!options) options = {};
100+
if (!options) options = kEmptyObject;
97101

98102
const {
99103
honorCipherOrder,
Collapse file

‎lib/_tls_wrap.js‎

Copy file name to clipboardExpand all lines: lib/_tls_wrap.js
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ const {
4040

4141
const {
4242
assertCrypto,
43-
deprecate
43+
deprecate,
44+
kEmptyObject,
4445
} = require('internal/util');
4546

4647
assertCrypto();
@@ -1182,9 +1183,9 @@ function Server(options, listener) {
11821183

11831184
if (typeof options === 'function') {
11841185
listener = options;
1185-
options = {};
1186+
options = kEmptyObject;
11861187
} else if (options == null || typeof options === 'object') {
1187-
options = options || {};
1188+
options = options ?? kEmptyObject;
11881189
} else {
11891190
throw new ERR_INVALID_ARG_TYPE('options', 'Object', options);
11901191
}
Collapse file

‎lib/internal/tls/secure-context.js‎

Copy file name to clipboardExpand all lines: lib/internal/tls/secure-context.js
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ const {
1717
},
1818
} = require('internal/errors');
1919

20+
const {
21+
kEmptyObject,
22+
} = require('internal/util');
23+
2024
const {
2125
isArrayBufferView,
2226
} = require('internal/util/types');
@@ -117,7 +121,7 @@ function processCiphers(ciphers, name) {
117121
return { cipherList, cipherSuites };
118122
}
119123

120-
function configSecureContext(context, options = {}, name = 'options') {
124+
function configSecureContext(context, options = kEmptyObject, name = 'options') {
121125
validateObject(options, name);
122126

123127
const {
Collapse file

‎lib/internal/tls/secure-pair.js‎

Copy file name to clipboardExpand all lines: lib/internal/tls/secure-pair.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const EventEmitter = require('events');
4+
const { kEmptyObject } = require('internal/util');
45
const { Duplex } = require('stream');
56
const _tls_wrap = require('_tls_wrap');
67
const _tls_common = require('_tls_common');
@@ -57,7 +58,7 @@ class SecurePair extends EventEmitter {
5758
isServer = false,
5859
requestCert = !isServer,
5960
rejectUnauthorized = false,
60-
options = {}) {
61+
options = kEmptyObject) {
6162
super();
6263
const { socket1, socket2 } = new DuplexPair();
6364

0 commit comments

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