basant307/AI_Governance_Project
048
1# set-function-length <sup>[![Version Badge][npm-version-svg]][package-url]</sup>2 3[![github actions][actions-image]][actions-url]4[![coverage][codecov-image]][codecov-url]5[![License][license-image]][license-url]6[![Downloads][downloads-image]][downloads-url]7 8[![npm badge][npm-badge-png]][package-url]9 10Set a function’s length.11 12Arguments:13 - `fn`: the function14 - `length`: the new length. Must be an integer between 0 and 2**32.15 - `loose`: Optional. If true, and the length fails to be set, do not throw. Default false.16 17Returns `fn`.18 19## Usage20 21```javascript22var setFunctionLength = require('set-function-length');23var assert = require('assert');24 25function zero() {}26function one(_) {}27function two(_, __) {}28 29assert.equal(zero.length, 0);30assert.equal(one.length, 1);31assert.equal(two.length, 2);32 33assert.equal(setFunctionLength(zero, 10), zero);34assert.equal(setFunctionLength(one, 11), one);35assert.equal(setFunctionLength(two, 12), two);36 37assert.equal(zero.length, 10);38assert.equal(one.length, 11);39assert.equal(two.length, 12);40```41 42[package-url]: https://npmjs.org/package/set-function-length43[npm-version-svg]: https://versionbadg.es/ljharb/set-function-length.svg44[deps-svg]: https://david-dm.org/ljharb/set-function-length.svg45[deps-url]: https://david-dm.org/ljharb/set-function-length46[dev-deps-svg]: https://david-dm.org/ljharb/set-function-length/dev-status.svg47[dev-deps-url]: https://david-dm.org/ljharb/set-function-length#info=devDependencies48[npm-badge-png]: https://nodei.co/npm/set-function-length.png?downloads=true&stars=true49[license-image]: https://img.shields.io/npm/l/set-function-length.svg50[license-url]: LICENSE51[downloads-image]: https://img.shields.io/npm/dm/set-function-length.svg52[downloads-url]: https://npm-stat.com/charts.html?package=set-function-length53[codecov-image]: https://codecov.io/gh/ljharb/set-function-length/branch/main/graphs/badge.svg54[codecov-url]: https://app.codecov.io/gh/ljharb/set-function-length/55[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/set-function-length56[actions-url]: https://github.com/ljharb/set-function-length/actions57 