{"id":13454622,"url":"https://github.com/sindresorhus/math-clamp","last_synced_at":"2025-06-17T05:04:12.672Z","repository":{"id":34626958,"uuid":"38576623","full_name":"sindresorhus/math-clamp","owner":"sindresorhus","description":"Clamp a number","archived":false,"fork":false,"pushed_at":"2024-02-03T10:26:43.000Z","size":16,"stargazers_count":14,"open_issues_count":1,"forks_count":3,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-06-07T15:23:49.658Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/sindresorhus.png","metadata":{"funding":{"github":"sindresorhus","open_collective":"sindresorhus","buy_me_a_coffee":"sindresorhus","custom":"https://sindresorhus.com/donate"},"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2015-07-05T16:56:05.000Z","updated_at":"2025-01-07T20:11:11.000Z","dependencies_parsed_at":"2024-04-15T01:00:41.343Z","dependency_job_id":"b4099003-0bf9-42bd-8298-1b0bbd63fd90","html_url":"https://github.com/sindresorhus/math-clamp","commit_stats":{"total_commits":18,"total_committers":4,"mean_commits":4.5,"dds":"0.38888888888888884","last_synced_commit":"8e1fda2846e58421499ea5c0418ed5975d264858"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/sindresorhus/math-clamp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fmath-clamp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fmath-clamp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fmath-clamp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fmath-clamp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/math-clamp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fmath-clamp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260158920,"owners_count":22967310,"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":[],"created_at":"2024-07-31T08:00:56.024Z","updated_at":"2025-06-17T05:04:12.650Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://buymeacoffee.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["Packages","包","目录","Math","Number"],"sub_categories":["Math","数学"],"readme":"# math-clamp\n\n\u003e [Clamp](https://en.wikipedia.org/wiki/Clamping_(graphics)) a number\n\n## Install\n\n```sh\nnpm install math-clamp\n```\n\n## Usage\n\n```js\nimport mathClamp from 'math-clamp';\n\nmathClamp(1, {min: 2, max: 4});\n//=\u003e 2\n\nmathClamp(1, {min: 2});\n//=\u003e 2\n\nmathClamp(5, {max: 4});\n//=\u003e 4\n```\n\n## API\n\n### mathClamp(number, {min?, max?})\n\n## Related\n\n- [math-sum](https://github.com/sindresorhus/math-sum) - Sum numbers\n- [math-average](https://github.com/sindresorhus/math-average) - Get the average of numbers\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fmath-clamp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fmath-clamp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fmath-clamp/lists"}