{"id":15541921,"url":"https://github.com/snewcomer/ember-short-number","last_synced_at":"2026-03-15T17:55:42.510Z","repository":{"id":33146232,"uuid":"152748029","full_name":"snewcomer/ember-short-number","owner":"snewcomer","description":"Short number formatting based on CLDR repository data","archived":false,"fork":false,"pushed_at":"2023-03-04T15:14:09.000Z","size":5485,"stargazers_count":11,"open_issues_count":17,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-18T08:22:44.005Z","etag":null,"topics":["emberjs","emberjs-addon","formatting","number-converter"],"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/snewcomer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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}},"created_at":"2018-10-12T12:35:42.000Z","updated_at":"2022-04-24T12:03:13.000Z","dependencies_parsed_at":"2024-10-20T20:22:15.201Z","dependency_job_id":null,"html_url":"https://github.com/snewcomer/ember-short-number","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snewcomer%2Fember-short-number","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snewcomer%2Fember-short-number/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snewcomer%2Fember-short-number/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snewcomer%2Fember-short-number/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snewcomer","download_url":"https://codeload.github.com/snewcomer/ember-short-number/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250477812,"owners_count":21437049,"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":["emberjs","emberjs-addon","formatting","number-converter"],"created_at":"2024-10-02T12:20:02.480Z","updated_at":"2026-03-15T17:55:37.478Z","avatar_url":"https://github.com/snewcomer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"ember-short-number\n==============================================================================\n![Download count all time](https://img.shields.io/npm/dt/ember-short-number.svg)\n[![npm version](https://badge.fury.io/js/ember-short-number.svg)](http://badge.fury.io/js/ember-short-number)\n[![Ember Observer Score](http://emberobserver.com/badges/ember-short-number.svg)](http://emberobserver.com/addons/ember-short-number)\n\n[![Dependency Status](https://david-dm.org/snewcomer/ember-short-number.svg)](https://david-dm.org/snewcomer/ember-short-number)\n[![devDependency Status](https://david-dm.org/snewcomer/ember-short-number/dev-status.svg)](https://david-dm.org/snewcomer/ember-short-number#info=devDependencies)\n\nShort number formatting based on CLDR locale data.  Particularly useful for __statistical data__, showing financial numbers in __charts__, and __abbreviating number of ratings__ across a range of languages.\n\n- `1234` is converted to `1K` in English\n- `101234` is converted to `101K` in English and `101.1K` if need 1 significant digit\n- `1234` is converted to `1 mil` in Espanol\n- `101234` is converted to `101,1 mil` in Espanol if need 1 significant digit\n- `1234` is converted to `1234` in Japanese\n\nUtilizes [cldr-numbers-full](https://github.com/unicode-cldr/cldr-numbers-full). Here is the related proposal for [Compact Decimal Format](https://github.com/tc39/ecma402/issues/37) that this addon is based on.  This is why there are no browser API's baked into something like `Intl.NumberFormat`.\n\nLastly, this work has been built into [ember-intl](https://github.com/ember-intl/ember-intl) as of version 4.0.0-beta.6 if you also use an internationalization library. See docs for more details.\n\nInstallation\n------------------------------------------------------------------------------\n\n```\nember install ember-short-number\n```\n\nConfiguration\n------------------------------------------------------------------------------\nProvide list of language codes applicable to your app in your `environment.js` file.  See [ISO 639-1](http://www.loc.gov/standards/iso639-2/php/code_list.php) for more information.\n\nIf not provided, we will include the data for all CLDR number formatting options in your app.  IMPORTANT - this adds ~28KB gzipped to your app so be sure to include all the languages you care about.\n\n```js\nlet ENV = {\n  'ember-short-number': {\n    locales: ['en', 'es'],\n    threshold: 0.05 // default\n  }\n}\n```\n\n### threshold\n\nThis configuration option decides when to round up the formatted number.  So if you pass 95001, `ember-short-number` will output 100K.  However, if you pass 94999, you will get back 95K.\n\nUsage\n------------------------------------------------------------------------------\nThe following APIs take the language code as the the second argument based on [ISO 639-1](http://www.loc.gov/standards/iso639-2/php/code_list.php).  You can also pass `en_GB` and we will normalize it to `en-GB` as well.\n\n### Template Helper\n\n```hbs\n{{short-number 19634 \"en\"}}\n// 19K\n```\n\n```hbs\n{{short-number 19634 \"en\" significantDigits=1}}\n// 19.6K\n```\n\n```hbs\n{{short-number 19634 \"es\" significantDigits=1}}\n// 19,6 mil\n```\n\n```hbs\n{{short-number 19634 \"es-MX\" significantDigits=1}}\n// 19.6 k\n```\n\n```hbs\n{{short-number 101K \"en\" significantDigits=1 financialFormat=true}}\n// 0.1M\n```\n\n\n### Service API\n\n```js\nthis.shortNumber.format(19634, 'en');\n// 19K\n```\n\n```js\nthis.shortNumber.format(19634, 'en', { significantDigits: 1, minimumFractionDigits: 1, maximumFractionDigits: 2 });\n// 19.6K\n```\n\n```js\nthis.shortNumber.format(101, 'en', { significantDigits: 1, financialFormat: true });\n// 0.1M\n```\n\n```js\nthis.shortNumber.format(19634, 'ja');\n// 2万\n```\n\n```js\nthis.shortNumber.format(19634, 'es', { significantDigits: 1 });\n// 19,6 mil\n```\n\n* Note when using significantDigits, this addon utilizes [`toLocaleString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString).\n\n\n### Long Formatting\n\n\"Wait, I thought this addon was for compact number formatting?\" Well it can be a misnomer depending on the language.  Let's look at some examples.\n\nThis doesn't seem shorter!!!! (╯°□°）╯︵ ┻━┻\n```js\nthis.shortNumber.format(101000, 'en', { long: true });\n// 101 thousand\n```\n\nBut this does! ʘ‿ʘ\n```js\nthis.shortNumber.format(101000, 'ja', { long: true });\n// 101万\n```\n\nSo we will just go with `ember-short-number` for now.\n\n\nOther\n------------------------------------------------------------------------------\nCurrently this only shortens with latin digits 0..9\n\nFor your information, known number systems include:\n\n[adlm, ahom, arab, arabext, armn, armnlow, bali, beng, bhks, brah,\n cakm, cham, cyrl, deva, ethi, fullwide, geor, grek, greklow, gujr,\n guru, hanidays, hanidec, hans, hansfin, hant, hantfin, hebr, hmng,\n java, jpan, jpanfin, kali, khmr, knda, lana, lanatham, laoo, latn,\n lepc, limb, mathbold, mathdbl, mathmono, mathsanb, mathsans, mlym,\n modi, mong, mroo, ...]\n\n\nContributing\n------------------------------------------------------------------------------\n\n### Installation\n\n* `git clone git@github.com:snewcomer/ember-short-number.git`\n* `cd ember-short-number`\n* `npm install`\n\n### Linting\n\n* `npm run lint:js`\n* `npm run lint:js -- --fix`\n\n### Running tests\n\n* `ember test` – Runs the test suite on the current Ember version\n* `ember test --server` – Runs the test suite in \"watch mode\"\n* `ember try:each` – Runs the test suite against multiple Ember versions\n\n### Running the dummy application\n\n* `ember serve`\n* Visit the dummy application at [http://localhost:4200](http://localhost:4200).\n\nFor more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).\n\nLicense\n------------------------------------------------------------------------------\n\nThis project is licensed under the [MIT License](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnewcomer%2Fember-short-number","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnewcomer%2Fember-short-number","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnewcomer%2Fember-short-number/lists"}