🔧
This commit is contained in:
7
node_modules/set-function-length/index.js
generated
vendored
7
node_modules/set-function-length/index.js
generated
vendored
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user