GeezerVison is showing github.com — lib: prefer `call()` over `apply()` if argument list is not array · nodejs/node@f814307
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/assert.js +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -27,13 +27,13 @@ const { | 27 | 27 | ArrayPrototypePush, | 28 | 28 | ArrayPrototypeSlice, | 29 | 29 | Error, | | 30 | + FunctionPrototypeCall, | 30 | 31 | NumberIsNaN, | 31 | 32 | ObjectAssign, | 32 | 33 | ObjectDefineProperty, | 33 | 34 | ObjectIs, | 34 | 35 | ObjectKeys, | 35 | 36 | ObjectPrototypeIsPrototypeOf, | 36 | | - ReflectApply, | 37 | 37 | RegExpPrototypeExec, | 38 | 38 | String, | 39 | 39 | StringPrototypeIndexOf, | @@ -575,7 +575,7 @@ function expectedException(actual, expected, message, fn) { | 575 | 575 | throwError = true; | 576 | 576 | } else { | 577 | 577 | // Check validation functions return value. | 578 | | - const res = ReflectApply(expected, {}, [actual]); | | 578 | + const res = FunctionPrototypeCall(expected, {}, actual); | 579 | 579 | if (res !== true) { | 580 | 580 | if (!message) { | 581 | 581 | generatedMessage = true; | @@ -720,7 +720,7 @@ function hasMatchingError(actual, expected) { | 720 | 720 | if (ObjectPrototypeIsPrototypeOf(Error, expected)) { | 721 | 721 | return false; | 722 | 722 | } | 723 | | - return ReflectApply(expected, {}, [actual]) === true; | | 723 | + return FunctionPrototypeCall(expected, {}, actual) === true; | 724 | 724 | } | 725 | 725 |
| 726 | 726 | function expectsNoError(stackStartFn, actual, error, message) { | |
Collapse file Copy file name to clipboardExpand all lines: lib/dgram.js +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -29,7 +29,6 @@ const { | 29 | 29 | FunctionPrototypeCall, | 30 | 30 | ObjectDefineProperty, | 31 | 31 | ObjectSetPrototypeOf, | 32 | | - ReflectApply, | 33 | 32 | SymbolAsyncDispose, | 34 | 33 | SymbolDispose, | 35 | 34 | } = primordials; | @@ -437,7 +436,7 @@ Socket.prototype.connect = function(port, address, callback) { | 437 | 436 | return; | 438 | 437 | } | 439 | 438 |
| 440 | | - ReflectApply(_connect, this, [port, address, callback]); | | 439 | + FunctionPrototypeCall(_connect, this, port, address, callback); | 441 | 440 | }; | 442 | 441 |
| 443 | 442 |
| |
Collapse file Copy file name to clipboardExpand all lines: lib/fs.js +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -29,6 +29,7 @@ const { | 29 | 29 | ArrayPrototypePush, | 30 | 30 | BigIntPrototypeToString, | 31 | 31 | Boolean, | | 32 | + FunctionPrototypeCall, | 32 | 33 | MathMax, | 33 | 34 | Number, | 34 | 35 | ObjectDefineProperties, | @@ -370,7 +371,7 @@ function readFile(path, options, callback) { | 370 | 371 | } | 371 | 372 | if (context.isUserFd) { | 372 | 373 | process.nextTick(function tick(context) { | 373 | | - ReflectApply(readFileAfterOpen, { context }, [null, path]); | | 374 | + FunctionPrototypeCall(readFileAfterOpen, { context }, null, path); | 374 | 375 | }, context); | 375 | 376 | return; | 376 | 377 | } | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/child_process.js +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -821,8 +821,7 @@ function setupChannel(target, channel, serializationMode) { | 821 | 821 | obj = handleConversion[message.type]; | 822 | 822 |
| 823 | 823 | // convert TCP object to native handle object | 824 | | - handle = ReflectApply(handleConversion[message.type].send, | 825 | | - target, [message, handle, options]); | | 824 | + handle = FunctionPrototypeCall(handleConversion[message.type].send, target, message, handle, options); | 826 | 825 |
| 827 | 826 | // If handle was sent twice, or it is impossible to get native handle | 828 | 827 | // out of it - just send a text without the handle. | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/cluster/child.js +3-2Lines changed: 3 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 | const { | 4 | 4 | ArrayPrototypeJoin, | 5 | 5 | FunctionPrototype, | | 6 | + FunctionPrototypeCall, | 6 | 7 | ObjectAssign, | 7 | 8 | ReflectApply, | 8 | 9 | SafeMap, | @@ -58,7 +59,7 @@ cluster._setupWorker = function() { | 58 | 59 | if (message.act === 'newconn') | 59 | 60 | onconnection(message, handle); | 60 | 61 | else if (message.act === 'disconnect') | 61 | | - ReflectApply(_disconnect, worker, [true]); | | 62 | + FunctionPrototypeCall(_disconnect, worker, true); | 62 | 63 | } | 63 | 64 | }; | 64 | 65 |
| @@ -287,7 +288,7 @@ function _disconnect(primaryInitiated) { | 287 | 288 | Worker.prototype.disconnect = function() { | 288 | 289 | if (this.state !== 'disconnecting' && this.state !== 'destroying') { | 289 | 290 | this.state = 'disconnecting'; | 290 | | - ReflectApply(_disconnect, this, []); | | 291 | + FunctionPrototypeCall(_disconnect, this); | 291 | 292 | } | 292 | 293 |
| 293 | 294 | return this; | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/cluster/worker.js +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | 'use strict'; | 2 | 2 |
| 3 | 3 | const { | | 4 | + FunctionPrototypeCall, | 4 | 5 | ObjectSetPrototypeOf, | 5 | 6 | ReflectApply, | 6 | 7 | } = primordials; | @@ -16,7 +17,7 @@ function Worker(options) { | 16 | 17 | if (!(this instanceof Worker)) | 17 | 18 | return new Worker(options); | 18 | 19 |
| 19 | | - ReflectApply(EventEmitter, this, []); | | 20 | + FunctionPrototypeCall(EventEmitter, this); | 20 | 21 |
| 21 | 22 | if (options === null || typeof options !== 'object') | 22 | 23 | options = kEmptyObject; | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/crypto/cipher.js +5-5Lines changed: 5 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | 'use strict'; | 2 | 2 |
| 3 | 3 | const { | | 4 | + FunctionPrototypeCall, | 4 | 5 | ObjectSetPrototypeOf, | 5 | | - ReflectApply, | 6 | 6 | StringPrototypeToLowerCase, | 7 | 7 | } = primordials; | 8 | 8 |
| @@ -117,15 +117,15 @@ function createCipherBase(cipher, credential, options, isEncrypt, iv) { | 117 | 117 | this[kHandle] = new CipherBase(isEncrypt, cipher, credential, iv, authTagLength); | 118 | 118 | this._decoder = null; | 119 | 119 |
| 120 | | - ReflectApply(LazyTransform, this, [options]); | | 120 | + FunctionPrototypeCall(LazyTransform, this, options); | 121 | 121 | } | 122 | 122 |
| 123 | 123 | function createCipherWithIV(cipher, key, options, isEncrypt, iv) { | 124 | 124 | validateString(cipher, 'cipher'); | 125 | 125 | const encoding = getStringOption(options, 'encoding'); | 126 | 126 | key = prepareSecretKey(key, encoding); | 127 | 127 | iv = iv === null ? null : getArrayBufferOrView(iv, 'iv'); | 128 | | - ReflectApply(createCipherBase, this, [cipher, key, options, isEncrypt, iv]); | | 128 | + FunctionPrototypeCall(createCipherBase, this, cipher, key, options, isEncrypt, iv); | 129 | 129 | } | 130 | 130 |
| 131 | 131 | // The Cipher class is part of the legacy Node.js crypto API. It exposes | @@ -215,7 +215,7 @@ function Cipheriv(cipher, key, iv, options) { | 215 | 215 | if (!(this instanceof Cipheriv)) | 216 | 216 | return new Cipheriv(cipher, key, iv, options); | 217 | 217 |
| 218 | | - ReflectApply(createCipherWithIV, this, [cipher, key, options, true, iv]); | | 218 | + FunctionPrototypeCall(createCipherWithIV, this, cipher, key, options, true, iv); | 219 | 219 | } | 220 | 220 |
| 221 | 221 | function addCipherPrototypeFunctions(constructor) { | @@ -244,7 +244,7 @@ function Decipheriv(cipher, key, iv, options) { | 244 | 244 | if (!(this instanceof Decipheriv)) | 245 | 245 | return new Decipheriv(cipher, key, iv, options); | 246 | 246 |
| 247 | | - ReflectApply(createCipherWithIV, this, [cipher, key, options, false, iv]); | | 247 | + FunctionPrototypeCall(createCipherWithIV, this, cipher, key, options, false, iv); | 248 | 248 | } | 249 | 249 |
| 250 | 250 | ObjectSetPrototypeOf(Decipheriv.prototype, LazyTransform.prototype); | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/crypto/hash.js +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | 'use strict'; | 2 | 2 |
| 3 | 3 | const { | | 4 | + FunctionPrototypeCall, | 4 | 5 | ObjectSetPrototypeOf, | 5 | | - ReflectApply, | 6 | 6 | StringPrototypeReplace, | 7 | 7 | StringPrototypeToLowerCase, | 8 | 8 | Symbol, | @@ -107,7 +107,7 @@ function Hash(algorithm, options) { | 107 | 107 | if (!isCopy && xofLen === undefined) { | 108 | 108 | maybeEmitDeprecationWarning(algorithm); | 109 | 109 | } | 110 | | - ReflectApply(LazyTransform, this, [options]); | | 110 | + FunctionPrototypeCall(LazyTransform, this, options); | 111 | 111 | } | 112 | 112 |
| 113 | 113 | ObjectSetPrototypeOf(Hash.prototype, LazyTransform.prototype); | @@ -171,7 +171,7 @@ function Hmac(hmac, key, options) { | 171 | 171 | this[kState] = { | 172 | 172 | [kFinalized]: false, | 173 | 173 | }; | 174 | | - ReflectApply(LazyTransform, this, [options]); | | 174 | + FunctionPrototypeCall(LazyTransform, this, options); | 175 | 175 | } | 176 | 176 |
| 177 | 177 | ObjectSetPrototypeOf(Hmac.prototype, LazyTransform.prototype); | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/crypto/sig.js +2-3Lines changed: 2 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 | const { | 4 | 4 | FunctionPrototypeCall, | 5 | 5 | ObjectSetPrototypeOf, | 6 | | - ReflectApply, | 7 | 6 | } = primordials; | 8 | 7 |
| 9 | 8 | const { | @@ -59,7 +58,7 @@ function Sign(algorithm, options) { | 59 | 58 | this[kHandle] = new _Sign(); | 60 | 59 | this[kHandle].init(algorithm); | 61 | 60 |
| 62 | | - ReflectApply(Writable, this, [options]); | | 61 | + FunctionPrototypeCall(Writable, this, options); | 63 | 62 | } | 64 | 63 |
| 65 | 64 | ObjectSetPrototypeOf(Sign.prototype, Writable.prototype); | @@ -219,7 +218,7 @@ function Verify(algorithm, options) { | 219 | 218 | this[kHandle] = new _Verify(); | 220 | 219 | this[kHandle].init(algorithm); | 221 | 220 |
| 222 | | - ReflectApply(Writable, this, [options]); | | 221 | + FunctionPrototypeCall(Writable, this, options); | 223 | 222 | } | 224 | 223 |
| 225 | 224 | ObjectSetPrototypeOf(Verify.prototype, Writable.prototype); | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/crypto/webcrypto.js +13-12Lines changed: 13 additions & 12 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 |
| 3 | 3 | const { | 4 | 4 | ArrayPrototypeIncludes, | | 5 | + FunctionPrototypeCall, | 5 | 6 | JSONParse, | 6 | 7 | JSONStringify, | 7 | 8 | ObjectDefineProperties, | @@ -84,7 +85,7 @@ async function digest(algorithm, data) { | 84 | 85 |
| 85 | 86 | algorithm = normalizeAlgorithm(algorithm, 'digest'); | 86 | 87 |
| 87 | | - return await ReflectApply(asyncDigest, this, [algorithm, data]); | | 88 | + return await FunctionPrototypeCall(asyncDigest, this, algorithm, data); | 88 | 89 | } | 89 | 90 |
| 90 | 91 | function randomUUID() { | @@ -377,10 +378,10 @@ async function deriveKey( | 377 | 378 | throw lazyDOMException('Unrecognized algorithm name', 'NotSupportedError'); | 378 | 379 | } | 379 | 380 |
| 380 | | - return ReflectApply( | | 381 | + return FunctionPrototypeCall( | 381 | 382 | importKeySync, | 382 | 383 | this, | 383 | | - ['raw-secret', bits, derivedKeyAlgorithm, extractable, keyUsages], | | 384 | + 'raw-secret', bits, derivedKeyAlgorithm, extractable, keyUsages, | 384 | 385 | ); | 385 | 386 | } | 386 | 387 |
| @@ -889,10 +890,10 @@ async function importKey( | 889 | 890 |
| 890 | 891 | algorithm = normalizeAlgorithm(algorithm, 'importKey'); | 891 | 892 |
| 892 | | - return ReflectApply( | | 893 | + return FunctionPrototypeCall( | 893 | 894 | importKeySync, | 894 | 895 | this, | 895 | | - [format, keyData, algorithm, extractable, keyUsages], | | 896 | + format, keyData, algorithm, extractable, keyUsages, | 896 | 897 | ); | 897 | 898 | } | 898 | 899 |
| @@ -926,7 +927,7 @@ async function wrapKey(format, key, wrappingKey, algorithm) { | 926 | 927 | } catch { | 927 | 928 | algorithm = normalizeAlgorithm(algorithm, 'encrypt'); | 928 | 929 | } | 929 | | - let keyData = await ReflectApply(exportKey, this, [format, key]); | | 930 | + let keyData = await FunctionPrototypeCall(exportKey, this, format, key); | 930 | 931 |
| 931 | 932 | if (format === 'jwk') { | 932 | 933 | const ec = new TextEncoder(); | @@ -1023,10 +1024,10 @@ async function unwrapKey( | 1023 | 1024 | } | 1024 | 1025 | } | 1025 | 1026 |
| 1026 | | - return ReflectApply( | | 1027 | + return FunctionPrototypeCall( | 1027 | 1028 | importKeySync, | 1028 | 1029 | this, | 1029 | | - [format, keyData, unwrappedKeyAlgo, extractable, keyUsages], | | 1030 | + format, keyData, unwrappedKeyAlgo, extractable, keyUsages, | 1030 | 1031 | ); | 1031 | 1032 | } | 1032 | 1033 |
| @@ -1349,10 +1350,10 @@ async function encapsulateKey(encapsulationAlgorithm, encapsulationKey, sharedKe | 1349 | 1350 | throw lazyDOMException('Unrecognized algorithm name', 'NotSupportedError'); | 1350 | 1351 | } | 1351 | 1352 |
| 1352 | | - const sharedKey = ReflectApply( | | 1353 | + const sharedKey = FunctionPrototypeCall( | 1353 | 1354 | importKeySync, | 1354 | 1355 | this, | 1355 | | - ['raw-secret', encapsulateBits.sharedKey, normalizedSharedKeyAlgorithm, extractable, usages], | | 1356 | + 'raw-secret', encapsulateBits.sharedKey, normalizedSharedKeyAlgorithm, extractable, usages, | 1356 | 1357 | ); | 1357 | 1358 |
| 1358 | 1359 | const encapsulatedKey = { | @@ -1469,10 +1470,10 @@ async function decapsulateKey( | 1469 | 1470 | throw lazyDOMException('Unrecognized algorithm name', 'NotSupportedError'); | 1470 | 1471 | } | 1471 | 1472 |
| 1472 | | - return ReflectApply( | | 1473 | + return FunctionPrototypeCall( | 1473 | 1474 | importKeySync, | 1474 | 1475 | this, | 1475 | | - ['raw-secret', decapsulatedBits, normalizedSharedKeyAlgorithm, extractable, usages], | | 1476 | + 'raw-secret', decapsulatedBits, normalizedSharedKeyAlgorithm, extractable, usages, | 1476 | 1477 | ); | 1477 | 1478 | } | 1478 | 1479 |
| |
|