Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
cuducos committed Feb 11, 2017
1 parent 5ab4b75 commit 116508d
Showing 1 changed file with 33 additions and 13 deletions.
46 changes: 33 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,44 @@
# Elm Format Number
# Elm Format Number [![Build Status](https://travis-ci.org/cuducos/elm-format-number.svg?branch=master)](https://travis-ci.org/cuducos/elm-format-number)

[![Build Status](https://travis-ci.org/lovasoa/elm-format-number.svg?branch=master)](https://travis-ci.org/lovasoa/elm-format-number)

This simple [Elm](http://elm-lang.com) package formats numbers as pretty strings.
It is flexible enough to deal with different number of decimals,
different thousand separators and diffetent decimal separator.
This simple [Elm](http://elm-lang.com) package formats `float` numbers as pretty strings:

## API documentation
The API is extensively documented with numerous examples.
```elm
import FormatNumber exposing (format)
import FormatNumber.Locales exposing (spanishLocale)

See this package's page on elm-lang.org:
http://package.elm-lang.org/packages/lovasoa/elm-format-number/latest/FormatNumber
format spanishLocale (pi * 1000) -- "3.141,59"
```

It is flexible enough to deal with different number of decimals, different thousand separators and diffetent decimal separator. It has a couple os predefined `Locale` but you can edit them or create your own:

```elm
import FormatNumber exposing (format)
import FormatNumber.Locales exposing (Locale)

myLocale : Locale
myLocale =
{ decimals = 4
, thousandSeparator = " "
, decimalSeparator = "."
}

sharesLocale : Locale
sharesLocale = { myLocale | decimals = 3 }

format myLocale (pi * 1000) -- "3 141.5926"
format sharesLocale (pi * 1000) -- "3 141.593"



```

The API is further documented in [package.elm-lang.org](http://package.elm-lang.org/packages/cuducos/elm-format-number/latest/FormatNumber).

## Tests

This package uses [elm-doc-test](https://www.npmjs.com/package/elm-doc-test):
All the exemples in the documentation are automatically tested and are
guaranted to be correct.
This package uses [elm-doc-test](https://www.npmjs.com/package/elm-doc-test), all the exemples in the documentation are automatically tested:

#### launch tests
```console
$ yarn install
$ yarn test
Expand Down

0 comments on commit 116508d

Please sign in to comment.