{"id":20056218,"url":"https://github.com/devgru/round-to-unit","last_synced_at":"2026-06-02T21:31:39.523Z","repository":{"id":66725655,"uuid":"46005037","full_name":"devgru/round-to-unit","owner":"devgru","description":"Number-rounding and formatting library with focus on correct string representation. roundToUnit('0.25')(0.4) === '0.50'","archived":false,"fork":false,"pushed_at":"2024-04-21T20:08:03.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-03-28T01:37:38.450Z","etag":null,"topics":["precision","rounding"],"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/devgru.png","metadata":{"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-11-11T19:35:29.000Z","updated_at":"2024-08-11T19:38:02.000Z","dependencies_parsed_at":"2023-06-09T20:15:30.544Z","dependency_job_id":null,"html_url":"https://github.com/devgru/round-to-unit","commit_stats":null,"previous_names":["devgru/round-to-unit","devgru/round-to-precision"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/devgru/round-to-unit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devgru%2Fround-to-unit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devgru%2Fround-to-unit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devgru%2Fround-to-unit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devgru%2Fround-to-unit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devgru","download_url":"https://codeload.github.com/devgru/round-to-unit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devgru%2Fround-to-unit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33838215,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-02T02:00:07.132Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["precision","rounding"],"created_at":"2024-11-13T12:52:31.883Z","updated_at":"2026-06-02T21:31:39.504Z","avatar_url":"https://github.com/devgru.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# round-to-unit\n\n\u003e Number-rounding and formatting library with focus on correct string representation. Useful in user interfaces and data visualizations.\n\nThis library provides rounding function converting raw user input (e.g. pointer coordinates) into nice values that are multiples to specified `unit`.\n\nBy default, library outputs strings. This behaviour can be overridden.\n\n## Usage\n\n```js\nimport { roundToUnit } from 'round-to-unit';\n\nconst roundToQuarters = roundToUnit('0.25');\nroundToQuarters(-0.7); // \"-0.75\"\n\nconst roundToTenths = roundToUnit('0.1', Number);\nroundToTenths(0.36); // 0.4\n```\n\n## NPM package\n\nInstall `round-to-unit@2`, it has no dependencies.\n\n## API Reference\n\n`roundToUnit(unit, [outputType = String])`\n\nGiven a string representing positive finite number `unit`, returns a `roundToSpecifiedUnit` function.\n\nProvide optional `outputType` to override return type of `roundToSpecifiedUnit` function.\n\n`roundToSpecifiedUnit(input)`\n\nGiven a number `input`, rounds it to specified `unit` and transforms it to `outputType`.\n\n## Development\n\n* Build `bun run prepack`;\n* Run tests: `bun test`;\n\n## License\n\nMIT © [Dima Semyushkin](https://devg.ru)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevgru%2Fround-to-unit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevgru%2Fround-to-unit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevgru%2Fround-to-unit/lists"}