{"id":15686811,"url":"https://github.com/ljharb/set-function-length","last_synced_at":"2025-04-30T07:28:36.680Z","repository":{"id":199937542,"uuid":"704249795","full_name":"ljharb/set-function-length","owner":"ljharb","description":"Set a function's length property","archived":false,"fork":false,"pushed_at":"2024-03-09T17:40:57.000Z","size":75,"stargazers_count":6,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-04T08:08:12.602Z","etag":null,"topics":["ecmascript","function","javascript","length","set"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ljharb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["ljharb"],"patreon":null,"open_collective":null,"ko_fi":"ljharb","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"polar":null,"buy_me_a_coffee":null,"custom":null}},"created_at":"2023-10-12T21:29:58.000Z","updated_at":"2024-06-03T02:11:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"6eff8cc8-a47e-4f99-a275-f184f1f9bad9","html_url":"https://github.com/ljharb/set-function-length","commit_stats":null,"previous_names":["ljharb/set-function-length"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ljharb%2Fset-function-length","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ljharb%2Fset-function-length/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ljharb%2Fset-function-length/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ljharb%2Fset-function-length/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ljharb","download_url":"https://codeload.github.com/ljharb/set-function-length/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233985940,"owners_count":18761563,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ecmascript","function","javascript","length","set"],"created_at":"2024-10-03T17:41:25.851Z","updated_at":"2025-01-16T03:28:03.597Z","avatar_url":"https://github.com/ljharb.png","language":"JavaScript","funding_links":["https://github.com/sponsors/ljharb","https://ko-fi.com/ljharb"],"categories":[],"sub_categories":[],"readme":"# set-function-length \u003csup\u003e[![Version Badge][npm-version-svg]][package-url]\u003c/sup\u003e\n\n[![github actions][actions-image]][actions-url]\n[![coverage][codecov-image]][codecov-url]\n[![License][license-image]][license-url]\n[![Downloads][downloads-image]][downloads-url]\n\n[![npm badge][npm-badge-png]][package-url]\n\nSet a function’s length.\n\nArguments:\n - `fn`: the function\n - `length`: the new length. Must be an integer between 0 and 2**32.\n - `loose`: Optional. If true, and the length fails to be set, do not throw. Default false.\n\nReturns `fn`.\n\n## Usage\n\n```javascript\nvar setFunctionLength = require('set-function-length');\nvar assert = require('assert');\n\nfunction zero() {}\nfunction one(_) {}\nfunction two(_, __) {}\n\nassert.equal(zero.length, 0);\nassert.equal(one.length, 1);\nassert.equal(two.length, 2);\n\nassert.equal(setFunctionLength(zero, 10), zero);\nassert.equal(setFunctionLength(one, 11), one);\nassert.equal(setFunctionLength(two, 12), two);\n\nassert.equal(zero.length, 10);\nassert.equal(one.length, 11);\nassert.equal(two.length, 12);\n```\n\n[package-url]: https://npmjs.org/package/set-function-length\n[npm-version-svg]: https://versionbadg.es/ljharb/set-function-length.svg\n[deps-svg]: https://david-dm.org/ljharb/set-function-length.svg\n[deps-url]: https://david-dm.org/ljharb/set-function-length\n[dev-deps-svg]: https://david-dm.org/ljharb/set-function-length/dev-status.svg\n[dev-deps-url]: https://david-dm.org/ljharb/set-function-length#info=devDependencies\n[npm-badge-png]: https://nodei.co/npm/set-function-length.png?downloads=true\u0026stars=true\n[license-image]: https://img.shields.io/npm/l/set-function-length.svg\n[license-url]: LICENSE\n[downloads-image]: https://img.shields.io/npm/dm/set-function-length.svg\n[downloads-url]: https://npm-stat.com/charts.html?package=set-function-length\n[codecov-image]: https://codecov.io/gh/ljharb/set-function-length/branch/main/graphs/badge.svg\n[codecov-url]: https://app.codecov.io/gh/ljharb/set-function-length/\n[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/set-function-length\n[actions-url]: https://github.com/ljharb/set-function-length/actions\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fljharb%2Fset-function-length","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fljharb%2Fset-function-length","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fljharb%2Fset-function-length/lists"}