This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
We were not able to find the expected elm-package.json file at this tag.
Tag 8.1.2
Committed At 2020-05-18 17:48:34 UTC

Modules

    README

    Elm Format Number Build Status

    This simple Elm package formats Float numbers as pretty strings.

    Format

    The format function formats Float numbers using a locale with settings:

    import FormatNumber exposing (format)
    import FormatNumber.Locales exposing (spanishLocale, usLocale)
    
    format usLocale (pi * 1000)  --> "3,141.59"
    format spanishLocale (pi * 1000)  --> "3.141,593"
    

    It is flexible enough to deal with different number of decimals, different thousand separators, different decimal separator, and different ways to represent negative numbers — all that is possible using Locales. The base locale matches Elm's native String.fromFloat using unicode minus (U+2212) instead of an hyphen/dash.

    import FormatNumber exposing (format)
    import FormatNumber.Locales exposing (Decimals(..), Locale, usLocale)
    
    sharesLocale : Locale
    sharesLocale =
        { usLocale
            | decimals = Exact 3
            , negativePrefix = "("
            , negativeSuffix = ")"
        }
    
    format usLocale -pi --> "−3.14"
    format sharesLocale -pi --> "(3.142)"
    

    The Decimals strategy type

    Decimals type contains different strategies for handling the number of decimals when formatting the number.

    • Min Int shows at least a certain amount of decimal digits, adding trailing zeros if needed.
    • Max Int shows up to a certain amount of decimal digits, discarding trailing zeros if needed.
    • Exact Int shows an exact number of decimal digits, adding trailing zeros if needed.

    Docs

    The API is further documented in package.elm-lang.org.

    Tests

    This package uses elm-verify-examples, all the examples in the documentation are automatically tested:

    $ npm install
    $ npm test