Skip to content

Latest commit

 

History

History
43 lines (35 loc) · 2.43 KB

abbrNumber.md

File metadata and controls

43 lines (35 loc) · 2.43 KB

Type Enforcer Math

An extension of type-enforcer with Math related data types and enforcer functions

npm build coverage deps size vulnerabilities license


abbrNumber(value, [settings]) ⇒ string

Abbreviates a number in a human readable format.

See: https://en.wikipedia.org/wiki/Metric_prefix

Param Type Default Description
value number The number to abbreviate.
[settings] object Setting object.
[settings.precision] number 2 Passed to round().
[settings.prefix] object An object of unit name prefixes to use when shortening numbers. {'-8': 'y', '-7': 'z', ... '-1': 'm', '0': '', '1': 'k', ... '7': 'Z', '8': 'Y'}. The default prefixes are single character symbols like 'k' and 'μ' while full prefix names are provided via the separately exported "metricPrefixNames".
[settings.suffix] string "''" Appended after the prefix.