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 df0903c

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

File tree

Expand file treeCollapse file tree

3 files changed

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

3 files changed

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

‎lib/internal/crypto/keygen.js‎

Copy file name to clipboardExpand all lines: lib/internal/crypto/keygen.js
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ const {
3838
kAesKeyLengths,
3939
} = require('internal/crypto/util');
4040

41-
const { customPromisifyArgs } = require('internal/util');
41+
const {
42+
customPromisifyArgs,
43+
kEmptyObject,
44+
} = require('internal/util');
4245

4346
const {
4447
validateFunction,
@@ -119,7 +122,7 @@ function handleError(ret) {
119122
};
120123
}
121124

122-
function parseKeyEncoding(keyType, options = {}) {
125+
function parseKeyEncoding(keyType, options = kEmptyObject) {
123126
const { publicKeyEncoding, privateKeyEncoding } = options;
124127

125128
let publicFormat, publicType;
Collapse file

‎lib/internal/crypto/random.js‎

Copy file name to clipboardExpand all lines: lib/internal/crypto/random.js
+7-6Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const {
2626
} = internalBinding('crypto');
2727

2828
const {
29+
kEmptyObject,
2930
lazyDOMException,
3031
} = require('internal/util');
3132

@@ -399,7 +400,7 @@ function randomUUID(options) {
399400
validateObject(options, 'options');
400401
const {
401402
disableEntropyCache = false,
402-
} = options || {};
403+
} = options || kEmptyObject;
403404

404405
validateBoolean(disableEntropyCache, 'options.disableEntropyCache');
405406

@@ -464,7 +465,7 @@ function generatePrime(size, options, callback) {
464465
validateInt32(size, 'size', 1);
465466
if (typeof options === 'function') {
466467
callback = options;
467-
options = {};
468+
options = kEmptyObject;
468469
}
469470
validateFunction(callback, 'callback');
470471

@@ -482,7 +483,7 @@ function generatePrime(size, options, callback) {
482483
job.run();
483484
}
484485

485-
function generatePrimeSync(size, options = {}) {
486+
function generatePrimeSync(size, options = kEmptyObject) {
486487
validateInt32(size, 'size', 1);
487488

488489
const job = createRandomPrimeJob(kCryptoJobSync, size, options);
@@ -506,7 +507,7 @@ function unsignedBigIntToBuffer(bigint, name) {
506507
return Buffer.from(padded, 'hex');
507508
}
508509

509-
function checkPrime(candidate, options = {}, callback) {
510+
function checkPrime(candidate, options = kEmptyObject, callback) {
510511
if (typeof candidate === 'bigint')
511512
candidate = unsignedBigIntToBuffer(candidate, 'candidate');
512513
if (!isAnyArrayBuffer(candidate) && !isArrayBufferView(candidate)) {
@@ -524,7 +525,7 @@ function checkPrime(candidate, options = {}, callback) {
524525
}
525526
if (typeof options === 'function') {
526527
callback = options;
527-
options = {};
528+
options = kEmptyObject;
528529
}
529530
validateFunction(callback, 'callback');
530531
validateObject(options, 'options');
@@ -539,7 +540,7 @@ function checkPrime(candidate, options = {}, callback) {
539540
job.run();
540541
}
541542

542-
function checkPrimeSync(candidate, options = {}) {
543+
function checkPrimeSync(candidate, options = kEmptyObject) {
543544
if (typeof candidate === 'bigint')
544545
candidate = unsignedBigIntToBuffer(candidate, 'candidate');
545546
if (!isAnyArrayBuffer(candidate) && !isArrayBufferView(candidate)) {
Collapse file

‎lib/internal/crypto/x509.js‎

Copy file name to clipboardExpand all lines: lib/internal/crypto/x509.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const {
2323

2424
const {
2525
customInspectSymbol: kInspect,
26+
kEmptyObject,
2627
} = require('internal/util');
2728

2829
const {
@@ -64,7 +65,7 @@ function isX509Certificate(value) {
6465
return value[kInternalState] !== undefined;
6566
}
6667

67-
function getFlags(options = {}) {
68+
function getFlags(options = kEmptyObject) {
6869
validateObject(options, 'options');
6970
const {
7071
subject = 'default', // Can be 'default', 'always', or 'never'

0 commit comments

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