Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember-short-number

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-short-number

Short Number abbreviation

  • 0.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
80
decreased by-75%
Maintainers
1
Weekly downloads
 
Created
Source

ember-short-number

Short number formatting based on cldr locale data

  • 1234 is converted to 1K in English
  • 101234 is converted to 101K in English and 101.1K if need 1 significant digit
  • 1234 is converted to 1 mil in Espanol
  • 101234 is converted to 101,1K in Espanol if need 1 significant digit

Based on cldr-numbers-full

Currently this only shortens with latin digits 0..9

For your information, known number systems include:

[adlm, ahom, arab, arabext, armn, armnlow, bali, beng, bhks, brah, cakm, cham, cyrl, deva, ethi, fullwide, geor, grek, greklow, gujr, guru, hanidays, hanidec, hans, hansfin, hant, hantfin, hebr, hmng, java, jpan, jpanfin, kali, khmr, knda, lana, lanatham, laoo, latn, lepc, limb, mathbold, mathdbl, mathmono, mathsanb, mathsans, mlym, modi, mong, mroo, ...]

Installation

ember install ember-short-number

Configuration

Provide list of language codes applicable to your app in your environment.js file. See ISO 639-1 for more information.

If 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.

let ENV = {
  'ember-short-number': {
    locales: ['en', 'es']
  }
}

Usage

Note - the following APIs take the language code as the the second argument based on ISO 639-1

Template Helper

{{short-number 19634 "en"}}
{{short-number 19634 "en" significantDigits=1}}

Service API

this.shortNumber.formatNumber(19634, 'en');
// 19K
this.shortNumber.formatNumber(19634, 'en', { significantDigits: 1, minimumFractionDigits: 1, maximumFractionDigits: 2 });
// 19.6K
  • Note when using significantDigits, this addon utilizes toLocaleString and returns type of String.

Contributing

Installation

  • git clone git@github.com:snewcomer/ember-short-number.git
  • cd ember-short-number
  • npm install

Linting

  • npm run lint:js
  • npm run lint:js -- --fix

Running tests

  • ember test – Runs the test suite on the current Ember version
  • ember test --server – Runs the test suite in "watch mode"
  • ember try:each – Runs the test suite against multiple Ember versions

Running the dummy application

For more information on using ember-cli, visit https://ember-cli.com/.

License

This project is licensed under the MIT License.

Keywords

FAQs

Package last updated on 16 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc