{"id":17398499,"url":"https://github.com/vweevers/fixed-number","last_synced_at":"2026-04-17T05:03:32.321Z","repository":{"id":57237681,"uuid":"108103608","full_name":"vweevers/fixed-number","owner":"vweevers","description":"Format numbers, percentages and currencies with a fixed number of digits.","archived":false,"fork":false,"pushed_at":"2020-05-11T17:18:03.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-27T06:47:01.859Z","etag":null,"topics":["intl","nodejs","npm-package","number-formatter","numbers"],"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/vweevers.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}},"created_at":"2017-10-24T09:13:29.000Z","updated_at":"2019-08-19T21:26:12.000Z","dependencies_parsed_at":"2022-08-26T15:01:24.934Z","dependency_job_id":null,"html_url":"https://github.com/vweevers/fixed-number","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/vweevers/fixed-number","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Ffixed-number","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Ffixed-number/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Ffixed-number/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Ffixed-number/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vweevers","download_url":"https://codeload.github.com/vweevers/fixed-number/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Ffixed-number/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262689752,"owners_count":23349136,"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":["intl","nodejs","npm-package","number-formatter","numbers"],"created_at":"2024-10-16T14:57:37.157Z","updated_at":"2026-04-17T05:03:27.228Z","avatar_url":"https://github.com/vweevers.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fixed-number\n\n**Format numbers, percentages and currencies with a fixed number of digits. Succinct wrapper of [`Intl.NumberFormat`] defaulting to `en-US` locale. In terms of functionality it sits between [`Number.prototype.toFixed`] and the option-rich (and consequently verbose) `Intl.NumberFormat`.**\n\n[![npm status](http://img.shields.io/npm/v/fixed-number.svg)](https://www.npmjs.org/package/fixed-number)\n[![node](https://img.shields.io/node/v/fixed-number.svg)](https://www.npmjs.org/package/fixed-number)\n[![Travis build status](https://img.shields.io/travis/vweevers/fixed-number.svg?label=travis)](http://travis-ci.org/vweevers/fixed-number)\n[![AppVeyor build status](https://img.shields.io/appveyor/ci/vweevers/fixed-number.svg?label=appveyor)](https://ci.appveyor.com/project/vweevers/fixed-number)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n[![Dependency status](https://img.shields.io/david/vweevers/fixed-number.svg)](https://david-dm.org/vweevers/fixed-number)\n\n## Example\n\n```js\nconst decimal = require('fixed-number')(1, 3)\nconst percent = require('fixed-number')(2, 1, 'percent')\nconst usd = require('fixed-number')(2, 2, 'usd')\nconst eur = require('fixed-number')(3, 0, 'eur')\nconst custom = require('fixed-number')(1, 1, '+')\n\nconsole.log(decimal(123456.78900001)) // '123,456.789'\nconsole.log(decimal(NaN)) // '-.---'\nconsole.log(percent(0.2)) // '20.0%'\nconsole.log(usd(19.99)) // '$19.99'\nconsole.log(eur(19.99)) // '€020'\nconsole.log(custom(2)) // '2.0+'\n```\n\n## API\n\n### `format = require('fixed-number')(..)`\n\nArguments:\n\n- `minimumIntegerDigits` (number, required)\n- `exactFractionDigits` (number, required)\n- `style` (string): `'decimal'` (default), `'percent'`, a ISO 4217 currency code, or a custom suffix.\n- `locale` (string): defaults to `'en-US'` (see [Node.js docs](https://nodejs.org/api/intl.html) for requirements)\n\nReturns a function `format` that when called with a number, returns a formatted string.\n\n## Install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install fixed-number\n```\n\n## License\n\n[MIT](LICENSE) © 2017-present Vincent Weevers\n\n[`Intl.NumberFormat`]: https://developer.mozilla.org/nl/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat\n[`Number.prototype.toFixed`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvweevers%2Ffixed-number","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvweevers%2Ffixed-number","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvweevers%2Ffixed-number/lists"}