set-function-length <sup>Version Badge</sup>

github actions coverage License Downloads

npm badge

Set a function’s length.

Arguments:

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);

set-function-length - Installation

To install set-function-length via this registry, you'll need to install via the --registry parameter with your package manager.

n

NPM

npm install set-function-length --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Yarn

yarn config set registry https://js.registry.sudovanilla.org
yarn install set-function-length

Learn more about the config option.

PNPM

pnpm install set-function-length --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Bun Logo

Bun

bun install set-function-length --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Learn more about setting this up in your bunfig.toml configuration.


For Deno, add the following to your .npmrc file in your directory:

registry="https://js.registry.sudovanilla.org"

Then run the deno install command.

set-function-length - Download

Download Tarball (v1.2.2)

Integrity sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==
SHASUM aac72314198eaed975cf77b2c3b6b880695e5449
Tarball https://js.registry.sudovanilla.org/set-function-length/-/set-function-length-1.2.2.tgz