set-function-length (1.2.2)
Published 2026-02-24 14:04:57 +00:00 by atheaadmin
Installation
registry=npm install set-function-length@1.2.2"set-function-length": "1.2.2"About this package
set-function-length 
Set a function’s length.
Arguments:
fn: the functionlength: the new length. Must be an integer between 0 and 2**32.loose: Optional. If true, and the length fails to be set, do not throw. Default false.
Returns fn.
Usage
var setFunctionLength = require('set-function-length');
var assert = require('assert');
function zero() {}
function one(_) {}
function two(_, __) {}
assert.equal(zero.length, 0);
assert.equal(one.length, 1);
assert.equal(two.length, 2);
assert.equal(setFunctionLength(zero, 10), zero);
assert.equal(setFunctionLength(one, 11), one);
assert.equal(setFunctionLength(two, 12), two);
assert.equal(zero.length, 10);
assert.equal(one.length, 11);
assert.equal(two.length, 12);
Dependencies
Dependencies
| ID | Version |
|---|---|
| define-data-property | ^1.1.4 |
| es-errors | ^1.3.0 |
| function-bind | ^1.1.2 |
| get-intrinsic | ^1.2.4 |
| gopd | ^1.0.1 |
| has-property-descriptors | ^1.0.2 |
Development Dependencies
| ID | Version |
|---|---|
| @arethetypeswrong/cli | ^0.15.1 |
| @ljharb/eslint-config | ^21.1.0 |
| @ljharb/tsconfig | ^0.1.1 |
| @types/call-bind | ^1.0.5 |
| @types/define-properties | ^1.1.5 |
| @types/es-value-fixtures | ^1.4.4 |
| @types/for-each | ^0.3.3 |
| @types/function-bind | ^1.1.10 |
| @types/gopd | ^1.0.3 |
| @types/has-property-descriptors | ^1.0.3 |
| @types/object-inspect | ^1.8.4 |
| @types/tape | ^5.6.4 |
| aud | ^2.0.4 |
| auto-changelog | ^2.4.0 |
| call-bind | ^1.0.7 |
| es-value-fixtures | ^1.4.2 |
| eslint | =8.8.0 |
| evalmd | ^0.0.19 |
| for-each | ^0.3.3 |
| in-publish | ^2.0.1 |
| npmignore | ^0.3.1 |
| nyc | ^10.3.2 |
| object-inspect | ^1.13.1 |
| safe-publish-latest | ^2.0.0 |
| tape | ^5.7.5 |
| typescript | next |
Keywords
javascript
ecmascript
set
function
length
function.length
