source: imaps-frontend/node_modules/set-function-length/README.md

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 2.1 KB
Line 
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 function
14 - `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## Usage
20
21```javascript
22var 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-length
43[npm-version-svg]: https://versionbadg.es/ljharb/set-function-length.svg
44[deps-svg]: https://david-dm.org/ljharb/set-function-length.svg
45[deps-url]: https://david-dm.org/ljharb/set-function-length
46[dev-deps-svg]: https://david-dm.org/ljharb/set-function-length/dev-status.svg
47[dev-deps-url]: https://david-dm.org/ljharb/set-function-length#info=devDependencies
48[npm-badge-png]: https://nodei.co/npm/set-function-length.png?downloads=true&stars=true
49[license-image]: https://img.shields.io/npm/l/set-function-length.svg
50[license-url]: LICENSE
51[downloads-image]: https://img.shields.io/npm/dm/set-function-length.svg
52[downloads-url]: https://npm-stat.com/charts.html?package=set-function-length
53[codecov-image]: https://codecov.io/gh/ljharb/set-function-length/branch/main/graphs/badge.svg
54[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-length
56[actions-url]: https://github.com/ljharb/set-function-length/actions
Note: See TracBrowser for help on using the repository browser.