UNPKG

5.37 kBMarkdownView Raw
1# [Numeral.js](http://numeraljs.com/)
2
3A javascript library for formatting and manipulating numbers.
4
5[Website and documentation](http://numeraljs.com/)
6
7
8# Travis Build Status
9
10Master [![Build Status](https://api.travis-ci.org/adamwdraper/Numeral-js.png)](https://travis-ci.org/adamwdraper/Numeral-js)
11
12Develop [![Build Status](https://travis-ci.org/adamwdraper/Numeral-js.png?branch=develop)](https://travis-ci.org/adamwdraper/Numeral-js)
13
14
15# Contributing
16
17Please submit all pull requests to the `develop` branch.
18
191. Fork the library
20
212. [Install grunt](http://gruntjs.com/getting-started#installing-the-cli)
22
233. Run `npm install` to install dependencies
24
254. Add your tests to the files in `/tests`
26
275. To test your tests, run `grunt`
28
296. When all your tests are passing, run `grunt build` to minify all files
30
317. Submit a pull request to the `develop` branch.
32
33
34### Languages
35
36When naming language files use the [ISO 639-1 language codes](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) supplemented by [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country codes when necessary.
37
38### Language translations will not be merged without unit tests.
39
40See [the english unit tests](https://github.com/adamwdraper/Numeral-js/blob/master/tests/languages/en-gb.js) for an example.
41
42
43# Changelog
44
45### 1.5.3
46
47Added currency symbol to optionally appear before negative sign / open paren
48
49Added float precision math support
50
51Added specification of abbreviation in thousands, millions, billions
52
53### 1.5.2
54
55Bug fix: Unformat should pass through if given a number
56
57Added a mechanism to control rounding behaviour
58
59Added languageData() for getting and setting language props at runtime
60
61### 1.5.1
62
63Bug fix: Make sure values aren't changed during formatting
64
65### 1.5.0
66
67Add defaultFormat(). numeral().format() uses the default to format if no string is provided
68
69.unformat() returns 0 when passed no string
70
71Added languages.js that contains all languages
72
73Bug fix: Fix bug while unformatting ordinals
74
75Add format option to always show signed value
76
77Added ability to instantiate numeral with a string value of a number
78
79### 1.4.9
80
81Bug fix: Fix bug while unformatting ordinals
82
83### 1.4.8
84
85Bug fix: Throw error if language is not defined
86
87### 1.4.7
88
89Bug fix: Fix typo for trillion
90
91### 1.4.6
92
93Bug fix: remove ' from unformatting regex that was causing an error with fr-ch.js
94
95### 1.4.5
96
97Add zeroFormat() function that accepts a string for custom formating of zeros
98
99Add valueOf() function
100
101Chain functionality to language function
102
103Make all minified files have the same .min.js filename ending
104
105### 1.4.1
106
107Bug fix: Bytes not formatting correctly
108
109### 1.4.0
110
111Add optional format for all decimals
112
113### 1.3.4
114
115Remove AMD module id. (This is encouraged by require.js to make the module more portable, and keep it from creating a global)
116
117### 1.3.3
118
119AMD define() compatibility.
120
121### 1.3.2
122
123Bug fix: Formatting some numbers results in the wrong value. Issue #21
124
125### 1.3.1
126
127Bug fix: Minor fix to unformatting parser
128
129### 1.3.0
130
131Add support for spaces before/after $, a, o, b in a format string
132
133Bug fix: Fix unformat for languages that use '.' in ordinals
134
135Bug fix: Fix round up floating numbers with no precision correctly.
136
137Bug fix: Fix currency signs at the end in unformat
138
139### 1.2.6
140
141Add support for optional decimal places
142
143### 1.2.5
144
145Add support for appending currency symbol
146
147### 1.2.4
148
149Add support for humanized filesizes
150
151### 1.2.3
152
153Bug Fix: Fix unformatting for languages that use '.' as thousands delimiter
154
155### 1.2.2
156
157Changed language definition property 'money' to 'currency'
158
159### 1.2.1
160
161Bug fix: Fix unformatting non-negative abbreviations
162
163### 1.2.0
164
165Add language support
166
167Update testing for to include languages
168
169### 1.1.0
170
171Add Tests
172
173Bug fix: Fix difference returning negative values
174
175### 1.0.4
176
177Bug fix: Non negative numbers were displaying as negative when using parentheses
178
179### 1.0.3
180
181Add ordinal formatting using 'o' in the format
182
183### 1.0.2
184
185Add clone functionality
186
187### 1.0.1
188
189Added abbreviations for thousands and millions using 'a' in the format
190
191### 1.0.0
192
193Initial release
194
195
196# Acknowlegements
197
198Numeral.js, while less complex, was inspired by and heavily borrowed from [Moment.js](http://momentjs.com)
199
200
201# License
202
203Numeral.js is freely distributable under the terms of the MIT license.
204
205Copyright (c) 2012 Adam Draper
206
207Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
208files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use,
209copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
210
211The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
212
213THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.