Skip to content

Commit e31baca

Browse files
LiviaMedeirosdanielleadams
authored andcommitted
tls: use kEmptyObject
PR-URL: #43159 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent fecad7a commit e31baca

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

lib/_tls_common.js

+5-1
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,

lib/_tls_wrap.js

+4-3
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
}

lib/internal/tls/secure-context.js

+5-1
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 {

lib/internal/tls/secure-pair.js

+2-1
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)