{"id":22645516,"url":"https://github.com/akmjenkins/nearest","last_synced_at":"2025-03-29T06:21:14.491Z","repository":{"id":57096019,"uuid":"380362953","full_name":"akmjenkins/nearest","owner":"akmjenkins","description":"Round to the nearest N","archived":false,"fork":false,"pushed_at":"2021-06-26T17:34:01.000Z","size":199,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-17T19:53:23.087Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akmjenkins.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-25T22:04:02.000Z","updated_at":"2021-06-26T17:34:04.000Z","dependencies_parsed_at":"2022-08-22T23:00:29.578Z","dependency_job_id":null,"html_url":"https://github.com/akmjenkins/nearest","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akmjenkins%2Fnearest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akmjenkins%2Fnearest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akmjenkins%2Fnearest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akmjenkins%2Fnearest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akmjenkins","download_url":"https://codeload.github.com/akmjenkins/nearest/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246145604,"owners_count":20730593,"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-12-09T06:06:15.222Z","updated_at":"2025-03-29T06:21:14.473Z","avatar_url":"https://github.com/akmjenkins.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @akmjenkins/nearest\n\n[![npm version](https://img.shields.io/npm/v/@akmjenkins/nearest.svg)](https://npmjs.org/package/@akmjenkins/nearest)\n[![Coverage Status](https://coveralls.io/repos/github/akmjenkins/nearest/badge.svg)](https://coveralls.io/github/akmjenkins/nearest)\n[![Build Status](https://travis-ci.com/akmjenkins/nearest.svg)](https://travis-ci.com/akmjenkins/nearest)\n[![Bundle Phobia](https://badgen.net/bundlephobia/minzip/@akmjenkins/nearest)](https://bundlephobia.com/result?p=@akmjenkins/nearest)\n\n\n## Rounds a number to the nearest N\n\n\n```js\nimport nearest from '@akmjenkins/nearest';\n\nconst roundToNearest10 = nearest(10);\n\nroundToNearest10(5); // 10\nroundToNearest10(4); // 0\n\nconst roundUpToNearest10 = nearest(10,Math.ceil);\n\nroundUpToNearest10(5); // 10\nroundUpToNearest10(1); // 10\nroundUpToNearest10(11); // 20\n\nconst roundDownToNearest10 = nearest(10,Math.floor);\n\nroundDownToNearest10(5); // 0\nroundDownToNearest10(1); // 0\nroundDownToNearest10(11); // 10\nroundDownToNearest10(19); // 10\n```\n\nOr in the browser (creates a global `nearest`)\n\n```html\n\u003cscript src=\"https://unpkg.com/@akmjenkins/nearest\"\u003e\n    const roundToNearest10 = nearest(10);\n    roundToNearest10(5); // 10\n\u003c/script\u003e\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakmjenkins%2Fnearest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakmjenkins%2Fnearest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakmjenkins%2Fnearest/lists"}