This commit is contained in:
TiclemFR
2024-01-20 23:14:52 +01:00
parent a068f54957
commit 031f7071e6
881 changed files with 241469 additions and 247870 deletions

View File

@@ -8,6 +8,9 @@ var gOPD = require('gopd');
var $TypeError = GetIntrinsic('%TypeError%');
var $floor = GetIntrinsic('%Math.floor%');
/** @typedef {(...args: unknown[]) => unknown} Func */
/** @type {<T extends Func = Func>(fn: T, length: number, loose?: boolean) => T} */
module.exports = function setFunctionLength(fn, length) {
if (typeof fn !== 'function') {
throw new $TypeError('`fn` is not a function');
@@ -32,9 +35,9 @@ module.exports = function setFunctionLength(fn, length) {
if (functionLengthIsConfigurable || functionLengthIsWritable || !loose) {
if (hasDescriptors) {
define(fn, 'length', length, true, true);
define(/** @type {Parameters<define>[0]} */ (fn), 'length', length, true, true);
} else {
define(fn, 'length', length);
define(/** @type {Parameters<define>[0]} */ (fn), 'length', length);
}
}
return fn;