View Source Better Number
BetterNumber is an Elixir library which provides functions to convert numbers into a variety of different formats. It is a fork of Daniel Berkompas's Number but it
Has slightly more features
Does not perform any configuration lookups and therefore each function is 100% pure.
Has no
__using__to import functionsHas correct type specifications
Actively maintained
example
Example
alias BetterNumber, as: Number
Number.Currency.number_to_currency(2034.46)
"$2,034.46"
Number.Phone.number_to_phone(1112223333, area_code: true, country_code: 1)
"+1 (111) 222-3333"
Number.Percentage.number_to_percentage(100, precision: 0)
"100%"
Number.Human.number_to_human(1234)
"1.23 Thousand"
Number.Delimit.number_to_delimited(12345678)
"12,345,678"
installation
Installation
Get it from Hex:
defp deps do
[
{:better_number, "~> 1.0.0"}
]
endThen run mix deps.get.
usage
Usage
defmodule MyModule do
alias BetterNumber, as: Number
endSee the Hex documentation for more information
about the modules provided by Number.
license
License
MIT. See LICENSE for more details.