From faceae486bdfb025225b581ac07259e5d30a16b5 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 20 Jan 2022 06:05:32 -0800 Subject: [PATCH] crypto: revise variables for const use instead of let MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This prepares the code for enabling the no-cond-assign rule. PR-URL: https://github.com/nodejs/node/pull/41614 Reviewed-By: Tobias Nießen Reviewed-By: Anna Henningsen --- lib/internal/crypto/scrypt.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/internal/crypto/scrypt.js b/lib/internal/crypto/scrypt.js index 63a5547e4cbf79..49e5b0624e1ae7 100644 --- a/lib/internal/crypto/scrypt.js +++ b/lib/internal/crypto/scrypt.js @@ -98,8 +98,8 @@ function check(password, salt, keylen, options) { let { N, r, p, maxmem } = defaults; if (options && options !== defaults) { - let has_N, has_r, has_p; - if (has_N = (options.N !== undefined)) { + const has_N = options.N !== undefined; + if (has_N) { N = options.N; validateUint32(N, 'N'); } @@ -108,7 +108,8 @@ function check(password, salt, keylen, options) { N = options.cost; validateUint32(N, 'cost'); } - if (has_r = (options.r !== undefined)) { + const has_r = (options.r !== undefined); + if (has_r) { r = options.r; validateUint32(r, 'r'); } @@ -117,7 +118,8 @@ function check(password, salt, keylen, options) { r = options.blockSize; validateUint32(r, 'blockSize'); } - if (has_p = (options.p !== undefined)) { + const has_p = options.p !== undefined; + if (has_p) { p = options.p; validateUint32(p, 'p'); }