Skip to content

Commit def96ae

Browse files
danbevtargos
authored andcommitted
crypto: move _scrypt call out of handleError funct
This commit moves the _scrypt function call out of the handleError function, which now only takes in an error object as its parameter. The motivation for this is to hopefully improve readability as it was not clear to me the first time I stepped through the code where the actual call to _scrypt was. PR-URL: #28318 Reviewed-By: Yongsheng Zhang <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent ed8cee6 commit def96ae

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lib/internal/crypto/scrypt.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,21 @@ function scrypt(password, salt, keylen, options, callback = defaults) {
4444
callback.call(wrap, null, keybuf.toString(encoding));
4545
};
4646

47-
handleError(keybuf, password, salt, N, r, p, maxmem, wrap);
47+
handleError(_scrypt(keybuf, password, salt, N, r, p, maxmem, wrap));
4848
}
4949

5050
function scryptSync(password, salt, keylen, options = defaults) {
5151
options = check(password, salt, keylen, options);
5252
const { N, r, p, maxmem } = options;
5353
({ password, salt, keylen } = options);
5454
const keybuf = Buffer.alloc(keylen);
55-
handleError(keybuf, password, salt, N, r, p, maxmem);
55+
handleError(_scrypt(keybuf, password, salt, N, r, p, maxmem));
5656
const encoding = getDefaultEncoding();
5757
if (encoding === 'buffer') return keybuf;
5858
return keybuf.toString(encoding);
5959
}
6060

61-
function handleError(keybuf, password, salt, N, r, p, maxmem, wrap) {
62-
const ex = _scrypt(keybuf, password, salt, N, r, p, maxmem, wrap);
63-
61+
function handleError(ex) {
6462
if (ex === undefined)
6563
return;
6664

0 commit comments

Comments
 (0)