diff --git a/.gitignore b/.gitignore index 9843db63..38ecea03 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,7 @@ Icon # -------------------- # App Files # -------------------- -node_modules/ \ No newline at end of file +node_modules/ +.sass-cache +temp/ +npm-debug.log diff --git a/.travis.yml b/.travis.yml index 0fedc343..9de8cd01 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: node_js node_js: - - "0.10" - - "0.8" + - "node" + - "4" before_script: - npm install -g grunt-cli -script: grunt travis --verbose \ No newline at end of file +script: grunt travis --verbose diff --git a/Gruntfile.js b/Gruntfile.js index b90e008c..a1da9e49 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,50 +1,138 @@ -var fs = require('fs'); - module.exports = function(grunt) { - var minifiedFiles = { - 'min/numeral.min.js' : [ - 'numeral.js' - ], - 'min/languages.min.js': [ - 'languages.js' - ] - }; + var compileType = function() { + var type = this.data.type; + var template = grunt.file.read('templates/types.js'); + var anon = grunt.file.read('templates/anon.js'); + var files = grunt.file.expand([ + 'src/' + type + '/*.js' + ]); + var regexp = /\}\(this, function \(numeral\) \{\s([\s\S]+)(?:\s\}\)\);)/; + var content = ''; + var file; + var i; - // all the lang files need to be added manually - fs.readdirSync('./languages').forEach(function (path) { - var file = path.slice(0, -3), - destination = 'min/languages/' + file + '.min.js', - src = ['languages/' + path]; + for (i = 0; i < files.length; i++) { + file = grunt.file.read(files[i]); - minifiedFiles[destination] = src; - }); + content += '\n' + grunt.template.process(anon, { + data: { + content: file.match(regexp)[1] + } + }) + '\n'; + } + + grunt.file.write('temp/' + type + '.js', content); + + if (type === 'locales') { + grunt.file.write('locales.js', grunt.template.process(template, { + data: { + type: type, + content: content + } + })); + } + }, + compileNumeral = function() { + var regexp = /([\s])return numeral;(?:\s\}\)\);)/; + var numeral = grunt.file.read('src/numeral.js'); + var formats = grunt.file.read('temp/formats.js'); + var index = numeral.indexOf('return numeral;'); + + numeral = numeral.substr(0, index) + '\n' + formats + numeral.substr(index); + + grunt.file.write('numeral.js', numeral); + }; + + require('load-grunt-tasks')(grunt); grunt.initConfig({ - nodeunit : { - all : ['tests/**/*.js'] + mochaTest : { + all: [ + 'tests/numeral.js', + 'tests/formats/*.js', + 'tests/locales/*.js' + ] + }, + karma: { + options: { + files: [ + 'numeral.js', + 'locales.js', + 'tests/numeral.js', + 'tests/formats/*.js', + 'tests/locales/*.js' + ], + frameworks: [ + 'mocha', + 'chai' + ], + singleRun: true, + autoWatch: false + }, + local: { + browsers: [ + 'Chrome', + 'Firefox' + ] + }, + ci: { + configFile: 'karma-ci.conf.js' + } + }, + copy: { + locales: { + files: [ + { + expand: true, + cwd: 'src/', + src: [ + 'locales/*.js' + ], + dest: './' + } + ] + } + }, + compile: { + locales: { + type: 'locales' + }, + formats: { + type: 'formats' + } }, uglify: { - my_target: { - files: minifiedFiles + min: { + files: [ + { + expand: true, + cwd: 'src/', + src: [ + 'locales/*.js' + ], + dest: 'min/', + ext: '.min.js' + }, + { + expand: true, + src: [ + 'numeral.js', + 'locales.js' + ], + dest: 'min/', + ext: '.min.js' + } + ] }, options: { preserveComments: 'some' } }, - concat: { - languages: { - src: [ - 'languages/**/*.js' - ], - dest: 'languages.js' - } - }, jshint: { all: [ 'Gruntfile.js', - 'numeral.js', - 'languages/**/*.js' + 'src/**/*.js' ], options: { 'node': true, @@ -55,37 +143,117 @@ module.exports = function(grunt) { 'eqnull': true, 'newcap': true, 'noarg': true, - 'onevar': true, 'undef': true, 'sub': true, 'strict': false, - 'quotmark': 'single' + 'quotmark': 'single', + 'globals': { + 'define': true + } } } }); - grunt.loadNpmTasks('grunt-contrib-nodeunit'); - grunt.loadNpmTasks('grunt-contrib-uglify'); - grunt.loadNpmTasks('grunt-contrib-jshint'); - grunt.loadNpmTasks('grunt-contrib-concat'); - grunt.registerTask('default', [ 'test' ]); - grunt.registerTask('test', [ - 'jshint', - 'nodeunit' - ]); + grunt.registerMultiTask('compile', compileType); + + grunt.registerTask('compile:numeral', compileNumeral); - // P grunt.registerTask('build', [ 'jshint', - 'nodeunit', - 'concat', + 'compile', + 'compile:numeral', + 'copy' + ]); + + grunt.registerTask('test', [ + 'build', + 'mochaTest', + 'karma:local' + ]); + + grunt.registerTask('test:npm', [ + 'build', + 'mochaTest' + ]); + + grunt.registerTask('test:browser', [ + 'build', + 'karma:local' + ]); + + grunt.registerTask('dist', [ + 'build', 'uglify' ]); + grunt.registerTask('version', function (version) { + if (!version || version.split('.').length !== 3) { + grunt.fail.fatal('malformed version. Use\n\n grunt version:1.2.3'); + } + + grunt.config('string-replace.json', { + files: { + 'package.json': 'package.json', + 'component.json': 'component.json', + 'bower.json': 'bower.json' + }, + options: { + replacements: [ + { + pattern: /"version": .*/, + replacement: '"version": "' + version + '",' + } + ] + } + }); + + grunt.config('string-replace.numeral', { + files: { + 'src/numeral.js': 'src/numeral.js' + }, + options: { + replacements: [ + { + pattern: /version : .*/, + replacement: 'version : ' + version + }, + { + pattern: /VERSION = .*/, + replacement: 'VERSION = \'' + version + '\',' + } + ] + } + }); + + grunt.config('string-replace.templates', { + files: { + 'templates/types.js': 'templates/types.js' + }, + options: { + replacements: [ + { + pattern: /: .*/, + replacement: ': ' + version + } + ] + } + }); + + grunt.task.run([ + 'string-replace:json', + 'string-replace:templates', + 'string-replace:numeral' + ]); + }); + // Travis CI task. - grunt.registerTask('travis', ['test']); -}; \ No newline at end of file + grunt.registerTask('travis', [ + 'build', + 'mochaTest', + 'karma:ci' + ]); +}; diff --git a/LICENSE b/LICENSE index 145e65bc..e373f897 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2012 Adam Draper +Copyright (c) 2016 Adam Draper Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation @@ -19,4 +19,4 @@ 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. \ No newline at end of file +OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index 79f6e0e9..f1d414d7 100644 --- a/README.md +++ b/README.md @@ -7,17 +7,21 @@ A javascript library for formatting and manipulating numbers. # Travis Build Status -Master [![Build Status](https://api.travis-ci.org/adamwdraper/Numeral-js.png)](https://travis-ci.org/adamwdraper/Numeral-js) +Master [![Build Status](https://api.travis-ci.org/adamwdraper/Numeral-js.svg)](https://travis-ci.org/adamwdraper/Numeral-js) -Develop [![Build Status](https://travis-ci.org/adamwdraper/Numeral-js.png?branch=develop)](https://travis-ci.org/adamwdraper/Numeral-js) +Develop [![Build Status](https://travis-ci.org/adamwdraper/Numeral-js.svg?branch=develop)](https://travis-ci.org/adamwdraper/Numeral-js) # NPM -[![NPM](https://nodei.co/npm/numeral.png?downloads=true)](https://nodei.co/npm/numeral/) +[![NPM](https://nodei.co/npm/numeral.svg?downloads=true)](https://nodei.co/npm/numeral/) + +#CDNJS + +[![CDNJS](https://img.shields.io/cdnjs/v/numeral.js.svg)](https://cdnjs.com/libraries/numeral.js) # Contributing -Please submit all pull requests to the `develop` branch. +#### Important: Please create your branch from and submit pull requests to the `develop` branch. All pull requests must include the appropriate tests. 1. Fork the library @@ -25,26 +29,109 @@ Please submit all pull requests to the `develop` branch. 3. Run `npm install` to install dependencies -4. Add your tests to the files in `/tests` +4. Create a new branch from `develop` + +5. Add your tests to the files in `/tests` + +6. To test your tests, run `grunt` + +7. When all your tests are passing, run `grunt dist` to compile and minify all files + +8. Submit a pull request to the `develop` branch. -5. To test your tests, run `grunt` -6. When all your tests are passing, run `grunt build` to minify all files +### Formats -7. Submit a pull request to the `develop` branch. +Formats now exist in their own files and act more or less as plugins. Check out the [bytes format](https://github.com/adamwdraper/Numeral-js/blob/master/src/formats/bytes.js) for an example of how to create one. -### Languages +### Locales -When 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. +When naming locale 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. -### Language translations will not be merged without unit tests. +### Locale translations will not be merged without unit tests. -See [the english unit tests](https://github.com/adamwdraper/Numeral-js/blob/master/tests/languages/en-gb.js) for an example. +See [the english unit tests](https://github.com/adamwdraper/Numeral-js/blob/master/tests/locales/en-gb.js) for an example. # Changelog +### 2.0.6 + +Bug fix: Multi letter currency symbols and spacing + +Added: Formatting of numbers with leading zeros + +New format: Basic Point + +Option: Added `scalePercentBy100` (default: true) option to turn on/off scaling percentages + +### 2.0.4 + +Bug fix: Incorrect abbreviations for values rounded up [#187](https://github.com/adamwdraper/Numeral-js/issues/187) + +Bug fix: Signed currency is inconsistent [#89](https://github.com/adamwdraper/Numeral-js/issues/89) + +### 2.0.2 + +Bug fix: Updated module definitions + +### 2.0.1 + +Bug fix: Fixed regression for webpack/browserify/rollup + +### 2.0.0 + +2.0.0 brings a lot of breaking changes and a reorganization of the repo, but also simplifies the api as well as the creating of custom formats. + +Breaking change / Feature: All formats are now separate files. This makes it easy to create custom formats, and will also allow for custom builds with only certain formats. (Note: The built numeral.js still contains all formats in the repo). + +Breaking change / Feature: All formats and locales are now loaded using `numeral.register(type, name, {})` + +Breaking change: All `language` now renamed to `locale` and standardized to all lowercase filenames + +Breaking change: The `locale` function no longer loads locales, it only sets the current locale + +Breaking change: The `unformat` function has been removed `numeral().unformat(string)` and now happens on numeral init `numeral(string)` + +Breaking change / Feature: Bytes are now formatted as: `b` (base 1000) and `ib` (base 1024) + +Breaking change: `numeral(NaN)` is now treated the same as `numeral(null)` and no longer throws an error + +Feature: Exponential format using `e+` or `e-` + +Bug fix: Update to floating point helpers (Note: Numeral does not fix JS floating point errors, but look to our tests to see that it covers quite a few cases.) + +### 1.5.6 + +Bug fix: numeral converts strings to numbers + +Bug fix: Null values return same as 0 + +### 1.5.5 + +Contained breaking changes, recommended to use 1.5.6 + +Bug fix: Switch bytes back to `b` and change iecBinary to `ib`, and calculate both using 1024 for backwards compatibility + +### 1.5.4 + +Contained breaking changes, recommended to use 1.5.6 + +Tests: Changed all tests to use Mocha and Chai + +Tests: Added browser tests for Chrome, Firefox, and IE using saucelabs + +Added reset function to reset numeral to default options + +Added nullFormat option + +Update reduce polyfill + +Added Binary bytes + +Bug fix: Fixes problem with many optional decimals + ### 1.5.3 Added currency symbol to optionally appear before negative sign / open paren diff --git a/bower.json b/bower.json index 5dcf89f5..a1d77150 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "numeral", "repo": "adamwdraper/Numeral-js", - "version": "1.5.3", + "version": "2.0.6", "description": "Format and manipulate numbers.", "keywords": [ "numeral", @@ -13,4 +13,4 @@ ], "scripts": [ "numeral.js" ], "main": "numeral.js" -} \ No newline at end of file +} diff --git a/component.json b/component.json index b8239485..a1d77150 100644 --- a/component.json +++ b/component.json @@ -1,7 +1,7 @@ { "name": "numeral", "repo": "adamwdraper/Numeral-js", - "version": "1.5.3", + "version": "2.0.6", "description": "Format and manipulate numbers.", "keywords": [ "numeral", diff --git a/karma-ci.conf.js b/karma-ci.conf.js new file mode 100644 index 00000000..e5af43bc --- /dev/null +++ b/karma-ci.conf.js @@ -0,0 +1,41 @@ +module.exports = function(config) { + var customLaunchers = { + sl_chrome: { + base: 'SauceLabs', + browserName: 'chrome', + version: '50', + platform: 'OS X 10.11' + }, + sl_firefox: { + base: 'SauceLabs', + browserName: 'firefox', + version: '45', + platform: 'OS X 10.11' + }, + sl_ie: { + base: 'SauceLabs', + browserName: 'internet explorer', + version: '11.103', + platform: 'Windows 10' + } + }; + + process.env.SAUCE_USERNAME = 'numeraljs'; + process.env.SAUCE_ACCESS_KEY = '5506968c-cfdc-4797-ba75-294620ad475f'; + + config.set({ + reporters: [ + 'mocha', + 'saucelabs' + ], + browserDisconnectTimeout : 10000, + browserNoActivityTimeout: 120000, + browserDisconnectTolerance : 1, + browsers: Object.keys(customLaunchers), + sauceLabs: { + testName: 'Web App Unit Tests' + }, + customLaunchers: customLaunchers, + singleRun: true + }); +}; diff --git a/languages.js b/languages.js deleted file mode 100644 index 2f502ea0..00000000 --- a/languages.js +++ /dev/null @@ -1,989 +0,0 @@ -/*! - * numeral.js language configuration - * language : belgium-dutch (be-nl) - * author : Dieter Luypaert : https://github.com/moeriki - */ -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal : ',' - }, - abbreviations: { - thousand : 'k', - million : ' mln', - billion : ' mld', - trillion : ' bln' - }, - ordinal : function (number) { - var remainder = number % 100; - return (number !== 0 && remainder <= 1 || remainder === 8 || remainder >= 20) ? 'ste' : 'de'; - }, - currency: { - symbol: '€ ' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('be-nl', language); - } -}()); -/*! - * numeral.js language configuration - * language : simplified chinese - * author : badplum : https://github.com/badplum - */ -(function () { - var language = { - delimiters: { - thousands: ',', - decimal: '.' - }, - abbreviations: { - thousand: '千', - million: '百万', - billion: '十亿', - trillion: '兆' - }, - ordinal: function (number) { - return '.'; - }, - currency: { - symbol: '¥' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('chs', language); - } -}()); - -/*! - * numeral.js language configuration - * language : czech (cs) - * author : Anatoli Papirovski : https://github.com/apapirovski - */ -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal: ',' - }, - abbreviations: { - thousand: 'tis.', - million: 'mil.', - billion: 'b', - trillion: 't' - }, - ordinal: function () { - return '.'; - }, - currency: { - symbol: 'Kč' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('cs', language); - } -}()); - -/*! - * numeral.js language configuration - * language : danish denmark (dk) - * author : Michael Storgaard : https://github.com/mstorgaard - */ -(function () { - var language = { - delimiters: { - thousands: '.', - decimal: ',' - }, - abbreviations: { - thousand: 'k', - million: 'mio', - billion: 'mia', - trillion: 'b' - }, - ordinal: function (number) { - return '.'; - }, - currency: { - symbol: 'DKK' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('da-dk', language); - } -}()); -/*! - * numeral.js language configuration - * language : German in Switzerland (de-ch) - * author : Michael Piefel : https://github.com/piefel (based on work from Marco Krage : https://github.com/sinky) - */ -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal: ',' - }, - abbreviations: { - thousand: 'k', - million: 'm', - billion: 'b', - trillion: 't' - }, - ordinal: function (number) { - return '.'; - }, - currency: { - symbol: 'CHF' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('de-ch', language); - } -}()); -/*! - * numeral.js language configuration - * language : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium - * author : Marco Krage : https://github.com/sinky - */ -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal: ',' - }, - abbreviations: { - thousand: 'k', - million: 'm', - billion: 'b', - trillion: 't' - }, - ordinal: function (number) { - return '.'; - }, - currency: { - symbol: '€' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('de', language); - } -}()); -/*! - * numeral.js language configuration - * language : english united kingdom (uk) - * author : Dan Ristic : https://github.com/dristic - */ -(function () { - var language = { - delimiters: { - thousands: ',', - decimal: '.' - }, - abbreviations: { - thousand: 'k', - million: 'm', - billion: 'b', - trillion: 't' - }, - ordinal: function (number) { - var b = number % 10; - return (~~ (number % 100 / 10) === 1) ? 'th' : - (b === 1) ? 'st' : - (b === 2) ? 'nd' : - (b === 3) ? 'rd' : 'th'; - }, - currency: { - symbol: '£' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('en-gb', language); - } -}()); -/*! - * numeral.js language configuration - * language : spanish Spain - * author : Hernan Garcia : https://github.com/hgarcia - */ -(function () { - var language = { - delimiters: { - thousands: '.', - decimal: ',' - }, - abbreviations: { - thousand: 'k', - million: 'mm', - billion: 'b', - trillion: 't' - }, - ordinal: function (number) { - var b = number % 10; - return (b === 1 || b === 3) ? 'er' : - (b === 2) ? 'do' : - (b === 7 || b === 0) ? 'mo' : - (b === 8) ? 'vo' : - (b === 9) ? 'no' : 'to'; - }, - currency: { - symbol: '€' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('es', language); - } -}()); - -/*! - * numeral.js language configuration - * language : spanish - * author : Hernan Garcia : https://github.com/hgarcia - */ -(function () { - var language = { - delimiters: { - thousands: '.', - decimal: ',' - }, - abbreviations: { - thousand: 'k', - million: 'mm', - billion: 'b', - trillion: 't' - }, - ordinal: function (number) { - var b = number % 10; - return (b === 1 || b === 3) ? 'er' : - (b === 2) ? 'do' : - (b === 7 || b === 0) ? 'mo' : - (b === 8) ? 'vo' : - (b === 9) ? 'no' : 'to'; - }, - currency: { - symbol: '$' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('es', language); - } -}()); - -/*! - * numeral.js language configuration - * language : Estonian - * author : Illimar Tambek : https://github.com/ragulka - * - * Note: in Estonian, abbreviations are always separated - * from numbers with a space - */ -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal: ',' - }, - abbreviations: { - thousand: ' tuh', - million: ' mln', - billion: ' mld', - trillion: ' trl' - }, - ordinal: function (number) { - return '.'; - }, - currency: { - symbol: '€' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('et', language); - } -}()); - -/*! - * numeral.js language configuration - * language : Finnish - * author : Sami Saada : https://github.com/samitheberber - */ -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal: ',' - }, - abbreviations: { - thousand: 'k', - million: 'M', - billion: 'G', - trillion: 'T' - }, - ordinal: function (number) { - return '.'; - }, - currency: { - symbol: '€' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('fi', language); - } -}()); - -/*! - * numeral.js language configuration - * language : french (Canada) (fr-CA) - * author : Léo Renaud-Allaire : https://github.com/renaudleo - */ -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal: ',' - }, - abbreviations: { - thousand: 'k', - million: 'M', - billion: 'G', - trillion: 'T' - }, - ordinal : function (number) { - return number === 1 ? 'er' : 'e'; - }, - currency: { - symbol: '$' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('fr-CA', language); - } -}()); -/*! - * numeral.js language configuration - * language : french (fr-ch) - * author : Adam Draper : https://github.com/adamwdraper - */ -(function () { - var language = { - delimiters: { - thousands: '\'', - decimal: '.' - }, - abbreviations: { - thousand: 'k', - million: 'm', - billion: 'b', - trillion: 't' - }, - ordinal : function (number) { - return number === 1 ? 'er' : 'e'; - }, - currency: { - symbol: 'CHF' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('fr-ch', language); - } -}()); - -/*! - * numeral.js language configuration - * language : french (fr) - * author : Adam Draper : https://github.com/adamwdraper - */ -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal: ',' - }, - abbreviations: { - thousand: 'k', - million: 'm', - billion: 'b', - trillion: 't' - }, - ordinal : function (number) { - return number === 1 ? 'er' : 'e'; - }, - currency: { - symbol: '€' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('fr', language); - } -}()); -/*! - * numeral.js language configuration - * language : Hungarian (hu) - * author : Peter Bakondy : https://github.com/pbakondy - */ -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal: ',' - }, - abbreviations: { - thousand: 'E', // ezer - million: 'M', // millió - billion: 'Mrd', // milliárd - trillion: 'T' // trillió - }, - ordinal: function (number) { - return '.'; - }, - currency: { - symbol: ' Ft' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('hu', language); - } -}()); -/*! - * numeral.js language configuration - * language : italian Italy (it) - * author : Giacomo Trombi : http://cinquepunti.it - */ -(function () { - var language = { - delimiters: { - thousands: '.', - decimal: ',' - }, - abbreviations: { - thousand: 'mila', - million: 'mil', - billion: 'b', - trillion: 't' - }, - ordinal: function (number) { - return 'º'; - }, - currency: { - symbol: '€' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('it', language); - } -}()); -/*! - * numeral.js language configuration - * language : japanese - * author : teppeis : https://github.com/teppeis - */ -(function () { - var language = { - delimiters: { - thousands: ',', - decimal: '.' - }, - abbreviations: { - thousand: '千', - million: '百万', - billion: '十億', - trillion: '兆' - }, - ordinal: function (number) { - return '.'; - }, - currency: { - symbol: '¥' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('ja', language); - } -}()); - -/*! - * numeral.js language configuration - * language : netherlands-dutch (nl-nl) - * author : Dave Clayton : https://github.com/davedx - */ -(function () { - var language = { - delimiters: { - thousands: '.', - decimal : ',' - }, - abbreviations: { - thousand : 'k', - million : 'mln', - billion : 'mrd', - trillion : 'bln' - }, - ordinal : function (number) { - var remainder = number % 100; - return (number !== 0 && remainder <= 1 || remainder === 8 || remainder >= 20) ? 'ste' : 'de'; - }, - currency: { - symbol: '€ ' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('nl-nl', language); - } -}()); -/*! - * numeral.js language configuration - * language : polish (pl) - * author : Dominik Bulaj : https://github.com/dominikbulaj - */ -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal: ',' - }, - abbreviations: { - thousand: 'tys.', - million: 'mln', - billion: 'mld', - trillion: 'bln' - }, - ordinal: function (number) { - return '.'; - }, - currency: { - symbol: 'PLN' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('pl', language); - } -}()); -/*! - * numeral.js language configuration - * language : portuguese brazil (pt-br) - * author : Ramiro Varandas Jr : https://github.com/ramirovjr - */ -(function () { - var language = { - delimiters: { - thousands: '.', - decimal: ',' - }, - abbreviations: { - thousand: 'mil', - million: 'milhões', - billion: 'b', - trillion: 't' - }, - ordinal: function (number) { - return 'º'; - }, - currency: { - symbol: 'R$' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('pt-br', language); - } -}()); -/*! - * numeral.js language configuration - * language : portuguese (pt-pt) - * author : Diogo Resende : https://github.com/dresende - */ -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal: ',' - }, - abbreviations: { - thousand: 'k', - million: 'm', - billion: 'b', - trillion: 't' - }, - ordinal : function (number) { - return 'º'; - }, - currency: { - symbol: '€' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('pt-pt', language); - } -}()); - -// numeral.js language configuration -// language : Russian for the Ukraine (ru-UA) -// author : Anatoli Papirovski : https://github.com/apapirovski -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal: ',' - }, - abbreviations: { - thousand: 'тыс.', - million: 'млн', - billion: 'b', - trillion: 't' - }, - ordinal: function () { - // not ideal, but since in Russian it can taken on - // different forms (masculine, feminine, neuter) - // this is all we can do - return '.'; - }, - currency: { - symbol: '\u20B4' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('ru-UA', language); - } -}()); - -/*! - * numeral.js language configuration - * language : russian (ru) - * author : Anatoli Papirovski : https://github.com/apapirovski - */ -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal: ',' - }, - abbreviations: { - thousand: 'тыс.', - million: 'млн', - billion: 'b', - trillion: 't' - }, - ordinal: function () { - // not ideal, but since in Russian it can taken on - // different forms (masculine, feminine, neuter) - // this is all we can do - return '.'; - }, - currency: { - symbol: 'руб.' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('ru', language); - } -}()); - -/*! - * numeral.js language configuration - * language : slovak (sk) - * author : Ahmed Al Hafoudh : http://www.freevision.sk - */ -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal: ',' - }, - abbreviations: { - thousand: 'tis.', - million: 'mil.', - billion: 'b', - trillion: 't' - }, - ordinal: function () { - return '.'; - }, - currency: { - symbol: '€' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('sk', language); - } -}()); - -/*! - * numeral.js language configuration - * language : thai (th) - * author : Sathit Jittanupat : https://github.com/jojosati - */ -(function () { - var language = { - delimiters: { - thousands: ',', - decimal: '.' - }, - abbreviations: { - thousand: 'พัน', - million: 'ล้าน', - billion: 'พันล้าน', - trillion: 'ล้านล้าน' - }, - ordinal: function (number) { - return '.'; - }, - currency: { - symbol: '฿' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('th', language); - } -}()); - -/*! - * numeral.js language configuration - * language : turkish (tr) - * author : Ecmel Ercan : https://github.com/ecmel, Erhan Gundogan : https://github.com/erhangundogan, Burak Yiğit Kaya: https://github.com/BYK - */ -(function () { - var suffixes = { - 1: '\'inci', - 5: '\'inci', - 8: '\'inci', - 70: '\'inci', - 80: '\'inci', - - 2: '\'nci', - 7: '\'nci', - 20: '\'nci', - 50: '\'nci', - - 3: '\'üncü', - 4: '\'üncü', - 100: '\'üncü', - - 6: '\'ncı', - - 9: '\'uncu', - 10: '\'uncu', - 30: '\'uncu', - - 60: '\'ıncı', - 90: '\'ıncı' - }, - language = { - delimiters: { - thousands: '.', - decimal: ',' - }, - abbreviations: { - thousand: 'bin', - million: 'milyon', - billion: 'milyar', - trillion: 'trilyon' - }, - ordinal: function (number) { - if (number === 0) { // special case for zero - return '\'ıncı'; - } - - var a = number % 10, - b = number % 100 - a, - c = number >= 100 ? 100 : null; - - return suffixes[a] || suffixes[b] || suffixes[c]; - }, - currency: { - symbol: '\u20BA' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('tr', language); - } -}()); - -// numeral.js language configuration -// language : Ukrainian for the Ukraine (uk-UA) -// author : Michael Piefel : https://github.com/piefel (with help from Tetyana Kuzmenko) -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal: ',' - }, - abbreviations: { - thousand: 'тис.', - million: 'млн', - billion: 'млрд', - trillion: 'блн' - }, - ordinal: function () { - // not ideal, but since in Ukrainian it can taken on - // different forms (masculine, feminine, neuter) - // this is all we can do - return ''; - }, - currency: { - symbol: '\u20B4' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('uk-UA', language); - } -}()); diff --git a/languages/be-nl.js b/languages/be-nl.js deleted file mode 100644 index b26d840a..00000000 --- a/languages/be-nl.js +++ /dev/null @@ -1,35 +0,0 @@ -/*! - * numeral.js language configuration - * language : belgium-dutch (be-nl) - * author : Dieter Luypaert : https://github.com/moeriki - */ -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal : ',' - }, - abbreviations: { - thousand : 'k', - million : ' mln', - billion : ' mld', - trillion : ' bln' - }, - ordinal : function (number) { - var remainder = number % 100; - return (number !== 0 && remainder <= 1 || remainder === 8 || remainder >= 20) ? 'ste' : 'de'; - }, - currency: { - symbol: '€ ' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('be-nl', language); - } -}()); \ No newline at end of file diff --git a/languages/chs.js b/languages/chs.js deleted file mode 100644 index 9c54f2f1..00000000 --- a/languages/chs.js +++ /dev/null @@ -1,34 +0,0 @@ -/*! - * numeral.js language configuration - * language : simplified chinese - * author : badplum : https://github.com/badplum - */ -(function () { - var language = { - delimiters: { - thousands: ',', - decimal: '.' - }, - abbreviations: { - thousand: '千', - million: '百万', - billion: '十亿', - trillion: '兆' - }, - ordinal: function (number) { - return '.'; - }, - currency: { - symbol: '¥' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('chs', language); - } -}()); diff --git a/languages/cs.js b/languages/cs.js deleted file mode 100644 index 248a9118..00000000 --- a/languages/cs.js +++ /dev/null @@ -1,34 +0,0 @@ -/*! - * numeral.js language configuration - * language : czech (cs) - * author : Anatoli Papirovski : https://github.com/apapirovski - */ -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal: ',' - }, - abbreviations: { - thousand: 'tis.', - million: 'mil.', - billion: 'b', - trillion: 't' - }, - ordinal: function () { - return '.'; - }, - currency: { - symbol: 'Kč' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('cs', language); - } -}()); diff --git a/languages/da-dk.js b/languages/da-dk.js deleted file mode 100644 index 27078741..00000000 --- a/languages/da-dk.js +++ /dev/null @@ -1,34 +0,0 @@ -/*! - * numeral.js language configuration - * language : danish denmark (dk) - * author : Michael Storgaard : https://github.com/mstorgaard - */ -(function () { - var language = { - delimiters: { - thousands: '.', - decimal: ',' - }, - abbreviations: { - thousand: 'k', - million: 'mio', - billion: 'mia', - trillion: 'b' - }, - ordinal: function (number) { - return '.'; - }, - currency: { - symbol: 'DKK' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('da-dk', language); - } -}()); \ No newline at end of file diff --git a/languages/de-ch.js b/languages/de-ch.js deleted file mode 100644 index 29187385..00000000 --- a/languages/de-ch.js +++ /dev/null @@ -1,34 +0,0 @@ -/*! - * numeral.js language configuration - * language : German in Switzerland (de-ch) - * author : Michael Piefel : https://github.com/piefel (based on work from Marco Krage : https://github.com/sinky) - */ -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal: ',' - }, - abbreviations: { - thousand: 'k', - million: 'm', - billion: 'b', - trillion: 't' - }, - ordinal: function (number) { - return '.'; - }, - currency: { - symbol: 'CHF' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('de-ch', language); - } -}()); \ No newline at end of file diff --git a/languages/de.js b/languages/de.js deleted file mode 100644 index d6bd5f07..00000000 --- a/languages/de.js +++ /dev/null @@ -1,34 +0,0 @@ -/*! - * numeral.js language configuration - * language : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium - * author : Marco Krage : https://github.com/sinky - */ -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal: ',' - }, - abbreviations: { - thousand: 'k', - million: 'm', - billion: 'b', - trillion: 't' - }, - ordinal: function (number) { - return '.'; - }, - currency: { - symbol: '€' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('de', language); - } -}()); \ No newline at end of file diff --git a/languages/es.js b/languages/es.js deleted file mode 100644 index b078fe55..00000000 --- a/languages/es.js +++ /dev/null @@ -1,39 +0,0 @@ -/*! - * numeral.js language configuration - * language : spanish - * author : Hernan Garcia : https://github.com/hgarcia - */ -(function () { - var language = { - delimiters: { - thousands: '.', - decimal: ',' - }, - abbreviations: { - thousand: 'k', - million: 'mm', - billion: 'b', - trillion: 't' - }, - ordinal: function (number) { - var b = number % 10; - return (b === 1 || b === 3) ? 'er' : - (b === 2) ? 'do' : - (b === 7 || b === 0) ? 'mo' : - (b === 8) ? 'vo' : - (b === 9) ? 'no' : 'to'; - }, - currency: { - symbol: '$' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('es', language); - } -}()); diff --git a/languages/et.js b/languages/et.js deleted file mode 100644 index f45dd7de..00000000 --- a/languages/et.js +++ /dev/null @@ -1,37 +0,0 @@ -/*! - * numeral.js language configuration - * language : Estonian - * author : Illimar Tambek : https://github.com/ragulka - * - * Note: in Estonian, abbreviations are always separated - * from numbers with a space - */ -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal: ',' - }, - abbreviations: { - thousand: ' tuh', - million: ' mln', - billion: ' mld', - trillion: ' trl' - }, - ordinal: function (number) { - return '.'; - }, - currency: { - symbol: '€' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('et', language); - } -}()); diff --git a/languages/fi.js b/languages/fi.js deleted file mode 100644 index 2e247431..00000000 --- a/languages/fi.js +++ /dev/null @@ -1,34 +0,0 @@ -/*! - * numeral.js language configuration - * language : Finnish - * author : Sami Saada : https://github.com/samitheberber - */ -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal: ',' - }, - abbreviations: { - thousand: 'k', - million: 'M', - billion: 'G', - trillion: 'T' - }, - ordinal: function (number) { - return '.'; - }, - currency: { - symbol: '€' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('fi', language); - } -}()); diff --git a/languages/fr-CA.js b/languages/fr-CA.js deleted file mode 100644 index ea1c9a50..00000000 --- a/languages/fr-CA.js +++ /dev/null @@ -1,34 +0,0 @@ -/*! - * numeral.js language configuration - * language : french (Canada) (fr-CA) - * author : Léo Renaud-Allaire : https://github.com/renaudleo - */ -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal: ',' - }, - abbreviations: { - thousand: 'k', - million: 'M', - billion: 'G', - trillion: 'T' - }, - ordinal : function (number) { - return number === 1 ? 'er' : 'e'; - }, - currency: { - symbol: '$' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('fr-CA', language); - } -}()); \ No newline at end of file diff --git a/languages/fr-ch.js b/languages/fr-ch.js deleted file mode 100644 index 64ffbd22..00000000 --- a/languages/fr-ch.js +++ /dev/null @@ -1,34 +0,0 @@ -/*! - * numeral.js language configuration - * language : french (fr-ch) - * author : Adam Draper : https://github.com/adamwdraper - */ -(function () { - var language = { - delimiters: { - thousands: '\'', - decimal: '.' - }, - abbreviations: { - thousand: 'k', - million: 'm', - billion: 'b', - trillion: 't' - }, - ordinal : function (number) { - return number === 1 ? 'er' : 'e'; - }, - currency: { - symbol: 'CHF' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('fr-ch', language); - } -}()); diff --git a/languages/fr.js b/languages/fr.js deleted file mode 100644 index 960defad..00000000 --- a/languages/fr.js +++ /dev/null @@ -1,34 +0,0 @@ -/*! - * numeral.js language configuration - * language : french (fr) - * author : Adam Draper : https://github.com/adamwdraper - */ -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal: ',' - }, - abbreviations: { - thousand: 'k', - million: 'm', - billion: 'b', - trillion: 't' - }, - ordinal : function (number) { - return number === 1 ? 'er' : 'e'; - }, - currency: { - symbol: '€' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('fr', language); - } -}()); \ No newline at end of file diff --git a/languages/hu.js b/languages/hu.js deleted file mode 100644 index 9710ac23..00000000 --- a/languages/hu.js +++ /dev/null @@ -1,34 +0,0 @@ -/*! - * numeral.js language configuration - * language : Hungarian (hu) - * author : Peter Bakondy : https://github.com/pbakondy - */ -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal: ',' - }, - abbreviations: { - thousand: 'E', // ezer - million: 'M', // millió - billion: 'Mrd', // milliárd - trillion: 'T' // trillió - }, - ordinal: function (number) { - return '.'; - }, - currency: { - symbol: ' Ft' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('hu', language); - } -}()); \ No newline at end of file diff --git a/languages/it.js b/languages/it.js deleted file mode 100644 index 5bc1f9c3..00000000 --- a/languages/it.js +++ /dev/null @@ -1,34 +0,0 @@ -/*! - * numeral.js language configuration - * language : italian Italy (it) - * author : Giacomo Trombi : http://cinquepunti.it - */ -(function () { - var language = { - delimiters: { - thousands: '.', - decimal: ',' - }, - abbreviations: { - thousand: 'mila', - million: 'mil', - billion: 'b', - trillion: 't' - }, - ordinal: function (number) { - return 'º'; - }, - currency: { - symbol: '€' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('it', language); - } -}()); \ No newline at end of file diff --git a/languages/ja.js b/languages/ja.js deleted file mode 100644 index d0816b27..00000000 --- a/languages/ja.js +++ /dev/null @@ -1,34 +0,0 @@ -/*! - * numeral.js language configuration - * language : japanese - * author : teppeis : https://github.com/teppeis - */ -(function () { - var language = { - delimiters: { - thousands: ',', - decimal: '.' - }, - abbreviations: { - thousand: '千', - million: '百万', - billion: '十億', - trillion: '兆' - }, - ordinal: function (number) { - return '.'; - }, - currency: { - symbol: '¥' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('ja', language); - } -}()); diff --git a/languages/pl.js b/languages/pl.js deleted file mode 100644 index 5cb6056e..00000000 --- a/languages/pl.js +++ /dev/null @@ -1,34 +0,0 @@ -/*! - * numeral.js language configuration - * language : polish (pl) - * author : Dominik Bulaj : https://github.com/dominikbulaj - */ -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal: ',' - }, - abbreviations: { - thousand: 'tys.', - million: 'mln', - billion: 'mld', - trillion: 'bln' - }, - ordinal: function (number) { - return '.'; - }, - currency: { - symbol: 'PLN' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('pl', language); - } -}()); \ No newline at end of file diff --git a/languages/pt-br.js b/languages/pt-br.js deleted file mode 100644 index 51ab7dab..00000000 --- a/languages/pt-br.js +++ /dev/null @@ -1,34 +0,0 @@ -/*! - * numeral.js language configuration - * language : portuguese brazil (pt-br) - * author : Ramiro Varandas Jr : https://github.com/ramirovjr - */ -(function () { - var language = { - delimiters: { - thousands: '.', - decimal: ',' - }, - abbreviations: { - thousand: 'mil', - million: 'milhões', - billion: 'b', - trillion: 't' - }, - ordinal: function (number) { - return 'º'; - }, - currency: { - symbol: 'R$' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('pt-br', language); - } -}()); \ No newline at end of file diff --git a/languages/pt-pt.js b/languages/pt-pt.js deleted file mode 100644 index cce9a271..00000000 --- a/languages/pt-pt.js +++ /dev/null @@ -1,34 +0,0 @@ -/*! - * numeral.js language configuration - * language : portuguese (pt-pt) - * author : Diogo Resende : https://github.com/dresende - */ -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal: ',' - }, - abbreviations: { - thousand: 'k', - million: 'm', - billion: 'b', - trillion: 't' - }, - ordinal : function (number) { - return 'º'; - }, - currency: { - symbol: '€' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('pt-pt', language); - } -}()); diff --git a/languages/ru-UA.js b/languages/ru-UA.js deleted file mode 100644 index 37a1c046..00000000 --- a/languages/ru-UA.js +++ /dev/null @@ -1,35 +0,0 @@ -// numeral.js language configuration -// language : Russian for the Ukraine (ru-UA) -// author : Anatoli Papirovski : https://github.com/apapirovski -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal: ',' - }, - abbreviations: { - thousand: 'тыс.', - million: 'млн', - billion: 'b', - trillion: 't' - }, - ordinal: function () { - // not ideal, but since in Russian it can taken on - // different forms (masculine, feminine, neuter) - // this is all we can do - return '.'; - }, - currency: { - symbol: '\u20B4' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('ru-UA', language); - } -}()); diff --git a/languages/ru.js b/languages/ru.js deleted file mode 100644 index 14d9e83a..00000000 --- a/languages/ru.js +++ /dev/null @@ -1,37 +0,0 @@ -/*! - * numeral.js language configuration - * language : russian (ru) - * author : Anatoli Papirovski : https://github.com/apapirovski - */ -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal: ',' - }, - abbreviations: { - thousand: 'тыс.', - million: 'млн', - billion: 'b', - trillion: 't' - }, - ordinal: function () { - // not ideal, but since in Russian it can taken on - // different forms (masculine, feminine, neuter) - // this is all we can do - return '.'; - }, - currency: { - symbol: 'руб.' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('ru', language); - } -}()); diff --git a/languages/sk.js b/languages/sk.js deleted file mode 100644 index ac48faf7..00000000 --- a/languages/sk.js +++ /dev/null @@ -1,34 +0,0 @@ -/*! - * numeral.js language configuration - * language : slovak (sk) - * author : Ahmed Al Hafoudh : http://www.freevision.sk - */ -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal: ',' - }, - abbreviations: { - thousand: 'tis.', - million: 'mil.', - billion: 'b', - trillion: 't' - }, - ordinal: function () { - return '.'; - }, - currency: { - symbol: '€' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('sk', language); - } -}()); diff --git a/languages/th.js b/languages/th.js deleted file mode 100644 index ca73c7d7..00000000 --- a/languages/th.js +++ /dev/null @@ -1,34 +0,0 @@ -/*! - * numeral.js language configuration - * language : thai (th) - * author : Sathit Jittanupat : https://github.com/jojosati - */ -(function () { - var language = { - delimiters: { - thousands: ',', - decimal: '.' - }, - abbreviations: { - thousand: 'พัน', - million: 'ล้าน', - billion: 'พันล้าน', - trillion: 'ล้านล้าน' - }, - ordinal: function (number) { - return '.'; - }, - currency: { - symbol: '฿' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('th', language); - } -}()); diff --git a/languages/tr.js b/languages/tr.js deleted file mode 100644 index 79b9a498..00000000 --- a/languages/tr.js +++ /dev/null @@ -1,67 +0,0 @@ -/*! - * numeral.js language configuration - * language : turkish (tr) - * author : Ecmel Ercan : https://github.com/ecmel, Erhan Gundogan : https://github.com/erhangundogan, Burak Yiğit Kaya: https://github.com/BYK - */ -(function () { - var suffixes = { - 1: '\'inci', - 5: '\'inci', - 8: '\'inci', - 70: '\'inci', - 80: '\'inci', - - 2: '\'nci', - 7: '\'nci', - 20: '\'nci', - 50: '\'nci', - - 3: '\'üncü', - 4: '\'üncü', - 100: '\'üncü', - - 6: '\'ncı', - - 9: '\'uncu', - 10: '\'uncu', - 30: '\'uncu', - - 60: '\'ıncı', - 90: '\'ıncı' - }, - language = { - delimiters: { - thousands: '.', - decimal: ',' - }, - abbreviations: { - thousand: 'bin', - million: 'milyon', - billion: 'milyar', - trillion: 'trilyon' - }, - ordinal: function (number) { - if (number === 0) { // special case for zero - return '\'ıncı'; - } - - var a = number % 10, - b = number % 100 - a, - c = number >= 100 ? 100 : null; - - return suffixes[a] || suffixes[b] || suffixes[c]; - }, - currency: { - symbol: '\u20BA' - } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('tr', language); - } -}()); diff --git a/locales.js b/locales.js new file mode 100644 index 00000000..1f89d5a2 --- /dev/null +++ b/locales.js @@ -0,0 +1,846 @@ +/*! @preserve + * numeral.js + * locales : 2.0.6 + * license : MIT + * http://adamwdraper.github.com/Numeral-js/ + */ + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('./numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + +(function() { + numeral.register('locale', 'bg', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { // I found these here http://www.unicode.org/cldr/charts/28/verify/numbers/bg.html + thousand: 'хил', + million: 'млн', + billion: 'млрд', + trillion: 'трлн' + }, + ordinal: function (number) { + // google translate suggests: + // 1st=1-ви; 2nd=2-ри; 7th=7-ми; + // 8th=8-ми and many others end with -ти + // for example 3rd=3-ти + // However since I've seen suggestions that in + // Bulgarian the ordinal can be taken in + // different forms (masculine, feminine, neuter) + // I've opted to wimp out on commiting that to code + return ''; + }, + currency: { + symbol: 'лв' + } + }); +})(); + + +(function() { + + numeral.register('locale', 'chs', { + delimiters: { + thousands: ',', + decimal: '.' + }, + abbreviations: { + thousand: '千', + million: '百万', + billion: '十亿', + trillion: '兆' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: '¥' + } + }); +})(); + + +(function() { + numeral.register('locale', 'cs', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'tis.', + million: 'mil.', + billion: 'b', + trillion: 't' + }, + ordinal: function () { + return '.'; + }, + currency: { + symbol: 'Kč' + } + }); +})(); + + +(function() { + numeral.register('locale', 'da-dk', { + delimiters: { + thousands: '.', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'mio', + billion: 'mia', + trillion: 'b' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: 'DKK' + } + }); +})(); + + +(function() { + numeral.register('locale', 'de-ch', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: 'CHF' + } + }); +})(); + + +(function() { + numeral.register('locale', 'de', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: '€' + } + }); +})(); + + +(function() { + numeral.register('locale', 'en-au', { + delimiters: { + thousands: ',', + decimal: '.' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + var b = number % 10; + return (~~ (number % 100 / 10) === 1) ? 'th' : + (b === 1) ? 'st' : + (b === 2) ? 'nd' : + (b === 3) ? 'rd' : 'th'; + }, + currency: { + symbol: '$' + } + }); +})(); + + +(function() { + numeral.register('locale', 'en-gb', { + delimiters: { + thousands: ',', + decimal: '.' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + var b = number % 10; + return (~~ (number % 100 / 10) === 1) ? 'th' : + (b === 1) ? 'st' : + (b === 2) ? 'nd' : + (b === 3) ? 'rd' : 'th'; + }, + currency: { + symbol: '£' + } + }); +})(); + + +(function() { + numeral.register('locale', 'en-za', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + var b = number % 10; + return (~~ (number % 100 / 10) === 1) ? 'th' : + (b === 1) ? 'st' : + (b === 2) ? 'nd' : + (b === 3) ? 'rd' : 'th'; + }, + currency: { + symbol: 'R' + } + }); +})(); + + +(function() { + numeral.register('locale', 'es-es', { + delimiters: { + thousands: '.', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'mm', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + var b = number % 10; + return (b === 1 || b === 3) ? 'er' : + (b === 2) ? 'do' : + (b === 7 || b === 0) ? 'mo' : + (b === 8) ? 'vo' : + (b === 9) ? 'no' : 'to'; + }, + currency: { + symbol: '€' + } + }); +})(); + + +(function() { + numeral.register('locale', 'es', { + delimiters: { + thousands: '.', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'mm', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + var b = number % 10; + return (b === 1 || b === 3) ? 'er' : + (b === 2) ? 'do' : + (b === 7 || b === 0) ? 'mo' : + (b === 8) ? 'vo' : + (b === 9) ? 'no' : 'to'; + }, + currency: { + symbol: '$' + } + }); +})(); + + +(function() { + numeral.register('locale', 'et', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: ' tuh', + million: ' mln', + billion: ' mld', + trillion: ' trl' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: '€' + } + }); +})(); + + +(function() { + numeral.register('locale', 'fi', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'M', + billion: 'G', + trillion: 'T' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: '€' + } + }); +})(); + + +(function() { + numeral.register('locale', 'fr-ca', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'M', + billion: 'G', + trillion: 'T' + }, + ordinal : function (number) { + return number === 1 ? 'er' : 'e'; + }, + currency: { + symbol: '$' + } + }); +})(); + + +(function() { + numeral.register('locale', 'fr-ch', { + delimiters: { + thousands: '\'', + decimal: '.' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal : function (number) { + return number === 1 ? 'er' : 'e'; + }, + currency: { + symbol: 'CHF' + } + }); +})(); + + +(function() { + numeral.register('locale', 'fr', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal : function (number) { + return number === 1 ? 'er' : 'e'; + }, + currency: { + symbol: '€' + } + }); +})(); + + +(function() { + numeral.register('locale', 'hu', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'E', // ezer + million: 'M', // millió + billion: 'Mrd', // milliárd + trillion: 'T' // trillió + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: ' Ft' + } + }); +})(); + + +(function() { + numeral.register('locale', 'it', { + delimiters: { + thousands: '.', + decimal: ',' + }, + abbreviations: { + thousand: 'mila', + million: 'mil', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + return 'º'; + }, + currency: { + symbol: '€' + } + }); +})(); + + +(function() { + numeral.register('locale', 'ja', { + delimiters: { + thousands: ',', + decimal: '.' + }, + abbreviations: { + thousand: '千', + million: '百万', + billion: '十億', + trillion: '兆' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: '¥' + } + }); +})(); + + +(function() { + numeral.register('locale', 'lv', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: ' tūkst.', + million: ' milj.', + billion: ' mljrd.', + trillion: ' trilj.' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: '€' + } + }); +})(); + + +(function() { + numeral.register('locale', 'nl-be', { + delimiters: { + thousands: ' ', + decimal : ',' + }, + abbreviations: { + thousand : 'k', + million : ' mln', + billion : ' mld', + trillion : ' bln' + }, + ordinal : function (number) { + var remainder = number % 100; + + return (number !== 0 && remainder <= 1 || remainder === 8 || remainder >= 20) ? 'ste' : 'de'; + }, + currency: { + symbol: '€ ' + } + }); +})(); + + +(function() { + numeral.register('locale', 'nl-nl', { + delimiters: { + thousands: '.', + decimal : ',' + }, + abbreviations: { + thousand : 'k', + million : 'mln', + billion : 'mrd', + trillion : 'bln' + }, + ordinal : function (number) { + var remainder = number % 100; + return (number !== 0 && remainder <= 1 || remainder === 8 || remainder >= 20) ? 'ste' : 'de'; + }, + currency: { + symbol: '€ ' + } + }); +})(); + + +(function() { + numeral.register('locale', 'no', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: 'kr' + } + }); +})(); + + +(function() { + numeral.register('locale', 'pl', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'tys.', + million: 'mln', + billion: 'mld', + trillion: 'bln' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: 'PLN' + } + }); +})(); + + +(function() { + numeral.register('locale', 'pt-br', { + delimiters: { + thousands: '.', + decimal: ',' + }, + abbreviations: { + thousand: 'mil', + million: 'milhões', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + return 'º'; + }, + currency: { + symbol: 'R$' + } + }); +})(); + + +(function() { + numeral.register('locale', 'pt-pt', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal : function (number) { + return 'º'; + }, + currency: { + symbol: '€' + } + }); +})(); + + +(function() { + numeral.register('locale', 'ru-ua', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'тыс.', + million: 'млн', + billion: 'b', + trillion: 't' + }, + ordinal: function () { + // not ideal, but since in Russian it can taken on + // different forms (masculine, feminine, neuter) + // this is all we can do + return '.'; + }, + currency: { + symbol: '\u20B4' + } + }); +})(); + + +(function() { + numeral.register('locale', 'ru', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'тыс.', + million: 'млн.', + billion: 'млрд.', + trillion: 'трлн.' + }, + ordinal: function () { + // not ideal, but since in Russian it can taken on + // different forms (masculine, feminine, neuter) + // this is all we can do + return '.'; + }, + currency: { + symbol: 'руб.' + } + }); +})(); + + +(function() { + numeral.register('locale', 'sk', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'tis.', + million: 'mil.', + billion: 'b', + trillion: 't' + }, + ordinal: function () { + return '.'; + }, + currency: { + symbol: '€' + } + }); +})(); + + +(function() { + numeral.register('locale', 'sl', { + delimiters: { + thousands: '.', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'mio', + billion: 'mrd', + trillion: 'trilijon' + }, + ordinal: function () { + return '.'; + }, + currency: { + symbol: '€' + } + }); +})(); + + +(function() { + + + numeral.register('locale', 'th', { + delimiters: { + thousands: ',', + decimal: '.' + }, + abbreviations: { + thousand: 'พัน', + million: 'ล้าน', + billion: 'พันล้าน', + trillion: 'ล้านล้าน' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: '฿' + } + }); +})(); + + +(function() { + var suffixes = { + 1: '\'inci', + 5: '\'inci', + 8: '\'inci', + 70: '\'inci', + 80: '\'inci', + + 2: '\'nci', + 7: '\'nci', + 20: '\'nci', + 50: '\'nci', + + 3: '\'üncü', + 4: '\'üncü', + 100: '\'üncü', + + 6: '\'ncı', + + 9: '\'uncu', + 10: '\'uncu', + 30: '\'uncu', + + 60: '\'ıncı', + 90: '\'ıncı' + }; + + numeral.register('locale', 'tr', { + delimiters: { + thousands: '.', + decimal: ',' + }, + abbreviations: { + thousand: 'bin', + million: 'milyon', + billion: 'milyar', + trillion: 'trilyon' + }, + ordinal: function (number) { + if (number === 0) { // special case for zero + return '\'ıncı'; + } + + var a = number % 10, + b = number % 100 - a, + c = number >= 100 ? 100 : null; + + return suffixes[a] || suffixes[b] || suffixes[c]; + }, + currency: { + symbol: '\u20BA' + } + }); +})(); + + +(function() { + numeral.register('locale', 'uk-ua', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'тис.', + million: 'млн', + billion: 'млрд', + trillion: 'блн' + }, + ordinal: function () { + // not ideal, but since in Ukrainian it can taken on + // different forms (masculine, feminine, neuter) + // this is all we can do + return ''; + }, + currency: { + symbol: '\u20B4' + } + }); +})(); + + +(function() { + + numeral.register('locale', 'vi', { + delimiters: { + thousands: '.', + decimal: ',' + }, + abbreviations: { + thousand: ' nghìn', + million: ' triệu', + billion: ' tỷ', + trillion: ' nghìn tỷ' + }, + ordinal: function () { + return '.'; + }, + currency: { + symbol: '₫' + } + }); +})(); + + +})); diff --git a/locales/bg.js b/locales/bg.js new file mode 100644 index 00000000..ef71941c --- /dev/null +++ b/locales/bg.js @@ -0,0 +1,40 @@ +// numeral.js locale configuration +// locale : Bulgarian +// author : Don Vince : https://github.com/donvince/ + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'bg', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { // I found these here http://www.unicode.org/cldr/charts/28/verify/numbers/bg.html + thousand: 'хил', + million: 'млн', + billion: 'млрд', + trillion: 'трлн' + }, + ordinal: function (number) { + // google translate suggests: + // 1st=1-ви; 2nd=2-ри; 7th=7-ми; + // 8th=8-ми and many others end with -ти + // for example 3rd=3-ти + // However since I've seen suggestions that in + // Bulgarian the ordinal can be taken in + // different forms (masculine, feminine, neuter) + // I've opted to wimp out on commiting that to code + return ''; + }, + currency: { + symbol: 'лв' + } + }); +})); diff --git a/locales/chs.js b/locales/chs.js new file mode 100644 index 00000000..1bcc9462 --- /dev/null +++ b/locales/chs.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : simplified chinese (chs) +// author : badplum : https://github.com/badplum + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'chs', { + delimiters: { + thousands: ',', + decimal: '.' + }, + abbreviations: { + thousand: '千', + million: '百万', + billion: '十亿', + trillion: '兆' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: '¥' + } + }); +})); diff --git a/locales/cs.js b/locales/cs.js new file mode 100644 index 00000000..316051f2 --- /dev/null +++ b/locales/cs.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : czech (cs) +// author : Anatoli Papirovski : https://github.com/apapirovski + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'cs', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'tis.', + million: 'mil.', + billion: 'b', + trillion: 't' + }, + ordinal: function () { + return '.'; + }, + currency: { + symbol: 'Kč' + } + }); +})); diff --git a/locales/da-dk.js b/locales/da-dk.js new file mode 100644 index 00000000..c21e5a78 --- /dev/null +++ b/locales/da-dk.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : danish denmark (dk) +// author : Michael Storgaard : https://github.com/mstorgaard + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'da-dk', { + delimiters: { + thousands: '.', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'mio', + billion: 'mia', + trillion: 'b' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: 'DKK' + } + }); +})); diff --git a/locales/de-ch.js b/locales/de-ch.js new file mode 100644 index 00000000..5921e46c --- /dev/null +++ b/locales/de-ch.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : German in Switzerland (de-ch) +// author : Michael Piefel : https://github.com/piefel (based on work from Marco Krage : https://github.com/sinky) + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'de-ch', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: 'CHF' + } + }); +})); diff --git a/locales/de.js b/locales/de.js new file mode 100644 index 00000000..87f87880 --- /dev/null +++ b/locales/de.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium +// author : Marco Krage : https://github.com/sinky + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'de', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: '€' + } + }); +})); diff --git a/locales/en-au.js b/locales/en-au.js new file mode 100644 index 00000000..6202c842 --- /dev/null +++ b/locales/en-au.js @@ -0,0 +1,36 @@ +// numeral.js locale configuration +// locale : English Australia +// author : Don Vince : https://github.com/donvince/ + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'en-au', { + delimiters: { + thousands: ',', + decimal: '.' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + var b = number % 10; + return (~~ (number % 100 / 10) === 1) ? 'th' : + (b === 1) ? 'st' : + (b === 2) ? 'nd' : + (b === 3) ? 'rd' : 'th'; + }, + currency: { + symbol: '$' + } + }); +})); diff --git a/languages/en-gb.js b/locales/en-gb.js similarity index 52% rename from languages/en-gb.js rename to locales/en-gb.js index 5b99c7a8..a51190eb 100644 --- a/languages/en-gb.js +++ b/locales/en-gb.js @@ -1,10 +1,17 @@ -/*! - * numeral.js language configuration - * language : english united kingdom (uk) - * author : Dan Ristic : https://github.com/dristic - */ -(function () { - var language = { +// numeral.js locale configuration +// locale : english united kingdom (uk) +// author : Dan Ristic : https://github.com/dristic + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'en-gb', { delimiters: { thousands: ',', decimal: '.' @@ -25,14 +32,5 @@ currency: { symbol: '£' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('en-gb', language); - } -}()); \ No newline at end of file + }); +})); diff --git a/locales/en-za.js b/locales/en-za.js new file mode 100644 index 00000000..8417268d --- /dev/null +++ b/locales/en-za.js @@ -0,0 +1,36 @@ +// numeral.js locale configuration +// locale : english south africa (uk) +// author : Etienne Boshoff : etienne@zailab.com + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'en-za', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + var b = number % 10; + return (~~ (number % 100 / 10) === 1) ? 'th' : + (b === 1) ? 'st' : + (b === 2) ? 'nd' : + (b === 3) ? 'rd' : 'th'; + }, + currency: { + symbol: 'R' + } + }); +})); diff --git a/languages/es-ES.js b/locales/es-es.js similarity index 55% rename from languages/es-ES.js rename to locales/es-es.js index a62abc07..31e7de5b 100644 --- a/languages/es-ES.js +++ b/locales/es-es.js @@ -1,10 +1,17 @@ -/*! - * numeral.js language configuration - * language : spanish Spain - * author : Hernan Garcia : https://github.com/hgarcia - */ -(function () { - var language = { +// numeral.js locale configuration +// locale : spanish Spain +// author : Hernan Garcia : https://github.com/hgarcia + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'es-es', { delimiters: { thousands: '.', decimal: ',' @@ -26,14 +33,5 @@ currency: { symbol: '€' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('es', language); - } -}()); + }); +})); diff --git a/locales/es.js b/locales/es.js new file mode 100644 index 00000000..7ca71950 --- /dev/null +++ b/locales/es.js @@ -0,0 +1,37 @@ +// numeral.js locale configuration +// locale : spanish +// author : Hernan Garcia : https://github.com/hgarcia + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'es', { + delimiters: { + thousands: '.', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'mm', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + var b = number % 10; + return (b === 1 || b === 3) ? 'er' : + (b === 2) ? 'do' : + (b === 7 || b === 0) ? 'mo' : + (b === 8) ? 'vo' : + (b === 9) ? 'no' : 'to'; + }, + currency: { + symbol: '$' + } + }); +})); diff --git a/locales/et.js b/locales/et.js new file mode 100644 index 00000000..f8269e12 --- /dev/null +++ b/locales/et.js @@ -0,0 +1,33 @@ +// numeral.js locale configuration +// locale : Estonian +// author : Illimar Tambek : https://github.com/ragulka +// Note: in Estonian, abbreviations are always separated from numbers with a space + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'et', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: ' tuh', + million: ' mln', + billion: ' mld', + trillion: ' trl' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: '€' + } + }); +})); diff --git a/locales/fi.js b/locales/fi.js new file mode 100644 index 00000000..25eaa7fd --- /dev/null +++ b/locales/fi.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : Finnish +// author : Sami Saada : https://github.com/samitheberber + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'fi', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'M', + billion: 'G', + trillion: 'T' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: '€' + } + }); +})); diff --git a/locales/fr-ca.js b/locales/fr-ca.js new file mode 100644 index 00000000..f8dd2061 --- /dev/null +++ b/locales/fr-ca.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : french (Canada) (fr-ca) +// author : Léo Renaud-Allaire : https://github.com/renaudleo + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'fr-ca', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'M', + billion: 'G', + trillion: 'T' + }, + ordinal : function (number) { + return number === 1 ? 'er' : 'e'; + }, + currency: { + symbol: '$' + } + }); +})); diff --git a/locales/fr-ch.js b/locales/fr-ch.js new file mode 100644 index 00000000..ea29b39c --- /dev/null +++ b/locales/fr-ch.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : french (fr-ch) +// author : Adam Draper : https://github.com/adamwdraper + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'fr-ch', { + delimiters: { + thousands: '\'', + decimal: '.' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal : function (number) { + return number === 1 ? 'er' : 'e'; + }, + currency: { + symbol: 'CHF' + } + }); +})); diff --git a/locales/fr.js b/locales/fr.js new file mode 100644 index 00000000..5ddc609d --- /dev/null +++ b/locales/fr.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : french (fr) +// author : Adam Draper : https://github.com/adamwdraper + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'fr', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal : function (number) { + return number === 1 ? 'er' : 'e'; + }, + currency: { + symbol: '€' + } + }); +})); diff --git a/locales/hu.js b/locales/hu.js new file mode 100644 index 00000000..a3d7638a --- /dev/null +++ b/locales/hu.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : Hungarian (hu) +// author : Peter Bakondy : https://github.com/pbakondy + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'hu', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'E', // ezer + million: 'M', // millió + billion: 'Mrd', // milliárd + trillion: 'T' // trillió + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: ' Ft' + } + }); +})); diff --git a/locales/it.js b/locales/it.js new file mode 100644 index 00000000..a5d3406e --- /dev/null +++ b/locales/it.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : italian Italy (it) +// author : Giacomo Trombi : http://cinquepunti.it + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'it', { + delimiters: { + thousands: '.', + decimal: ',' + }, + abbreviations: { + thousand: 'mila', + million: 'mil', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + return 'º'; + }, + currency: { + symbol: '€' + } + }); +})); diff --git a/locales/ja.js b/locales/ja.js new file mode 100644 index 00000000..bb6c8a1e --- /dev/null +++ b/locales/ja.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : japanese +// author : teppeis : https://github.com/teppeis + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'ja', { + delimiters: { + thousands: ',', + decimal: '.' + }, + abbreviations: { + thousand: '千', + million: '百万', + billion: '十億', + trillion: '兆' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: '¥' + } + }); +})); diff --git a/locales/lv.js b/locales/lv.js new file mode 100644 index 00000000..cc46c0e7 --- /dev/null +++ b/locales/lv.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : Latvian (lv) +// author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'lv', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: ' tūkst.', + million: ' milj.', + billion: ' mljrd.', + trillion: ' trilj.' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: '€' + } + }); +})); diff --git a/locales/nl-be.js b/locales/nl-be.js new file mode 100644 index 00000000..6b561904 --- /dev/null +++ b/locales/nl-be.js @@ -0,0 +1,35 @@ +// numeral.js locale configuration +// locale : dutch-belgium (nl-be) +// author : Dieter Luypaert : https://github.com/moeriki +// corrected : Olivier Godefroy : https://github.com/godefroyo + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'nl-be', { + delimiters: { + thousands: ' ', + decimal : ',' + }, + abbreviations: { + thousand : 'k', + million : ' mln', + billion : ' mld', + trillion : ' bln' + }, + ordinal : function (number) { + var remainder = number % 100; + + return (number !== 0 && remainder <= 1 || remainder === 8 || remainder >= 20) ? 'ste' : 'de'; + }, + currency: { + symbol: '€ ' + } + }); +})); diff --git a/languages/nl-nl.js b/locales/nl-nl.js similarity index 50% rename from languages/nl-nl.js rename to locales/nl-nl.js index ab577867..00f70f7c 100644 --- a/languages/nl-nl.js +++ b/locales/nl-nl.js @@ -1,10 +1,17 @@ -/*! - * numeral.js language configuration - * language : netherlands-dutch (nl-nl) - * author : Dave Clayton : https://github.com/davedx - */ -(function () { - var language = { +// numeral.js locale configuration +// locale : netherlands-dutch (nl-nl) +// author : Dave Clayton : https://github.com/davedx + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'nl-nl', { delimiters: { thousands: '.', decimal : ',' @@ -22,14 +29,5 @@ currency: { symbol: '€ ' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('nl-nl', language); - } -}()); \ No newline at end of file + }); +})); diff --git a/locales/no.js b/locales/no.js new file mode 100644 index 00000000..2a2b06c8 --- /dev/null +++ b/locales/no.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : norwegian (bokmål) +// author : Ove Andersen : https://github.com/azzlack + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'no', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: 'kr' + } + }); +})); diff --git a/locales/pl.js b/locales/pl.js new file mode 100644 index 00000000..b336c090 --- /dev/null +++ b/locales/pl.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : polish (pl) +// author : Dominik Bulaj : https://github.com/dominikbulaj + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'pl', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'tys.', + million: 'mln', + billion: 'mld', + trillion: 'bln' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: 'PLN' + } + }); +})); diff --git a/locales/pt-br.js b/locales/pt-br.js new file mode 100644 index 00000000..94d384b3 --- /dev/null +++ b/locales/pt-br.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : portuguese brazil (pt-br) +// author : Ramiro Varandas Jr : https://github.com/ramirovjr + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'pt-br', { + delimiters: { + thousands: '.', + decimal: ',' + }, + abbreviations: { + thousand: 'mil', + million: 'milhões', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + return 'º'; + }, + currency: { + symbol: 'R$' + } + }); +})); diff --git a/locales/pt-pt.js b/locales/pt-pt.js new file mode 100644 index 00000000..9bf59770 --- /dev/null +++ b/locales/pt-pt.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : portuguese (pt-pt) +// author : Diogo Resende : https://github.com/dresende + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'pt-pt', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal : function (number) { + return 'º'; + }, + currency: { + symbol: '€' + } + }); +})); diff --git a/locales/ru-ua.js b/locales/ru-ua.js new file mode 100644 index 00000000..798f94f4 --- /dev/null +++ b/locales/ru-ua.js @@ -0,0 +1,35 @@ +// numeral.js locale configuration +// locale : Russian for the Ukraine (ru-ua) +// author : Anatoli Papirovski : https://github.com/apapirovski + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'ru-ua', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'тыс.', + million: 'млн', + billion: 'b', + trillion: 't' + }, + ordinal: function () { + // not ideal, but since in Russian it can taken on + // different forms (masculine, feminine, neuter) + // this is all we can do + return '.'; + }, + currency: { + symbol: '\u20B4' + } + }); +})); diff --git a/locales/ru.js b/locales/ru.js new file mode 100644 index 00000000..34dfb7f9 --- /dev/null +++ b/locales/ru.js @@ -0,0 +1,35 @@ +// numeral.js locale configuration +// locale : russian (ru) +// author : Anatoli Papirovski : https://github.com/apapirovski + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'ru', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'тыс.', + million: 'млн.', + billion: 'млрд.', + trillion: 'трлн.' + }, + ordinal: function () { + // not ideal, but since in Russian it can taken on + // different forms (masculine, feminine, neuter) + // this is all we can do + return '.'; + }, + currency: { + symbol: 'руб.' + } + }); +})); diff --git a/locales/sk.js b/locales/sk.js new file mode 100644 index 00000000..cb0e898d --- /dev/null +++ b/locales/sk.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : slovak (sk) +// author : Ahmed Al Hafoudh : http://www.freevision.sk + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'sk', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'tis.', + million: 'mil.', + billion: 'b', + trillion: 't' + }, + ordinal: function () { + return '.'; + }, + currency: { + symbol: '€' + } + }); +})); diff --git a/locales/sl.js b/locales/sl.js new file mode 100644 index 00000000..2f1117eb --- /dev/null +++ b/locales/sl.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : slovenian (sl) +// author : Boštjan Pišler : https://github.com/BostjanPisler + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'sl', { + delimiters: { + thousands: '.', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'mio', + billion: 'mrd', + trillion: 'trilijon' + }, + ordinal: function () { + return '.'; + }, + currency: { + symbol: '€' + } + }); +})); diff --git a/locales/th.js b/locales/th.js new file mode 100644 index 00000000..d3e08d00 --- /dev/null +++ b/locales/th.js @@ -0,0 +1,34 @@ +// numeral.js locale configuration +// locale : thai (th) +// author : Sathit Jittanupat : https://github.com/jojosati + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + + + numeral.register('locale', 'th', { + delimiters: { + thousands: ',', + decimal: '.' + }, + abbreviations: { + thousand: 'พัน', + million: 'ล้าน', + billion: 'พันล้าน', + trillion: 'ล้านล้าน' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: '฿' + } + }); +})); diff --git a/locales/tr.js b/locales/tr.js new file mode 100644 index 00000000..07f7ffdd --- /dev/null +++ b/locales/tr.js @@ -0,0 +1,66 @@ +// numeral.js locale configuration +// locale : turkish (tr) +// author : Ecmel Ercan : https://github.com/ecmel, Erhan Gundogan : https://github.com/erhangundogan, Burak Yiğit Kaya: https://github.com/BYK + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + var suffixes = { + 1: '\'inci', + 5: '\'inci', + 8: '\'inci', + 70: '\'inci', + 80: '\'inci', + + 2: '\'nci', + 7: '\'nci', + 20: '\'nci', + 50: '\'nci', + + 3: '\'üncü', + 4: '\'üncü', + 100: '\'üncü', + + 6: '\'ncı', + + 9: '\'uncu', + 10: '\'uncu', + 30: '\'uncu', + + 60: '\'ıncı', + 90: '\'ıncı' + }; + + numeral.register('locale', 'tr', { + delimiters: { + thousands: '.', + decimal: ',' + }, + abbreviations: { + thousand: 'bin', + million: 'milyon', + billion: 'milyar', + trillion: 'trilyon' + }, + ordinal: function (number) { + if (number === 0) { // special case for zero + return '\'ıncı'; + } + + var a = number % 10, + b = number % 100 - a, + c = number >= 100 ? 100 : null; + + return suffixes[a] || suffixes[b] || suffixes[c]; + }, + currency: { + symbol: '\u20BA' + } + }); +})); diff --git a/languages/uk-UA.js b/locales/uk-ua.js similarity index 56% rename from languages/uk-UA.js rename to locales/uk-ua.js index ef54fd4a..34b31037 100644 --- a/languages/uk-UA.js +++ b/locales/uk-ua.js @@ -1,8 +1,17 @@ -// numeral.js language configuration -// language : Ukrainian for the Ukraine (uk-UA) +// numeral.js locale configuration +// locale : Ukrainian for the Ukraine (uk-ua) // author : Michael Piefel : https://github.com/piefel (with help from Tetyana Kuzmenko) -(function () { - var language = { + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'uk-ua', { delimiters: { thousands: ' ', decimal: ',' @@ -14,22 +23,13 @@ trillion: 'блн' }, ordinal: function () { - // not ideal, but since in Ukrainian it can taken on + // not ideal, but since in Ukrainian it can taken on // different forms (masculine, feminine, neuter) // this is all we can do - return ''; + return ''; }, currency: { symbol: '\u20B4' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = language; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('uk-UA', language); - } -}()); + }); +})); diff --git a/locales/vi.js b/locales/vi.js new file mode 100644 index 00000000..a71a1bb8 --- /dev/null +++ b/locales/vi.js @@ -0,0 +1,33 @@ +// numeral.js locale configuration +// locale : vietnam (vi) +// author : Harry Nguyen : https://github.com/thaihoa311 + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + + numeral.register('locale', 'vi', { + delimiters: { + thousands: '.', + decimal: ',' + }, + abbreviations: { + thousand: ' nghìn', + million: ' triệu', + billion: ' tỷ', + trillion: ' nghìn tỷ' + }, + ordinal: function () { + return '.'; + }, + currency: { + symbol: '₫' + } + }); +})); diff --git a/min/languages.min.js b/min/languages.min.js deleted file mode 100644 index 11252868..00000000 --- a/min/languages.min.js +++ /dev/null @@ -1,129 +0,0 @@ -/*! - * numeral.js language configuration - * language : belgium-dutch (be-nl) - * author : Dieter Luypaert : https://github.com/moeriki - */ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:" mln",billion:" mld",trillion:" bln"},ordinal:function(a){var b=a%100;return 0!==a&&1>=b||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("be-nl",a)}(),/*! - * numeral.js language configuration - * language : simplified chinese - * author : badplum : https://github.com/badplum - */ -function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("chs",a)}(),/*! - * numeral.js language configuration - * language : czech (cs) - * author : Anatoli Papirovski : https://github.com/apapirovski - */ -function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"Kč"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("cs",a)}(),/*! - * numeral.js language configuration - * language : danish denmark (dk) - * author : Michael Storgaard : https://github.com/mstorgaard - */ -function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mia",trillion:"b"},ordinal:function(){return"."},currency:{symbol:"DKK"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("da-dk",a)}(),/*! - * numeral.js language configuration - * language : German in Switzerland (de-ch) - * author : Michael Piefel : https://github.com/piefel (based on work from Marco Krage : https://github.com/sinky) - */ -function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"CHF"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("de-ch",a)}(),/*! - * numeral.js language configuration - * language : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium - * author : Marco Krage : https://github.com/sinky - */ -function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("de",a)}(),/*! - * numeral.js language configuration - * language : english united kingdom (uk) - * author : Dan Ristic : https://github.com/dristic - */ -function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===~~(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th"},currency:{symbol:"£"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("en-gb",a)}(),/*! - * numeral.js language configuration - * language : spanish Spain - * author : Hernan Garcia : https://github.com/hgarcia - */ -function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mm",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===b||3===b?"er":2===b?"do":7===b||0===b?"mo":8===b?"vo":9===b?"no":"to"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("es",a)}(),/*! - * numeral.js language configuration - * language : spanish - * author : Hernan Garcia : https://github.com/hgarcia - */ -function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mm",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===b||3===b?"er":2===b?"do":7===b||0===b?"mo":8===b?"vo":9===b?"no":"to"},currency:{symbol:"$"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("es",a)}(),/*! - * numeral.js language configuration - * language : Estonian - * author : Illimar Tambek : https://github.com/ragulka - * - * Note: in Estonian, abbreviations are always separated - * from numbers with a space - */ -function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("et",a)}(),/*! - * numeral.js language configuration - * language : Finnish - * author : Sami Saada : https://github.com/samitheberber - */ -function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("fi",a)}(),/*! - * numeral.js language configuration - * language : french (Canada) (fr-CA) - * author : Léo Renaud-Allaire : https://github.com/renaudleo - */ -function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return 1===a?"er":"e"},currency:{symbol:"$"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("fr-CA",a)}(),/*! - * numeral.js language configuration - * language : french (fr-ch) - * author : Adam Draper : https://github.com/adamwdraper - */ -function(){var a={delimiters:{thousands:"'",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return 1===a?"er":"e"},currency:{symbol:"CHF"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("fr-ch",a)}(),/*! - * numeral.js language configuration - * language : french (fr) - * author : Adam Draper : https://github.com/adamwdraper - */ -function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return 1===a?"er":"e"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("fr",a)}(),/*! - * numeral.js language configuration - * language : Hungarian (hu) - * author : Peter Bakondy : https://github.com/pbakondy - */ -function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(){return"."},currency:{symbol:" Ft"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("hu",a)}(),/*! - * numeral.js language configuration - * language : italian Italy (it) - * author : Giacomo Trombi : http://cinquepunti.it - */ -function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("it",a)}(),/*! - * numeral.js language configuration - * language : japanese - * author : teppeis : https://github.com/teppeis - */ -function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("ja",a)}(),/*! - * numeral.js language configuration - * language : netherlands-dutch (nl-nl) - * author : Dave Clayton : https://github.com/davedx - */ -function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mln",billion:"mrd",trillion:"bln"},ordinal:function(a){var b=a%100;return 0!==a&&1>=b||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("nl-nl",a)}(),/*! - * numeral.js language configuration - * language : polish (pl) - * author : Dominik Bulaj : https://github.com/dominikbulaj - */ -function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(){return"."},currency:{symbol:"PLN"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("pl",a)}(),/*! - * numeral.js language configuration - * language : portuguese brazil (pt-br) - * author : Ramiro Varandas Jr : https://github.com/ramirovjr - */ -function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mil",million:"milhões",billion:"b",trillion:"t"},ordinal:function(){return"º"},currency:{symbol:"R$"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("pt-br",a)}(),/*! - * numeral.js language configuration - * language : portuguese (pt-pt) - * author : Diogo Resende : https://github.com/dresende - */ -function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("pt-pt",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"₴"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("ru-UA",a)}(),/*! - * numeral.js language configuration - * language : russian (ru) - * author : Anatoli Papirovski : https://github.com/apapirovski - */ -function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"руб."}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("ru",a)}(),/*! - * numeral.js language configuration - * language : slovak (sk) - * author : Ahmed Al Hafoudh : http://www.freevision.sk - */ -function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("sk",a)}(),/*! - * numeral.js language configuration - * language : thai (th) - * author : Sathit Jittanupat : https://github.com/jojosati - */ -function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("th",a)}(),/*! - * numeral.js language configuration - * language : turkish (tr) - * author : Ecmel Ercan : https://github.com/ecmel, Erhan Gundogan : https://github.com/erhangundogan, Burak Yiğit Kaya: https://github.com/BYK - */ -function(){var a={1:"'inci",5:"'inci",8:"'inci",70:"'inci",80:"'inci",2:"'nci",7:"'nci",20:"'nci",50:"'nci",3:"'üncü",4:"'üncü",100:"'üncü",6:"'ncı",9:"'uncu",10:"'uncu",30:"'uncu",60:"'ıncı",90:"'ıncı"},b={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"bin",million:"milyon",billion:"milyar",trillion:"trilyon"},ordinal:function(b){if(0===b)return"'ıncı";var c=b%10,d=b%100-c,e=b>=100?100:null;return a[c]||a[d]||a[e]},currency:{symbol:"₺"}};"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("tr",b)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тис.",million:"млн",billion:"млрд",trillion:"блн"},ordinal:function(){return""},currency:{symbol:"₴"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("uk-UA",a)}(); \ No newline at end of file diff --git a/min/languages/be-nl.min.js b/min/languages/be-nl.min.js deleted file mode 100644 index d17a383f..00000000 --- a/min/languages/be-nl.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * numeral.js language configuration - * language : belgium-dutch (be-nl) - * author : Dieter Luypaert : https://github.com/moeriki - */ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:" mln",billion:" mld",trillion:" bln"},ordinal:function(a){var b=a%100;return 0!==a&&1>=b||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("be-nl",a)}(); \ No newline at end of file diff --git a/min/languages/chs.min.js b/min/languages/chs.min.js deleted file mode 100644 index 6d375969..00000000 --- a/min/languages/chs.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * numeral.js language configuration - * language : simplified chinese - * author : badplum : https://github.com/badplum - */ -!function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("chs",a)}(); \ No newline at end of file diff --git a/min/languages/cs.min.js b/min/languages/cs.min.js deleted file mode 100644 index b1d1ff57..00000000 --- a/min/languages/cs.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * numeral.js language configuration - * language : czech (cs) - * author : Anatoli Papirovski : https://github.com/apapirovski - */ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"Kč"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("cs",a)}(); \ No newline at end of file diff --git a/min/languages/da-dk.min.js b/min/languages/da-dk.min.js deleted file mode 100644 index 19f1a7b3..00000000 --- a/min/languages/da-dk.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * numeral.js language configuration - * language : danish denmark (dk) - * author : Michael Storgaard : https://github.com/mstorgaard - */ -!function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mia",trillion:"b"},ordinal:function(){return"."},currency:{symbol:"DKK"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("da-dk",a)}(); \ No newline at end of file diff --git a/min/languages/de-ch.min.js b/min/languages/de-ch.min.js deleted file mode 100644 index 5279f430..00000000 --- a/min/languages/de-ch.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * numeral.js language configuration - * language : German in Switzerland (de-ch) - * author : Michael Piefel : https://github.com/piefel (based on work from Marco Krage : https://github.com/sinky) - */ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"CHF"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("de-ch",a)}(); \ No newline at end of file diff --git a/min/languages/de.min.js b/min/languages/de.min.js deleted file mode 100644 index 0c54a30a..00000000 --- a/min/languages/de.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * numeral.js language configuration - * language : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium - * author : Marco Krage : https://github.com/sinky - */ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("de",a)}(); \ No newline at end of file diff --git a/min/languages/en-gb.min.js b/min/languages/en-gb.min.js deleted file mode 100644 index b6d97446..00000000 --- a/min/languages/en-gb.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * numeral.js language configuration - * language : english united kingdom (uk) - * author : Dan Ristic : https://github.com/dristic - */ -!function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===~~(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th"},currency:{symbol:"£"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("en-gb",a)}(); \ No newline at end of file diff --git a/min/languages/es-ES.min.js b/min/languages/es-ES.min.js deleted file mode 100644 index 3f936943..00000000 --- a/min/languages/es-ES.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * numeral.js language configuration - * language : spanish Spain - * author : Hernan Garcia : https://github.com/hgarcia - */ -!function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mm",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===b||3===b?"er":2===b?"do":7===b||0===b?"mo":8===b?"vo":9===b?"no":"to"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("es",a)}(); \ No newline at end of file diff --git a/min/languages/es.min.js b/min/languages/es.min.js deleted file mode 100644 index 40ac3354..00000000 --- a/min/languages/es.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * numeral.js language configuration - * language : spanish - * author : Hernan Garcia : https://github.com/hgarcia - */ -!function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mm",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===b||3===b?"er":2===b?"do":7===b||0===b?"mo":8===b?"vo":9===b?"no":"to"},currency:{symbol:"$"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("es",a)}(); \ No newline at end of file diff --git a/min/languages/et.min.js b/min/languages/et.min.js deleted file mode 100644 index cf9f7e38..00000000 --- a/min/languages/et.min.js +++ /dev/null @@ -1,9 +0,0 @@ -/*! - * numeral.js language configuration - * language : Estonian - * author : Illimar Tambek : https://github.com/ragulka - * - * Note: in Estonian, abbreviations are always separated - * from numbers with a space - */ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("et",a)}(); \ No newline at end of file diff --git a/min/languages/fi.min.js b/min/languages/fi.min.js deleted file mode 100644 index c841275f..00000000 --- a/min/languages/fi.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * numeral.js language configuration - * language : Finnish - * author : Sami Saada : https://github.com/samitheberber - */ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("fi",a)}(); \ No newline at end of file diff --git a/min/languages/fr-CA.min.js b/min/languages/fr-CA.min.js deleted file mode 100644 index b687e50e..00000000 --- a/min/languages/fr-CA.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * numeral.js language configuration - * language : french (Canada) (fr-CA) - * author : Léo Renaud-Allaire : https://github.com/renaudleo - */ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return 1===a?"er":"e"},currency:{symbol:"$"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("fr-CA",a)}(); \ No newline at end of file diff --git a/min/languages/fr-ch.min.js b/min/languages/fr-ch.min.js deleted file mode 100644 index 6ef1af8b..00000000 --- a/min/languages/fr-ch.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * numeral.js language configuration - * language : french (fr-ch) - * author : Adam Draper : https://github.com/adamwdraper - */ -!function(){var a={delimiters:{thousands:"'",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return 1===a?"er":"e"},currency:{symbol:"CHF"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("fr-ch",a)}(); \ No newline at end of file diff --git a/min/languages/fr.min.js b/min/languages/fr.min.js deleted file mode 100644 index 3cc2e70d..00000000 --- a/min/languages/fr.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * numeral.js language configuration - * language : french (fr) - * author : Adam Draper : https://github.com/adamwdraper - */ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return 1===a?"er":"e"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("fr",a)}(); \ No newline at end of file diff --git a/min/languages/hu.min.js b/min/languages/hu.min.js deleted file mode 100644 index 084551b2..00000000 --- a/min/languages/hu.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * numeral.js language configuration - * language : Hungarian (hu) - * author : Peter Bakondy : https://github.com/pbakondy - */ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(){return"."},currency:{symbol:" Ft"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("hu",a)}(); \ No newline at end of file diff --git a/min/languages/it.min.js b/min/languages/it.min.js deleted file mode 100644 index 186a70d0..00000000 --- a/min/languages/it.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * numeral.js language configuration - * language : italian Italy (it) - * author : Giacomo Trombi : http://cinquepunti.it - */ -!function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("it",a)}(); \ No newline at end of file diff --git a/min/languages/ja.min.js b/min/languages/ja.min.js deleted file mode 100644 index 99d8e74b..00000000 --- a/min/languages/ja.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * numeral.js language configuration - * language : japanese - * author : teppeis : https://github.com/teppeis - */ -!function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("ja",a)}(); \ No newline at end of file diff --git a/min/languages/nl-nl.min.js b/min/languages/nl-nl.min.js deleted file mode 100644 index 3321d4a0..00000000 --- a/min/languages/nl-nl.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * numeral.js language configuration - * language : netherlands-dutch (nl-nl) - * author : Dave Clayton : https://github.com/davedx - */ -!function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mln",billion:"mrd",trillion:"bln"},ordinal:function(a){var b=a%100;return 0!==a&&1>=b||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("nl-nl",a)}(); \ No newline at end of file diff --git a/min/languages/pl.min.js b/min/languages/pl.min.js deleted file mode 100644 index e0875827..00000000 --- a/min/languages/pl.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * numeral.js language configuration - * language : polish (pl) - * author : Dominik Bulaj : https://github.com/dominikbulaj - */ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(){return"."},currency:{symbol:"PLN"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("pl",a)}(); \ No newline at end of file diff --git a/min/languages/pt-br.min.js b/min/languages/pt-br.min.js deleted file mode 100644 index 3f57b0c6..00000000 --- a/min/languages/pt-br.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * numeral.js language configuration - * language : portuguese brazil (pt-br) - * author : Ramiro Varandas Jr : https://github.com/ramirovjr - */ -!function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mil",million:"milhões",billion:"b",trillion:"t"},ordinal:function(){return"º"},currency:{symbol:"R$"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("pt-br",a)}(); \ No newline at end of file diff --git a/min/languages/pt-pt.min.js b/min/languages/pt-pt.min.js deleted file mode 100644 index cd707074..00000000 --- a/min/languages/pt-pt.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * numeral.js language configuration - * language : portuguese (pt-pt) - * author : Diogo Resende : https://github.com/dresende - */ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("pt-pt",a)}(); \ No newline at end of file diff --git a/min/languages/ru-UA.min.js b/min/languages/ru-UA.min.js deleted file mode 100644 index 9b4f23fc..00000000 --- a/min/languages/ru-UA.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"₴"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("ru-UA",a)}(); \ No newline at end of file diff --git a/min/languages/ru.min.js b/min/languages/ru.min.js deleted file mode 100644 index 6a3762f3..00000000 --- a/min/languages/ru.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * numeral.js language configuration - * language : russian (ru) - * author : Anatoli Papirovski : https://github.com/apapirovski - */ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"руб."}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("ru",a)}(); \ No newline at end of file diff --git a/min/languages/sk.min.js b/min/languages/sk.min.js deleted file mode 100644 index e68e4dc7..00000000 --- a/min/languages/sk.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * numeral.js language configuration - * language : slovak (sk) - * author : Ahmed Al Hafoudh : http://www.freevision.sk - */ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("sk",a)}(); \ No newline at end of file diff --git a/min/languages/th.min.js b/min/languages/th.min.js deleted file mode 100644 index c165048c..00000000 --- a/min/languages/th.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * numeral.js language configuration - * language : thai (th) - * author : Sathit Jittanupat : https://github.com/jojosati - */ -!function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("th",a)}(); \ No newline at end of file diff --git a/min/languages/tr.min.js b/min/languages/tr.min.js deleted file mode 100644 index 265d16d6..00000000 --- a/min/languages/tr.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * numeral.js language configuration - * language : turkish (tr) - * author : Ecmel Ercan : https://github.com/ecmel, Erhan Gundogan : https://github.com/erhangundogan, Burak Yiğit Kaya: https://github.com/BYK - */ -!function(){var a={1:"'inci",5:"'inci",8:"'inci",70:"'inci",80:"'inci",2:"'nci",7:"'nci",20:"'nci",50:"'nci",3:"'üncü",4:"'üncü",100:"'üncü",6:"'ncı",9:"'uncu",10:"'uncu",30:"'uncu",60:"'ıncı",90:"'ıncı"},b={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"bin",million:"milyon",billion:"milyar",trillion:"trilyon"},ordinal:function(b){if(0===b)return"'ıncı";var c=b%10,d=b%100-c,e=b>=100?100:null;return a[c]||a[d]||a[e]},currency:{symbol:"₺"}};"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("tr",b)}(); \ No newline at end of file diff --git a/min/languages/uk-UA.min.js b/min/languages/uk-UA.min.js deleted file mode 100644 index 958ebf71..00000000 --- a/min/languages/uk-UA.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тис.",million:"млн",billion:"млрд",trillion:"блн"},ordinal:function(){return""},currency:{symbol:"₴"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("uk-UA",a)}(); \ No newline at end of file diff --git a/min/locales.min.js b/min/locales.min.js new file mode 100644 index 00000000..39b1736a --- /dev/null +++ b/min/locales.min.js @@ -0,0 +1,7 @@ +/*! @preserve + * numeral.js + * locales : 2.0.6 + * license : MIT + * http://adamwdraper.github.com/Numeral-js/ + */ +!function(a,b){"function"==typeof define&&define.amd?define(["numeral"],b):b("object"==typeof module&&module.exports?require("./numeral"):a.numeral)}(this,function(a){!function(){a.register("locale","bg",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}})}(),function(){a.register("locale","chs",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){a.register("locale","cs",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"Kč"}})}(),function(){a.register("locale","da-dk",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mia",trillion:"b"},ordinal:function(a){return"."},currency:{symbol:"DKK"}})}(),function(){a.register("locale","de-ch",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"CHF"}})}(),function(){a.register("locale","de",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){a.register("locale","en-au",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===~~(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th"},currency:{symbol:"$"}})}(),function(){a.register("locale","en-gb",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===~~(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th"},currency:{symbol:"£"}})}(),function(){a.register("locale","en-za",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===~~(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th"},currency:{symbol:"R"}})}(),function(){a.register("locale","es-es",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mm",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===b||3===b?"er":2===b?"do":7===b||0===b?"mo":8===b?"vo":9===b?"no":"to"},currency:{symbol:"€"}})}(),function(){a.register("locale","es",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mm",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===b||3===b?"er":2===b?"do":7===b||0===b?"mo":8===b?"vo":9===b?"no":"to"},currency:{symbol:"$"}})}(),function(){a.register("locale","et",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){a.register("locale","fi",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){a.register("locale","fr-ca",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return 1===a?"er":"e"},currency:{symbol:"$"}})}(),function(){a.register("locale","fr-ch",{delimiters:{thousands:"'",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return 1===a?"er":"e"},currency:{symbol:"CHF"}})}(),function(){a.register("locale","fr",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return 1===a?"er":"e"},currency:{symbol:"€"}})}(),function(){a.register("locale","hu",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}})}(),function(){a.register("locale","it",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){a.register("locale","ja",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){a.register("locale","lv",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){a.register("locale","nl-be",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:" mln",billion:" mld",trillion:" bln"},ordinal:function(a){var b=a%100;return 0!==a&&1>=b||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}(),function(){a.register("locale","nl-nl",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mln",billion:"mrd",trillion:"bln"},ordinal:function(a){var b=a%100;return 0!==a&&1>=b||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}(),function(){a.register("locale","no",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}})}(),function(){a.register("locale","pl",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}})}(),function(){a.register("locale","pt-br",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mil",million:"milhões",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"R$"}})}(),function(){a.register("locale","pt-pt",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){a.register("locale","ru-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"₴"}})}(),function(){a.register("locale","ru",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн.",billion:"млрд.",trillion:"трлн."},ordinal:function(){return"."},currency:{symbol:"руб."}})}(),function(){a.register("locale","sk",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€"}})}(),function(){a.register("locale","sl",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mrd",trillion:"trilijon"},ordinal:function(){return"."},currency:{symbol:"€"}})}(),function(){a.register("locale","th",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}})}(),function(){var b={1:"'inci",5:"'inci",8:"'inci",70:"'inci",80:"'inci",2:"'nci",7:"'nci",20:"'nci",50:"'nci",3:"'üncü",4:"'üncü",100:"'üncü",6:"'ncı",9:"'uncu",10:"'uncu",30:"'uncu",60:"'ıncı",90:"'ıncı"};a.register("locale","tr",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"bin",million:"milyon",billion:"milyar",trillion:"trilyon"},ordinal:function(a){if(0===a)return"'ıncı";var c=a%10,d=a%100-c,e=a>=100?100:null;return b[c]||b[d]||b[e]},currency:{symbol:"₺"}})}(),function(){a.register("locale","uk-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тис.",million:"млн",billion:"млрд",trillion:"блн"},ordinal:function(){return""},currency:{symbol:"₴"}})}(),function(){a.register("locale","vi",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:" nghìn",million:" triệu",billion:" tỷ",trillion:" nghìn tỷ"},ordinal:function(){return"."},currency:{symbol:"₫"}})}()}); \ No newline at end of file diff --git a/min/locales/be-nl.min.js b/min/locales/be-nl.min.js new file mode 100644 index 00000000..7c98f24b --- /dev/null +++ b/min/locales/be-nl.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","be-nl",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:" mln",billion:" mld",trillion:" bln"},ordinal:function(a){var b=a%100;return 0!==a&&b<=1||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}); \ No newline at end of file diff --git a/min/locales/bg.min.js b/min/locales/bg.min.js new file mode 100644 index 00000000..eb527e1f --- /dev/null +++ b/min/locales/bg.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","bg",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}})}); \ No newline at end of file diff --git a/min/locales/chs.min.js b/min/locales/chs.min.js new file mode 100644 index 00000000..41818b04 --- /dev/null +++ b/min/locales/chs.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","chs",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}); \ No newline at end of file diff --git a/min/locales/cs.min.js b/min/locales/cs.min.js new file mode 100644 index 00000000..bde3dd59 --- /dev/null +++ b/min/locales/cs.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","cs",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"Kč"}})}); \ No newline at end of file diff --git a/min/locales/da-dk.min.js b/min/locales/da-dk.min.js new file mode 100644 index 00000000..f493b252 --- /dev/null +++ b/min/locales/da-dk.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","da-dk",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mia",trillion:"b"},ordinal:function(a){return"."},currency:{symbol:"DKK"}})}); \ No newline at end of file diff --git a/min/locales/de-ch.min.js b/min/locales/de-ch.min.js new file mode 100644 index 00000000..18469430 --- /dev/null +++ b/min/locales/de-ch.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","de-ch",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"CHF"}})}); \ No newline at end of file diff --git a/min/locales/de.min.js b/min/locales/de.min.js new file mode 100644 index 00000000..baba5a1d --- /dev/null +++ b/min/locales/de.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","de",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}})}); \ No newline at end of file diff --git a/min/locales/en-au.min.js b/min/locales/en-au.min.js new file mode 100644 index 00000000..ad231d78 --- /dev/null +++ b/min/locales/en-au.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","en-au",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===~~(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th"},currency:{symbol:"$"}})}); \ No newline at end of file diff --git a/min/locales/en-gb.min.js b/min/locales/en-gb.min.js new file mode 100644 index 00000000..caea4d24 --- /dev/null +++ b/min/locales/en-gb.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","en-gb",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===~~(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th"},currency:{symbol:"£"}})}); \ No newline at end of file diff --git a/min/locales/en-za.min.js b/min/locales/en-za.min.js new file mode 100644 index 00000000..48838e98 --- /dev/null +++ b/min/locales/en-za.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","en-za",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===~~(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th"},currency:{symbol:"R"}})}); \ No newline at end of file diff --git a/min/locales/es-es.min.js b/min/locales/es-es.min.js new file mode 100644 index 00000000..1bf25b43 --- /dev/null +++ b/min/locales/es-es.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","es-es",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mm",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===b||3===b?"er":2===b?"do":7===b||0===b?"mo":8===b?"vo":9===b?"no":"to"},currency:{symbol:"€"}})}); \ No newline at end of file diff --git a/min/locales/es.min.js b/min/locales/es.min.js new file mode 100644 index 00000000..7dc95925 --- /dev/null +++ b/min/locales/es.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","es",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mm",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===b||3===b?"er":2===b?"do":7===b||0===b?"mo":8===b?"vo":9===b?"no":"to"},currency:{symbol:"$"}})}); \ No newline at end of file diff --git a/min/locales/et.min.js b/min/locales/et.min.js new file mode 100644 index 00000000..43e41687 --- /dev/null +++ b/min/locales/et.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","et",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}})}); \ No newline at end of file diff --git a/min/locales/fi.min.js b/min/locales/fi.min.js new file mode 100644 index 00000000..2d3d119b --- /dev/null +++ b/min/locales/fi.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","fi",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}})}); \ No newline at end of file diff --git a/min/locales/fr-ca.min.js b/min/locales/fr-ca.min.js new file mode 100644 index 00000000..36ea3ee8 --- /dev/null +++ b/min/locales/fr-ca.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","fr-ca",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return 1===a?"er":"e"},currency:{symbol:"$"}})}); \ No newline at end of file diff --git a/min/locales/fr-ch.min.js b/min/locales/fr-ch.min.js new file mode 100644 index 00000000..87e646b2 --- /dev/null +++ b/min/locales/fr-ch.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","fr-ch",{delimiters:{thousands:"'",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return 1===a?"er":"e"},currency:{symbol:"CHF"}})}); \ No newline at end of file diff --git a/min/locales/fr.min.js b/min/locales/fr.min.js new file mode 100644 index 00000000..ef5d9798 --- /dev/null +++ b/min/locales/fr.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","fr",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return 1===a?"er":"e"},currency:{symbol:"€"}})}); \ No newline at end of file diff --git a/min/locales/hu.min.js b/min/locales/hu.min.js new file mode 100644 index 00000000..a18bfe74 --- /dev/null +++ b/min/locales/hu.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","hu",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}})}); \ No newline at end of file diff --git a/min/locales/it.min.js b/min/locales/it.min.js new file mode 100644 index 00000000..0663447e --- /dev/null +++ b/min/locales/it.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","it",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}); \ No newline at end of file diff --git a/min/locales/ja.min.js b/min/locales/ja.min.js new file mode 100644 index 00000000..11bd5911 --- /dev/null +++ b/min/locales/ja.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","ja",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}); \ No newline at end of file diff --git a/min/locales/lv.min.js b/min/locales/lv.min.js new file mode 100644 index 00000000..9cf210fd --- /dev/null +++ b/min/locales/lv.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","lv",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}})}); \ No newline at end of file diff --git a/min/locales/nl-be.min.js b/min/locales/nl-be.min.js new file mode 100644 index 00000000..d97a6ff2 --- /dev/null +++ b/min/locales/nl-be.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","nl-be",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:" mln",billion:" mld",trillion:" bln"},ordinal:function(a){var b=a%100;return 0!==a&&1>=b||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}); \ No newline at end of file diff --git a/min/locales/nl-nl.min.js b/min/locales/nl-nl.min.js new file mode 100644 index 00000000..1e50e799 --- /dev/null +++ b/min/locales/nl-nl.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","nl-nl",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mln",billion:"mrd",trillion:"bln"},ordinal:function(a){var b=a%100;return 0!==a&&1>=b||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}); \ No newline at end of file diff --git a/min/locales/no.min.js b/min/locales/no.min.js new file mode 100644 index 00000000..9ed349a7 --- /dev/null +++ b/min/locales/no.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","no",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}})}); \ No newline at end of file diff --git a/min/locales/pl.min.js b/min/locales/pl.min.js new file mode 100644 index 00000000..633f0741 --- /dev/null +++ b/min/locales/pl.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","pl",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}})}); \ No newline at end of file diff --git a/min/locales/pt-br.min.js b/min/locales/pt-br.min.js new file mode 100644 index 00000000..5cc66de6 --- /dev/null +++ b/min/locales/pt-br.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","pt-br",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mil",million:"milhões",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"R$"}})}); \ No newline at end of file diff --git a/min/locales/pt-pt.min.js b/min/locales/pt-pt.min.js new file mode 100644 index 00000000..48fa0d90 --- /dev/null +++ b/min/locales/pt-pt.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","pt-pt",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}); \ No newline at end of file diff --git a/min/locales/ru-ua.min.js b/min/locales/ru-ua.min.js new file mode 100644 index 00000000..619444d9 --- /dev/null +++ b/min/locales/ru-ua.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","ru-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"₴"}})}); \ No newline at end of file diff --git a/min/locales/ru.min.js b/min/locales/ru.min.js new file mode 100644 index 00000000..f3d19ad5 --- /dev/null +++ b/min/locales/ru.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","ru",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн.",billion:"млрд.",trillion:"трлн."},ordinal:function(){return"."},currency:{symbol:"руб."}})}); \ No newline at end of file diff --git a/min/locales/sk.min.js b/min/locales/sk.min.js new file mode 100644 index 00000000..0baf1952 --- /dev/null +++ b/min/locales/sk.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","sk",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€"}})}); \ No newline at end of file diff --git a/min/locales/sl.min.js b/min/locales/sl.min.js new file mode 100644 index 00000000..def40e29 --- /dev/null +++ b/min/locales/sl.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","sl",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mrd",trillion:"trilijon"},ordinal:function(){return"."},currency:{symbol:"€"}})}); \ No newline at end of file diff --git a/min/locales/th.min.js b/min/locales/th.min.js new file mode 100644 index 00000000..fd49a50c --- /dev/null +++ b/min/locales/th.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","th",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}})}); \ No newline at end of file diff --git a/min/locales/tr.min.js b/min/locales/tr.min.js new file mode 100644 index 00000000..4f77e39f --- /dev/null +++ b/min/locales/tr.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){var b={1:"'inci",5:"'inci",8:"'inci",70:"'inci",80:"'inci",2:"'nci",7:"'nci",20:"'nci",50:"'nci",3:"'üncü",4:"'üncü",100:"'üncü",6:"'ncı",9:"'uncu",10:"'uncu",30:"'uncu",60:"'ıncı",90:"'ıncı"};a.register("locale","tr",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"bin",million:"milyon",billion:"milyar",trillion:"trilyon"},ordinal:function(a){if(0===a)return"'ıncı";var c=a%10,d=a%100-c,e=a>=100?100:null;return b[c]||b[d]||b[e]},currency:{symbol:"₺"}})}); \ No newline at end of file diff --git a/min/locales/uk-ua.min.js b/min/locales/uk-ua.min.js new file mode 100644 index 00000000..9120e3f0 --- /dev/null +++ b/min/locales/uk-ua.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","uk-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тис.",million:"млн",billion:"млрд",trillion:"блн"},ordinal:function(){return""},currency:{symbol:"₴"}})}); \ No newline at end of file diff --git a/min/locales/vi.min.js b/min/locales/vi.min.js new file mode 100644 index 00000000..fde4756b --- /dev/null +++ b/min/locales/vi.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(["../numeral"],b):b("object"==typeof module&&module.exports?require("../numeral"):a.numeral)}(this,function(a){a.register("locale","vi",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:" nghìn",million:" triệu",billion:" tỷ",trillion:" nghìn tỷ"},ordinal:function(){return"."},currency:{symbol:"₫"}})}); \ No newline at end of file diff --git a/min/numeral.min.js b/min/numeral.min.js index d17b5571..b721f54a 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -1,8 +1,8 @@ -/*! +/*! @preserve * numeral.js - * version : 1.5.3 + * version : 2.0.6 * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -(function(){function a(a){this._value=a}function b(a,b,c,d){var e,f,g=Math.pow(10,b);return f=(c(a*g)/g).toFixed(b),d&&(e=new RegExp("0{1,"+d+"}$"),f=f.replace(e,"")),f}function c(a,b,c){var d;return d=b.indexOf("$")>-1?e(a,b,c):b.indexOf("%")>-1?f(a,b,c):b.indexOf(":")>-1?g(a,b):i(a._value,b,c)}function d(a,b){var c,d,e,f,g,i=b,j=["KB","MB","GB","TB","PB","EB","ZB","YB"],k=!1;if(b.indexOf(":")>-1)a._value=h(b);else if(b===q)a._value=0;else{for("."!==o[p].delimiters.decimal&&(b=b.replace(/\./g,"").replace(o[p].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+o[p].abbreviations.thousand+"(?:\\)|(\\"+o[p].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+o[p].abbreviations.million+"(?:\\)|(\\"+o[p].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+o[p].abbreviations.billion+"(?:\\)|(\\"+o[p].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+o[p].abbreviations.trillion+"(?:\\)|(\\"+o[p].currency.symbol+")?(?:\\))?)?$"),g=0;g<=j.length&&!(k=b.indexOf(j[g])>-1?Math.pow(1024,g+1):!1);g++);a._value=(k?k:1)*(i.match(c)?Math.pow(10,3):1)*(i.match(d)?Math.pow(10,6):1)*(i.match(e)?Math.pow(10,9):1)*(i.match(f)?Math.pow(10,12):1)*(b.indexOf("%")>-1?.01:1)*((b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1)*Number(b.replace(/[^0-9\.]+/g,"")),a._value=k?Math.ceil(a._value):a._value}return a._value}function e(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),j="";return b.indexOf(" $")>-1?(j=" ",b=b.replace(" $","")):b.indexOf("$ ")>-1?(j=" ",b=b.replace("$ ","")):b=b.replace("$",""),e=i(a._value,b,c),1>=f?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,o[p].currency.symbol+j),e=e.join("")):e=o[p].currency.symbol+j+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,j+o[p].currency.symbol),e=e.join("")):e=e+j+o[p].currency.symbol,e}function f(a,b,c){var d,e="",f=100*a._value;return b.indexOf(" %")>-1?(e=" ",b=b.replace(" %","")):b=b.replace("%",""),d=i(f,b,c),d.indexOf(")")>-1?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function g(a){var b=Math.floor(a._value/60/60),c=Math.floor((a._value-60*b*60)/60),d=Math.round(a._value-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function h(a){var b=a.split(":"),c=0;return 3===b.length?(c+=60*Number(b[0])*60,c+=60*Number(b[1]),c+=Number(b[2])):2===b.length&&(c+=60*Number(b[0]),c+=Number(b[1])),Number(c)}function i(a,c,d){var e,f,g,h,i,j,k=!1,l=!1,m=!1,n="",r=!1,s=!1,t=!1,u=!1,v=!1,w="",x="",y=Math.abs(a),z=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],A="",B=!1;if(0===a&&null!==q)return q;if(c.indexOf("(")>-1?(k=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(l=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(r=c.indexOf("aK")>=0,s=c.indexOf("aM")>=0,t=c.indexOf("aB")>=0,u=c.indexOf("aT")>=0,v=r||s||t||u,c.indexOf(" a")>-1?(n=" ",c=c.replace(" a","")):c=c.replace("a",""),y>=Math.pow(10,12)&&!v||u?(n+=o[p].abbreviations.trillion,a/=Math.pow(10,12)):y=Math.pow(10,9)&&!v||t?(n+=o[p].abbreviations.billion,a/=Math.pow(10,9)):y=Math.pow(10,6)&&!v||s?(n+=o[p].abbreviations.million,a/=Math.pow(10,6)):(y=Math.pow(10,3)&&!v||r)&&(n+=o[p].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("b")>-1)for(c.indexOf(" b")>-1?(w=" ",c=c.replace(" b","")):c=c.replace("b",""),g=0;g<=z.length;g++)if(e=Math.pow(1024,g),f=Math.pow(1024,g+1),a>=e&&f>a){w+=z[g],e>0&&(a/=e);break}return c.indexOf("o")>-1&&(c.indexOf(" o")>-1?(x=" ",c=c.replace(" o","")):c=c.replace("o",""),x+=o[p].ordinal(a)),c.indexOf("[.]")>-1&&(m=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(i.indexOf("[")>-1?(i=i.replace("]",""),i=i.split("["),A=b(a,i[0].length+i[1].length,d,i[1].length)):A=b(a,i.length,d),h=A.split(".")[0],A=A.split(".")[1].length?o[p].delimiters.decimal+A.split(".")[1]:"",m&&0===Number(A.slice(1))&&(A="")):h=b(a,null,d),h.indexOf("-")>-1&&(h=h.slice(1),B=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+o[p].delimiters.thousands)),0===c.indexOf(".")&&(h=""),(k&&B?"(":"")+(!k&&B?"-":"")+(!B&&l?"+":"")+h+A+(x?x:"")+(n?n:"")+(w?w:"")+(k&&B?")":"")}function j(a,b){o[a]=b}function k(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function l(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=k(a),d=k(b);return c>d?c:d},-1/0)}var m,n="1.5.3",o={},p="en",q=null,r="0,0",s="undefined"!=typeof module&&module.exports;m=function(b){return m.isNumeral(b)?b=b.value():0===b||"undefined"==typeof b?b=0:Number(b)||(b=m.fn.unformat(b)),new a(Number(b))},m.version=n,m.isNumeral=function(b){return b instanceof a},m.language=function(a,b){if(!a)return p;if(a&&!b){if(!o[a])throw new Error("Unknown language : "+a);p=a}return(b||!o[a])&&j(a,b),m},m.languageData=function(a){if(!a)return o[p];if(!o[a])throw new Error("Unknown language : "+a);return o[a]},m.language("en",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===~~(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th"},currency:{symbol:"$"}}),m.zeroFormat=function(a){q="string"==typeof a?a:null},m.defaultFormat=function(a){r="string"==typeof a?a:"0.0"},"function"!=typeof Array.prototype.reduce&&(Array.prototype.reduce=function(a,b){"use strict";if(null===this||"undefined"==typeof this)throw new TypeError("Array.prototype.reduce called on null or undefined");if("function"!=typeof a)throw new TypeError(a+" is not a function");var c,d,e=this.length>>>0,f=!1;for(1c;++c)this.hasOwnProperty(c)&&(f?d=a(d,this[c],c,this):(d=this[c],f=!0));if(!f)throw new TypeError("Reduce of empty array with no initial value");return d}),m.fn=a.prototype={clone:function(){return m(this)},format:function(a,b){return c(this,a?a:r,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:d(this,a?a:r)},value:function(){return this._value},valueOf:function(){return this._value},set:function(a){return this._value=Number(a),this},add:function(a){function b(a,b){return a+c*b}var c=l.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b){return a-c*b}var c=l.call(null,this._value,a);return this._value=[a].reduce(b,this._value*c)/c,this},multiply:function(a){function b(a,b){var c=l(a,b);return a*c*b*c/(c*c)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b){var c=l(a,b);return a*c/(b*c)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(m(this._value).subtract(a).value())}},s&&(module.exports=m),"undefined"==typeof ender&&(this.numeral=m),"function"==typeof define&&define.amd&&define([],function(){return m})}).call(this); \ No newline at end of file +!function(a,b){"function"==typeof define&&define.amd?define(b):"object"==typeof module&&module.exports?module.exports=b():a.numeral=b()}(this,function(){function a(a,b){this._input=a,this._value=b}var b,c,d="2.0.6",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0",scalePercentBy100:!0},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat,scalePercentBy100:g.scalePercentBy100};return b=function(d){var f,g,i,j;if(b.isNumeral(d))f=d.value();else if(0===d||"undefined"==typeof d)f=0;else if(null===d||c.isNaN(d))f=null;else if("string"==typeof d)if(h.zeroFormat&&d===h.zeroFormat)f=0;else if(h.nullFormat&&d===h.nullFormat||!d.replace(/[^0-9]+/g,"").length)f=null;else{for(g in e)if(j="function"==typeof e[g].regexps.unformat?e[g].regexps.unformat():e[g].regexps.unformat,j&&d.match(j)){i=e[g].unformat;break}i=i||b._.stringToNumber,f=i(d)}else f=Number(d)||null;return new a(d,f)},b.version=d,b.isNumeral=function(b){return b instanceof a},b._=c={numberToFormat:function(a,c,d){var e,g,h,i,j,k,l,m=f[b.options.currentLocale],n=!1,o=!1,p=0,q="",r=1e12,s=1e9,t=1e6,u=1e3,v="",w=!1;if(a=a||0,g=Math.abs(a),b._.includes(c,"(")?(n=!0,c=c.replace(/[\(|\)]/g,"")):(b._.includes(c,"+")||b._.includes(c,"-"))&&(j=b._.includes(c,"+")?c.indexOf("+"):0>a?c.indexOf("-"):-1,c=c.replace(/[\+|\-]/g,"")),b._.includes(c,"a")&&(e=c.match(/a(k|m|b|t)?/),e=e?e[1]:!1,b._.includes(c," a")&&(q=" "),c=c.replace(new RegExp(q+"a[kmbt]?"),""),g>=r&&!e||"t"===e?(q+=m.abbreviations.trillion,a/=r):r>g&&g>=s&&!e||"b"===e?(q+=m.abbreviations.billion,a/=s):s>g&&g>=t&&!e||"m"===e?(q+=m.abbreviations.million,a/=t):(t>g&&g>=u&&!e||"k"===e)&&(q+=m.abbreviations.thousand,a/=u)),b._.includes(c,"[.]")&&(o=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],k=c.indexOf(","),p=(c.split(".")[0].split(",")[0].match(/0/g)||[]).length,i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),v=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):v=b._.toFixed(a,i.length,d),h=v.split(".")[0],v=b._.includes(v,".")?m.delimiters.decimal+v.split(".")[1]:"",o&&0===Number(v.slice(1))&&(v="")):h=b._.toFixed(a,0,d),q&&!e&&Number(h)>=1e3&&q!==m.abbreviations.trillion)switch(h=String(Number(h)/1e3),q){case m.abbreviations.thousand:q=m.abbreviations.million;break;case m.abbreviations.million:q=m.abbreviations.billion;break;case m.abbreviations.billion:q=m.abbreviations.trillion}if(b._.includes(h,"-")&&(h=h.slice(1),w=!0),h.length0;x--)h="0"+h;return k>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+m.delimiters.thousands)),0===c.indexOf(".")&&(h=""),l=h+v+(q?q:""),n?l=(n&&w?"(":"")+l+(n&&w?")":""):j>=0?l=0===j?(w?"-":"+")+l:l+(w?"-":"+"):w&&(l="-"+l),l},stringToNumber:function(a){var b,c,d,e=f[h.currentLocale],g=a,i={thousand:3,million:6,billion:9,trillion:12};if(h.zeroFormat&&a===h.zeroFormat)c=0;else if(h.nullFormat&&a===h.nullFormat||!a.replace(/[^0-9]+/g,"").length)c=null;else{c=1,"."!==e.delimiters.decimal&&(a=a.replace(/\./g,"").replace(e.delimiters.decimal,"."));for(b in i)if(d=new RegExp("[^a-zA-Z]"+e.abbreviations[b]+"(?:\\)|(\\"+e.currency.symbol+")?(?:\\))?)?$"),g.match(d)){c*=Math.pow(10,i[b]);break}c*=(a.split("-").length+Math.min(a.split("(").length-1,a.split(")").length-1))%2?1:-1,a=a.replace(/[^0-9\.]+/g,""),c*=Number(a)}return c},isNaN:function(a){return"number"==typeof a&&isNaN(a)},includes:function(a,b){return-1!==a.indexOf(b)},insert:function(a,b,c){return a.slice(0,c)+b+a.slice(c)},reduce:function(a,b){if(null===this)throw new TypeError("Array.prototype.reduce called on null or undefined");if("function"!=typeof b)throw new TypeError(b+" is not a function");var c,d=Object(a),e=d.length>>>0,f=0;if(3===arguments.length)c=arguments[2];else{for(;e>f&&!(f in d);)f++;if(f>=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;e>f;f++)f in d&&(c=b(c,d[f],f,d));return c},multiplier:function(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)},correctionFactor:function(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var d=c.multiplier(b);return a>d?a:d},1)},toFixed:function(a,b,c,d){var e,f,g,h,i=a.toString().split("."),j=b-(d||0);return e=2===i.length?Math.min(Math.max(i[1].length,j),b):j,g=Math.pow(10,e),h=(c(a+"e+"+e)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}},b.options=h,b.formats=e,b.locales=f,b.locale=function(a){return a&&(h.currentLocale=a.toLowerCase()),h.currentLocale},b.localeData=function(a){if(!a)return f[h.currentLocale];if(a=a.toLowerCase(),!f[a])throw new Error("Unknown locale : "+a);return f[a]},b.reset=function(){for(var a in g)h[a]=g[a]},b.zeroFormat=function(a){h.zeroFormat="string"==typeof a?a:null},b.nullFormat=function(a){h.nullFormat="string"==typeof a?a:null},b.defaultFormat=function(a){h.defaultFormat="string"==typeof a?a:"0.0"},b.register=function(a,b,c){if(b=b.toLowerCase(),this[a+"s"][b])throw new TypeError(b+" "+a+" already registered.");return this[a+"s"][b]=c,c},b.validate=function(a,c){var d,e,f,g,h,i,j,k;if("string"!=typeof a&&(a+="",console.warn&&console.warn("Numeral.js: Value is not string. It has been co-erced to: ",a)),a=a.trim(),a.match(/^\d+$/))return!0;if(""===a)return!1;try{j=b.localeData(c)}catch(l){j=b.localeData(b.locale())}return f=j.currency.symbol,h=j.abbreviations,d=j.delimiters.decimal,e="."===j.delimiters.thousands?"\\.":j.delimiters.thousands,k=a.match(/^[^\d]+/),null!==k&&(a=a.substr(1),k[0]!==f)?!1:(k=a.match(/[^\d]+$/),null!==k&&(a=a.slice(0,-1),k[0]!==h.thousand&&k[0]!==h.million&&k[0]!==h.billion&&k[0]!==h.trillion)?!1:(i=new RegExp(e+"{2}"),a.match(/[^\d.,]/g)?!1:(g=a.split(d),g.length>2?!1:g.length<2?!!g[0].match(/^\d+.*\d$/)&&!g[0].match(i):1===g[0].length?!!g[0].match(/^\d+$/)&&!g[0].match(i)&&!!g[1].match(/^\d+$/):!!g[0].match(/^\d+.*\d$/)&&!g[0].match(i)&&!!g[1].match(/^\d+$/))))},b.fn=a.prototype={clone:function(){return b(this)},format:function(a,c){var d,f,g,i=this._value,j=a||h.defaultFormat;if(c=c||Math.round,0===i&&null!==h.zeroFormat)f=h.zeroFormat;else if(null===i&&null!==h.nullFormat)f=h.nullFormat;else{for(d in e)if(j.match(e[d].regexps.format)){g=e[d].format;break}g=g||b._.numberToFormat,f=g(i,j,c)}return f},value:function(){return this._value},input:function(){return this._input},set:function(a){return this._value=Number(a),this},add:function(a){function b(a,b,c,e){return a+Math.round(d*b)}var d=c.correctionFactor.call(null,this._value,a);return this._value=c.reduce([this._value,a],b,0)/d,this},subtract:function(a){function b(a,b,c,e){return a-Math.round(d*b)}var d=c.correctionFactor.call(null,this._value,a);return this._value=c.reduce([a],b,Math.round(this._value*d))/d,this},multiply:function(a){function b(a,b,d,e){var f=c.correctionFactor(a,b);return Math.round(a*f)*Math.round(b*f)/Math.round(f*f)}return this._value=c.reduce([this._value,a],b,1),this},divide:function(a){function b(a,b,d,e){var f=c.correctionFactor(a,b);return Math.round(a*f)/Math.round(b*f)}return this._value=c.reduce([this._value,a],b),this},difference:function(a){return Math.abs(b(this._value).subtract(a).value())}},b.register("locale","en",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===~~(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th"},currency:{symbol:"$"}}),function(){b.register("format","bps",{regexps:{format:/(BPS)/,unformat:/(BPS)/},format:function(a,c,d){var e,f=b._.includes(c," BPS")?" ":"";return a=1e4*a,c=c.replace(/\s?BPS/,""),e=b._.numberToFormat(a,c,d),b._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"BPS"),e=e.join("")):e=e+f+"BPS",e},unformat:function(a){return+(1e-4*b._.stringToNumber(a)).toFixed(15)}})}(),function(){var a={base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},c={base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},d=a.suffixes.concat(c.suffixes.filter(function(b){return a.suffixes.indexOf(b)<0})),e=d.join("|");e="("+e.replace("B","B(?!PS)")+")",b.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp(e)},format:function(d,e,f){var g,h,i,j,k=b._.includes(e,"ib")?c:a,l=b._.includes(e," b")||b._.includes(e," ib")?" ":"";for(e=e.replace(/\s?i?b/,""),h=0;h<=k.suffixes.length;h++)if(i=Math.pow(k.base,h),j=Math.pow(k.base,h+1),null===d||0===d||d>=i&&j>d){l+=k.suffixes[h],i>0&&(d/=i);break}return g=b._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=b._.stringToNumber(d);if(g){for(e=a.suffixes.length-1;e>=0;e--){if(b._.includes(d,a.suffixes[e])){f=Math.pow(a.base,e);break}if(b._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){b.register("format","currency",{regexps:{format:/(\$)/},format:function(a,c,d){var e,f,g,h=b.locales[b.options.currentLocale],i={before:c.match(/^([\+|\-|\(|\s|\$]*)/)[0],after:c.match(/([\+|\-|\)|\s|\$]*)$/)[0]};for(c=c.replace(/\s?\$\s?/,""),e=b._.numberToFormat(a,c,d),a>=0?(i.before=i.before.replace(/[\-\(]/,""),i.after=i.after.replace(/[\-\)]/,"")):0>a&&!b._.includes(i.before,"-")&&!b._.includes(i.before,"(")&&(i.before="-"+i.before),g=0;g=0;g--)switch(f=i.after[g]){case"$":e=g===i.after.length-1?e+h.currency.symbol:b._.insert(e,h.currency.symbol,-(i.after.length-(1+g)));break;case" ":e=g===i.after.length-1?e+" ":b._.insert(e," ",-(i.after.length-(1+g)+h.currency.symbol.length-1))}return e}})}(),function(){b.register("format","exponential",{regexps:{format:/(e\+|e-)/,unformat:/(e\+|e-)/},format:function(a,c,d){var e,f="number"!=typeof a||b._.isNaN(a)?"0e+0":a.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=b._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]},unformat:function(a){function c(a,c,d,e){var f=b._.correctionFactor(a,c),g=a*f*(c*f)/(f*f);return g}var d=b._.includes(a,"e+")?a.split("e+"):a.split("e-"),e=Number(d[0]),f=Number(d[1]);return f=b._.includes(a,"e-")?f*=-1:f,b._.reduce([e,Math.pow(10,f)],c,1)}})}(),function(){b.register("format","ordinal",{regexps:{format:/(o)/},format:function(a,c,d){var e,f=b.locales[b.options.currentLocale],g=b._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(a),e=b._.numberToFormat(a,c,d),e+g}})}(),function(){b.register("format","percentage",{regexps:{format:/(%)/,unformat:/(%)/},format:function(a,c,d){var e,f=b._.includes(c," %")?" ":"";return b.options.scalePercentBy100&&(a=100*a),c=c.replace(/\s?\%/,""),e=b._.numberToFormat(a,c,d),b._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e},unformat:function(a){var c=b._.stringToNumber(a);return b.options.scalePercentBy100?.01*c:c}})}(),function(){b.register("format","time",{regexps:{format:/(:)/,unformat:/(:)/},format:function(a,b,c){var d=Math.floor(a/60/60),e=Math.floor((a-60*d*60)/60),f=Math.round(a-60*d*60-60*e);return d+":"+(10>e?"0"+e:e)+":"+(10>f?"0"+f:f)},unformat:function(a){var b=a.split(":"),c=0;return 3===b.length?(c+=60*Number(b[0])*60,c+=60*Number(b[1]),c+=Number(b[2])):2===b.length&&(c+=60*Number(b[0]),c+=Number(b[1])),Number(c)}})}(),b}); \ No newline at end of file diff --git a/numeral.js b/numeral.js index 9f46ab65..22726c9e 100644 --- a/numeral.js +++ b/numeral.js @@ -1,455 +1,672 @@ -/*! +/*! @preserve * numeral.js - * version : 1.5.3 + * version : 2.0.6 * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -(function () { - +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(factory); + } else if (typeof module === 'object' && module.exports) { + module.exports = factory(); + } else { + global.numeral = factory(); + } +}(this, function () { /************************************ - Constants + Variables ************************************/ var numeral, - VERSION = '1.5.3', - // internal storage for language config files - languages = {}, - currentLanguage = 'en', - zeroFormat = null, - defaultFormat = '0,0', - // check for nodeJS - hasModule = (typeof module !== 'undefined' && module.exports); + _, + VERSION = '2.0.6', + formats = {}, + locales = {}, + defaults = { + currentLocale: 'en', + zeroFormat: null, + nullFormat: null, + defaultFormat: '0,0', + scalePercentBy100: true + }, + options = { + currentLocale: defaults.currentLocale, + zeroFormat: defaults.zeroFormat, + nullFormat: defaults.nullFormat, + defaultFormat: defaults.defaultFormat, + scalePercentBy100: defaults.scalePercentBy100 + }; /************************************ Constructors ************************************/ - // Numeral prototype object - function Numeral (number) { - this._value = number; - } - - /** - * Implementation of toFixed() that treats floats more like decimals - * - * Fixes binary rounding issues (eg. (0.615).toFixed(2) === '0.61') that present - * problems for accounting- and finance-related software. - */ - function toFixed (value, precision, roundingFunction, optionals) { - var power = Math.pow(10, precision), - optionalsRegExp, - output; - - //roundingFunction = (roundingFunction !== undefined ? roundingFunction : Math.round); - // Multiply up by precision, round accurately, then divide and use native toFixed(): - output = (roundingFunction(value * power) / power).toFixed(precision); - - if (optionals) { - optionalsRegExp = new RegExp('0{1,' + optionals + '}$'); - output = output.replace(optionalsRegExp, ''); - } + function Numeral(input, number) { + this._input = input; - return output; + this._value = number; } - /************************************ - Formatting - ************************************/ - - // determine what type of formatting we need to do - function formatNumeral (n, format, roundingFunction) { - var output; - - // figure out what kind of format we are dealing with - if (format.indexOf('$') > -1) { // currency!!!!! - output = formatCurrency(n, format, roundingFunction); - } else if (format.indexOf('%') > -1) { // percentage - output = formatPercentage(n, format, roundingFunction); - } else if (format.indexOf(':') > -1) { // time - output = formatTime(n, format); - } else { // plain ol' numbers or bytes - output = formatNumber(n._value, format, roundingFunction); - } - - // return string - return output; - } + numeral = function(input) { + var value, + kind, + unformatFunction, + regexp; - // revert to number - function unformatNumeral (n, string) { - var stringOriginal = string, - thousandRegExp, - millionRegExp, - billionRegExp, - trillionRegExp, - suffixes = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], - bytesMultiplier = false, - power; - - if (string.indexOf(':') > -1) { - n._value = unformatTime(string); - } else { - if (string === zeroFormat) { - n._value = 0; + if (numeral.isNumeral(input)) { + value = input.value(); + } else if (input === 0 || typeof input === 'undefined') { + value = 0; + } else if (input === null || _.isNaN(input)) { + value = null; + } else if (typeof input === 'string') { + if (options.zeroFormat && input === options.zeroFormat) { + value = 0; + } else if (options.nullFormat && input === options.nullFormat || !input.replace(/[^0-9]+/g, '').length) { + value = null; } else { - if (languages[currentLanguage].delimiters.decimal !== '.') { - string = string.replace(/\./g,'').replace(languages[currentLanguage].delimiters.decimal, '.'); - } + for (kind in formats) { + regexp = typeof formats[kind].regexps.unformat === 'function' ? formats[kind].regexps.unformat() : formats[kind].regexps.unformat; - // see if abbreviations are there so that we can multiply to the correct number - thousandRegExp = new RegExp('[^a-zA-Z]' + languages[currentLanguage].abbreviations.thousand + '(?:\\)|(\\' + languages[currentLanguage].currency.symbol + ')?(?:\\))?)?$'); - millionRegExp = new RegExp('[^a-zA-Z]' + languages[currentLanguage].abbreviations.million + '(?:\\)|(\\' + languages[currentLanguage].currency.symbol + ')?(?:\\))?)?$'); - billionRegExp = new RegExp('[^a-zA-Z]' + languages[currentLanguage].abbreviations.billion + '(?:\\)|(\\' + languages[currentLanguage].currency.symbol + ')?(?:\\))?)?$'); - trillionRegExp = new RegExp('[^a-zA-Z]' + languages[currentLanguage].abbreviations.trillion + '(?:\\)|(\\' + languages[currentLanguage].currency.symbol + ')?(?:\\))?)?$'); + if (regexp && input.match(regexp)) { + unformatFunction = formats[kind].unformat; - // see if bytes are there so that we can multiply to the correct number - for (power = 0; power <= suffixes.length; power++) { - bytesMultiplier = (string.indexOf(suffixes[power]) > -1) ? Math.pow(1024, power + 1) : false; - - if (bytesMultiplier) { break; } } - // do some math to create our number - n._value = ((bytesMultiplier) ? bytesMultiplier : 1) * ((stringOriginal.match(thousandRegExp)) ? Math.pow(10, 3) : 1) * ((stringOriginal.match(millionRegExp)) ? Math.pow(10, 6) : 1) * ((stringOriginal.match(billionRegExp)) ? Math.pow(10, 9) : 1) * ((stringOriginal.match(trillionRegExp)) ? Math.pow(10, 12) : 1) * ((string.indexOf('%') > -1) ? 0.01 : 1) * (((string.split('-').length + Math.min(string.split('(').length-1, string.split(')').length-1)) % 2)? 1: -1) * Number(string.replace(/[^0-9\.]+/g, '')); + unformatFunction = unformatFunction || numeral._.stringToNumber; - // round if we are talking about bytes - n._value = (bytesMultiplier) ? Math.ceil(n._value) : n._value; + value = unformatFunction(input); } - } - return n._value; - } - - function formatCurrency (n, format, roundingFunction) { - var symbolIndex = format.indexOf('$'), - openParenIndex = format.indexOf('('), - minusSignIndex = format.indexOf('-'), - space = '', - spliceIndex, - output; - - // check for space before or after currency - if (format.indexOf(' $') > -1) { - space = ' '; - format = format.replace(' $', ''); - } else if (format.indexOf('$ ') > -1) { - space = ' '; - format = format.replace('$ ', ''); } else { - format = format.replace('$', ''); + value = Number(input)|| null; } - // format the number - output = formatNumber(n._value, format, roundingFunction); - - // position the symbol - if (symbolIndex <= 1) { - if (output.indexOf('(') > -1 || output.indexOf('-') > -1) { - output = output.split(''); - spliceIndex = 1; - if (symbolIndex < openParenIndex || symbolIndex < minusSignIndex){ - // the symbol appears before the "(" or "-" - spliceIndex = 0; - } - output.splice(spliceIndex, 0, languages[currentLanguage].currency.symbol + space); - output = output.join(''); - } else { - output = languages[currentLanguage].currency.symbol + space + output; - } - } else { - if (output.indexOf(')') > -1) { - output = output.split(''); - output.splice(-1, 0, space + languages[currentLanguage].currency.symbol); - output = output.join(''); - } else { - output = output + space + languages[currentLanguage].currency.symbol; - } - } - - return output; - } - - function formatPercentage (n, format, roundingFunction) { - var space = '', - output, - value = n._value * 100; - - // check for space before % - if (format.indexOf(' %') > -1) { - space = ' '; - format = format.replace(' %', ''); - } else { - format = format.replace('%', ''); - } - - output = formatNumber(value, format, roundingFunction); - - if (output.indexOf(')') > -1 ) { - output = output.split(''); - output.splice(-1, 0, space + '%'); - output = output.join(''); - } else { - output = output + space + '%'; - } + return new Numeral(input, value); + }; - return output; - } + // version number + numeral.version = VERSION; - function formatTime (n) { - var hours = Math.floor(n._value/60/60), - minutes = Math.floor((n._value - (hours * 60 * 60))/60), - seconds = Math.round(n._value - (hours * 60 * 60) - (minutes * 60)); - return hours + ':' + ((minutes < 10) ? '0' + minutes : minutes) + ':' + ((seconds < 10) ? '0' + seconds : seconds); - } + // compare numeral object + numeral.isNumeral = function(obj) { + return obj instanceof Numeral; + }; - function unformatTime (string) { - var timeArray = string.split(':'), - seconds = 0; - // turn hours and minutes into seconds and add them all up - if (timeArray.length === 3) { - // hours - seconds = seconds + (Number(timeArray[0]) * 60 * 60); - // minutes - seconds = seconds + (Number(timeArray[1]) * 60); - // seconds - seconds = seconds + Number(timeArray[2]); - } else if (timeArray.length === 2) { - // minutes - seconds = seconds + (Number(timeArray[0]) * 60); - // seconds - seconds = seconds + Number(timeArray[1]); - } - return Number(seconds); - } + // helper functions + numeral._ = _ = { + // formats numbers separators, decimals places, signs, abbreviations + numberToFormat: function(value, format, roundingFunction) { + var locale = locales[numeral.options.currentLocale], + negP = false, + optDec = false, + leadingCount = 0, + abbr = '', + trillion = 1000000000000, + billion = 1000000000, + million = 1000000, + thousand = 1000, + decimal = '', + neg = false, + abbrForce, // force abbreviation + abs, + min, + max, + power, + int, + precision, + signed, + thousands, + output; + + // make sure we never format a null value + value = value || 0; + + abs = Math.abs(value); - function formatNumber (value, format, roundingFunction) { - var negP = false, - signed = false, - optDec = false, - abbr = '', - abbrK = false, // force abbreviation to thousands - abbrM = false, // force abbreviation to millions - abbrB = false, // force abbreviation to billions - abbrT = false, // force abbreviation to trillions - abbrForce = false, // force abbreviation - bytes = '', - ord = '', - abs = Math.abs(value), - suffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], - min, - max, - power, - w, - precision, - thousands, - d = '', - neg = false; - - // check if number is zero and a custom zero format has been set - if (value === 0 && zeroFormat !== null) { - return zeroFormat; - } else { // see if we should use parentheses for negative number or if we should prefix with a sign // if both are present we default to parentheses - if (format.indexOf('(') > -1) { + if (numeral._.includes(format, '(')) { negP = true; - format = format.slice(1, -1); - } else if (format.indexOf('+') > -1) { - signed = true; - format = format.replace(/\+/g, ''); + format = format.replace(/[\(|\)]/g, ''); + } else if (numeral._.includes(format, '+') || numeral._.includes(format, '-')) { + signed = numeral._.includes(format, '+') ? format.indexOf('+') : value < 0 ? format.indexOf('-') : -1; + format = format.replace(/[\+|\-]/g, ''); } // see if abbreviation is wanted - if (format.indexOf('a') > -1) { - // check if abbreviation is specified - abbrK = format.indexOf('aK') >= 0; - abbrM = format.indexOf('aM') >= 0; - abbrB = format.indexOf('aB') >= 0; - abbrT = format.indexOf('aT') >= 0; - abbrForce = abbrK || abbrM || abbrB || abbrT; + if (numeral._.includes(format, 'a')) { + abbrForce = format.match(/a(k|m|b|t)?/); + + abbrForce = abbrForce ? abbrForce[1] : false; // check for space before abbreviation - if (format.indexOf(' a') > -1) { + if (numeral._.includes(format, ' a')) { abbr = ' '; - format = format.replace(' a', ''); - } else { - format = format.replace('a', ''); } - if (abs >= Math.pow(10, 12) && !abbrForce || abbrT) { + format = format.replace(new RegExp(abbr + 'a[kmbt]?'), ''); + + if (abs >= trillion && !abbrForce || abbrForce === 't') { // trillion - abbr = abbr + languages[currentLanguage].abbreviations.trillion; - value = value / Math.pow(10, 12); - } else if (abs < Math.pow(10, 12) && abs >= Math.pow(10, 9) && !abbrForce || abbrB) { + abbr += locale.abbreviations.trillion; + value = value / trillion; + } else if (abs < trillion && abs >= billion && !abbrForce || abbrForce === 'b') { // billion - abbr = abbr + languages[currentLanguage].abbreviations.billion; - value = value / Math.pow(10, 9); - } else if (abs < Math.pow(10, 9) && abs >= Math.pow(10, 6) && !abbrForce || abbrM) { + abbr += locale.abbreviations.billion; + value = value / billion; + } else if (abs < billion && abs >= million && !abbrForce || abbrForce === 'm') { // million - abbr = abbr + languages[currentLanguage].abbreviations.million; - value = value / Math.pow(10, 6); - } else if (abs < Math.pow(10, 6) && abs >= Math.pow(10, 3) && !abbrForce || abbrK) { + abbr += locale.abbreviations.million; + value = value / million; + } else if (abs < million && abs >= thousand && !abbrForce || abbrForce === 'k') { // thousand - abbr = abbr + languages[currentLanguage].abbreviations.thousand; - value = value / Math.pow(10, 3); - } - } - - // see if we are formatting bytes - if (format.indexOf('b') > -1) { - // check for space before - if (format.indexOf(' b') > -1) { - bytes = ' '; - format = format.replace(' b', ''); - } else { - format = format.replace('b', ''); - } - - for (power = 0; power <= suffixes.length; power++) { - min = Math.pow(1024, power); - max = Math.pow(1024, power+1); - - if (value >= min && value < max) { - bytes = bytes + suffixes[power]; - if (min > 0) { - value = value / min; - } - break; - } + abbr += locale.abbreviations.thousand; + value = value / thousand; } } - // see if ordinal is wanted - if (format.indexOf('o') > -1) { - // check for space before - if (format.indexOf(' o') > -1) { - ord = ' '; - format = format.replace(' o', ''); - } else { - format = format.replace('o', ''); - } - - ord = ord + languages[currentLanguage].ordinal(value); - } - - if (format.indexOf('[.]') > -1) { + // check for optional decimals + if (numeral._.includes(format, '[.]')) { optDec = true; format = format.replace('[.]', '.'); } - w = value.toString().split('.')[0]; + // break number and format + int = value.toString().split('.')[0]; precision = format.split('.')[1]; thousands = format.indexOf(','); + leadingCount = (format.split('.')[0].split(',')[0].match(/0/g) || []).length; if (precision) { - if (precision.indexOf('[') > -1) { + if (numeral._.includes(precision, '[')) { precision = precision.replace(']', ''); precision = precision.split('['); - d = toFixed(value, (precision[0].length + precision[1].length), roundingFunction, precision[1].length); + decimal = numeral._.toFixed(value, (precision[0].length + precision[1].length), roundingFunction, precision[1].length); } else { - d = toFixed(value, precision.length, roundingFunction); + decimal = numeral._.toFixed(value, precision.length, roundingFunction); } - w = d.split('.')[0]; + int = decimal.split('.')[0]; - if (d.split('.')[1].length) { - d = languages[currentLanguage].delimiters.decimal + d.split('.')[1]; + if (numeral._.includes(decimal, '.')) { + decimal = locale.delimiters.decimal + decimal.split('.')[1]; } else { - d = ''; + decimal = ''; } - if (optDec && Number(d.slice(1)) === 0) { - d = ''; + if (optDec && Number(decimal.slice(1)) === 0) { + decimal = ''; } } else { - w = toFixed(value, null, roundingFunction); + int = numeral._.toFixed(value, 0, roundingFunction); + } + + // check abbreviation again after rounding + if (abbr && !abbrForce && Number(int) >= 1000 && abbr !== locale.abbreviations.trillion) { + int = String(Number(int) / 1000); + + switch (abbr) { + case locale.abbreviations.thousand: + abbr = locale.abbreviations.million; + break; + case locale.abbreviations.million: + abbr = locale.abbreviations.billion; + break; + case locale.abbreviations.billion: + abbr = locale.abbreviations.trillion; + break; + } } + // format number - if (w.indexOf('-') > -1) { - w = w.slice(1); + if (numeral._.includes(int, '-')) { + int = int.slice(1); neg = true; } + if (int.length < leadingCount) { + for (var i = leadingCount - int.length; i > 0; i--) { + int = '0' + int; + } + } + if (thousands > -1) { - w = w.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + languages[currentLanguage].delimiters.thousands); + int = int.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + locale.delimiters.thousands); } if (format.indexOf('.') === 0) { - w = ''; + int = ''; + } + + output = int + decimal + (abbr ? abbr : ''); + + if (negP) { + output = (negP && neg ? '(' : '') + output + (negP && neg ? ')' : ''); + } else { + if (signed >= 0) { + output = signed === 0 ? (neg ? '-' : '+') + output : output + (neg ? '-' : '+'); + } else if (neg) { + output = '-' + output; + } + } + + return output; + }, + // unformats numbers separators, decimals places, signs, abbreviations + stringToNumber: function(string) { + var locale = locales[options.currentLocale], + stringOriginal = string, + abbreviations = { + thousand: 3, + million: 6, + billion: 9, + trillion: 12 + }, + abbreviation, + value, + i, + regexp; + + if (options.zeroFormat && string === options.zeroFormat) { + value = 0; + } else if (options.nullFormat && string === options.nullFormat || !string.replace(/[^0-9]+/g, '').length) { + value = null; + } else { + value = 1; + + if (locale.delimiters.decimal !== '.') { + string = string.replace(/\./g, '').replace(locale.delimiters.decimal, '.'); + } + + for (abbreviation in abbreviations) { + regexp = new RegExp('[^a-zA-Z]' + locale.abbreviations[abbreviation] + '(?:\\)|(\\' + locale.currency.symbol + ')?(?:\\))?)?$'); + + if (stringOriginal.match(regexp)) { + value *= Math.pow(10, abbreviations[abbreviation]); + break; + } + } + + // check for negative number + value *= (string.split('-').length + Math.min(string.split('(').length - 1, string.split(')').length - 1)) % 2 ? 1 : -1; + + // remove non numbers + string = string.replace(/[^0-9\.]+/g, ''); + + value *= Number(string); } - return ((negP && neg) ? '(' : '') + ((!negP && neg) ? '-' : '') + ((!neg && signed) ? '+' : '') + w + d + ((ord) ? ord : '') + ((abbr) ? abbr : '') + ((bytes) ? bytes : '') + ((negP && neg) ? ')' : ''); + return value; + }, + isNaN: function(value) { + return typeof value === 'number' && isNaN(value); + }, + includes: function(string, search) { + return string.indexOf(search) !== -1; + }, + insert: function(string, subString, start) { + return string.slice(0, start) + subString + string.slice(start); + }, + reduce: function(array, callback /*, initialValue*/) { + if (this === null) { + throw new TypeError('Array.prototype.reduce called on null or undefined'); + } + + if (typeof callback !== 'function') { + throw new TypeError(callback + ' is not a function'); + } + + var t = Object(array), + len = t.length >>> 0, + k = 0, + value; + + if (arguments.length === 3) { + value = arguments[2]; + } else { + while (k < len && !(k in t)) { + k++; + } + + if (k >= len) { + throw new TypeError('Reduce of empty array with no initial value'); + } + + value = t[k++]; + } + for (; k < len; k++) { + if (k in t) { + value = callback(value, t[k], k, t); + } + } + return value; + }, + /** + * Computes the multiplier necessary to make x >= 1, + * effectively eliminating miscalculations caused by + * finite precision. + */ + multiplier: function (x) { + var parts = x.toString().split('.'); + + return parts.length < 2 ? 1 : Math.pow(10, parts[1].length); + }, + /** + * Given a variable number of arguments, returns the maximum + * multiplier that must be used to normalize an operation involving + * all of them. + */ + correctionFactor: function () { + var args = Array.prototype.slice.call(arguments); + + return args.reduce(function(accum, next) { + var mn = _.multiplier(next); + return accum > mn ? accum : mn; + }, 1); + }, + /** + * Implementation of toFixed() that treats floats more like decimals + * + * Fixes binary rounding issues (eg. (0.615).toFixed(2) === '0.61') that present + * problems for accounting- and finance-related software. + */ + toFixed: function(value, maxDecimals, roundingFunction, optionals) { + var splitValue = value.toString().split('.'), + minDecimals = maxDecimals - (optionals || 0), + boundedPrecision, + optionalsRegExp, + power, + output; + + // Use the smallest precision value possible to avoid errors from floating point representation + if (splitValue.length === 2) { + boundedPrecision = Math.min(Math.max(splitValue[1].length, minDecimals), maxDecimals); + } else { + boundedPrecision = minDecimals; + } + + power = Math.pow(10, boundedPrecision); + + // Multiply up by precision, round accurately, then divide and use native toFixed(): + output = (roundingFunction(value + 'e+' + boundedPrecision) / power).toFixed(boundedPrecision); + + if (optionals > maxDecimals - boundedPrecision) { + optionalsRegExp = new RegExp('\\.?0{1,' + (optionals - (maxDecimals - boundedPrecision)) + '}$'); + output = output.replace(optionalsRegExp, ''); + } + + return output; } - } + }; - /************************************ - Top Level Functions - ************************************/ + // avaliable options + numeral.options = options; - numeral = function (input) { - if (numeral.isNumeral(input)) { - input = input.value(); - } else if (input === 0 || typeof input === 'undefined') { - input = 0; - } else if (!Number(input)) { - input = numeral.fn.unformat(input); + // avaliable formats + numeral.formats = formats; + + // avaliable formats + numeral.locales = locales; + + // This function sets the current locale. If + // no arguments are passed in, it will simply return the current global + // locale key. + numeral.locale = function(key) { + if (key) { + options.currentLocale = key.toLowerCase(); } - return new Numeral(Number(input)); + return options.currentLocale; }; - // version number - numeral.version = VERSION; + // This function provides access to the loaded locale data. If + // no arguments are passed in, it will simply return the current + // global locale object. + numeral.localeData = function(key) { + if (!key) { + return locales[options.currentLocale]; + } - // compare numeral object - numeral.isNumeral = function (obj) { - return obj instanceof Numeral; + key = key.toLowerCase(); + + if (!locales[key]) { + throw new Error('Unknown locale : ' + key); + } + + return locales[key]; }; - // This function will load languages and then set the global language. If - // no arguments are passed in, it will simply return the current global - // language key. - numeral.language = function (key, values) { - if (!key) { - return currentLanguage; + numeral.reset = function() { + for (var property in defaults) { + options[property] = defaults[property]; } + }; + + numeral.zeroFormat = function(format) { + options.zeroFormat = typeof(format) === 'string' ? format : null; + }; + + numeral.nullFormat = function (format) { + options.nullFormat = typeof(format) === 'string' ? format : null; + }; + + numeral.defaultFormat = function(format) { + options.defaultFormat = typeof(format) === 'string' ? format : '0.0'; + }; - if (key && !values) { - if(!languages[key]) { - throw new Error('Unknown language : ' + key); + numeral.register = function(type, name, format) { + name = name.toLowerCase(); + + if (this[type + 's'][name]) { + throw new TypeError(name + ' ' + type + ' already registered.'); + } + + this[type + 's'][name] = format; + + return format; + }; + + + numeral.validate = function(val, culture) { + var _decimalSep, + _thousandSep, + _currSymbol, + _valArray, + _abbrObj, + _thousandRegEx, + localeData, + temp; + + //coerce val to string + if (typeof val !== 'string') { + val += ''; + + if (console.warn) { + console.warn('Numeral.js: Value is not string. It has been co-erced to: ', val); } - currentLanguage = key; } - if (values || !languages[key]) { - loadLanguage(key, values); + //trim whitespaces from either sides + val = val.trim(); + + //if val is just digits return true + if (!!val.match(/^\d+$/)) { + return true; } - return numeral; - }; - - // This function provides access to the loaded language data. If - // no arguments are passed in, it will simply return the current - // global language object. - numeral.languageData = function (key) { - if (!key) { - return languages[currentLanguage]; + //if val is empty return false + if (val === '') { + return false; + } + + //get the decimal and thousands separator from numeral.localeData + try { + //check if the culture is understood by numeral. if not, default it to current locale + localeData = numeral.localeData(culture); + } catch (e) { + localeData = numeral.localeData(numeral.locale()); } - - if (!languages[key]) { - throw new Error('Unknown language : ' + key); + + //setup the delimiters and currency symbol based on culture/locale + _currSymbol = localeData.currency.symbol; + _abbrObj = localeData.abbreviations; + _decimalSep = localeData.delimiters.decimal; + if (localeData.delimiters.thousands === '.') { + _thousandSep = '\\.'; + } else { + _thousandSep = localeData.delimiters.thousands; + } + + // validating currency symbol + temp = val.match(/^[^\d]+/); + if (temp !== null) { + val = val.substr(1); + if (temp[0] !== _currSymbol) { + return false; + } + } + + //validating abbreviation symbol + temp = val.match(/[^\d]+$/); + if (temp !== null) { + val = val.slice(0, -1); + if (temp[0] !== _abbrObj.thousand && temp[0] !== _abbrObj.million && temp[0] !== _abbrObj.billion && temp[0] !== _abbrObj.trillion) { + return false; + } + } + + _thousandRegEx = new RegExp(_thousandSep + '{2}'); + + if (!val.match(/[^\d.,]/g)) { + _valArray = val.split(_decimalSep); + if (_valArray.length > 2) { + return false; + } else { + if (_valArray.length < 2) { + return ( !! _valArray[0].match(/^\d+.*\d$/) && !_valArray[0].match(_thousandRegEx)); + } else { + if (_valArray[0].length === 1) { + return ( !! _valArray[0].match(/^\d+$/) && !_valArray[0].match(_thousandRegEx) && !! _valArray[1].match(/^\d+$/)); + } else { + return ( !! _valArray[0].match(/^\d+.*\d$/) && !_valArray[0].match(_thousandRegEx) && !! _valArray[1].match(/^\d+$/)); + } + } + } + } + + return false; + }; + + + /************************************ + Numeral Prototype + ************************************/ + + numeral.fn = Numeral.prototype = { + clone: function() { + return numeral(this); + }, + format: function(inputString, roundingFunction) { + var value = this._value, + format = inputString || options.defaultFormat, + kind, + output, + formatFunction; + + // make sure we have a roundingFunction + roundingFunction = roundingFunction || Math.round; + + // format based on value + if (value === 0 && options.zeroFormat !== null) { + output = options.zeroFormat; + } else if (value === null && options.nullFormat !== null) { + output = options.nullFormat; + } else { + for (kind in formats) { + if (format.match(formats[kind].regexps.format)) { + formatFunction = formats[kind].format; + + break; + } + } + + formatFunction = formatFunction || numeral._.numberToFormat; + + output = formatFunction(value, format, roundingFunction); + } + + return output; + }, + value: function() { + return this._value; + }, + input: function() { + return this._input; + }, + set: function(value) { + this._value = Number(value); + + return this; + }, + add: function(value) { + var corrFactor = _.correctionFactor.call(null, this._value, value); + + function cback(accum, curr, currI, O) { + return accum + Math.round(corrFactor * curr); + } + + this._value = _.reduce([this._value, value], cback, 0) / corrFactor; + + return this; + }, + subtract: function(value) { + var corrFactor = _.correctionFactor.call(null, this._value, value); + + function cback(accum, curr, currI, O) { + return accum - Math.round(corrFactor * curr); + } + + this._value = _.reduce([value], cback, Math.round(this._value * corrFactor)) / corrFactor; + + return this; + }, + multiply: function(value) { + function cback(accum, curr, currI, O) { + var corrFactor = _.correctionFactor(accum, curr); + return Math.round(accum * corrFactor) * Math.round(curr * corrFactor) / Math.round(corrFactor * corrFactor); + } + + this._value = _.reduce([this._value, value], cback, 1); + + return this; + }, + divide: function(value) { + function cback(accum, curr, currI, O) { + var corrFactor = _.correctionFactor(accum, curr); + return Math.round(accum * corrFactor) / Math.round(curr * corrFactor); + } + + this._value = _.reduce([this._value, value], cback); + + return this; + }, + difference: function(value) { + return Math.abs(numeral(this._value).subtract(value).value()); } - - return languages[key]; }; - numeral.language('en', { + /************************************ + Default Locale && Format + ************************************/ + + numeral.register('locale', 'en', { delimiters: { thousands: ',', decimal: '.' @@ -460,9 +677,9 @@ billion: 'b', trillion: 't' }, - ordinal: function (number) { + ordinal: function(number) { var b = number % 10; - return (~~ (number % 100 / 10) === 1) ? 'th' : + return (~~(number % 100 / 10) === 1) ? 'th' : (b === 1) ? 'st' : (b === 2) ? 'nd' : (b === 3) ? 'rd' : 'th'; @@ -472,208 +689,325 @@ } }); - numeral.zeroFormat = function (format) { - zeroFormat = typeof(format) === 'string' ? format : null; - }; + - numeral.defaultFormat = function (format) { - defaultFormat = typeof(format) === 'string' ? format : '0.0'; - }; +(function() { + numeral.register('format', 'bps', { + regexps: { + format: /(BPS)/, + unformat: /(BPS)/ + }, + format: function(value, format, roundingFunction) { + var space = numeral._.includes(format, ' BPS') ? ' ' : '', + output; - /************************************ - Helpers - ************************************/ + value = value * 10000; - function loadLanguage(key, values) { - languages[key] = values; - } + // check for space before BPS + format = format.replace(/\s?BPS/, ''); - /************************************ - Floating-point helpers - ************************************/ + output = numeral._.numberToFormat(value, format, roundingFunction); - // The floating-point helper functions and implementation - // borrows heavily from sinful.js: http://guipn.github.io/sinful.js/ - - /** - * Array.prototype.reduce for browsers that don't support it - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce#Compatibility - */ - if ('function' !== typeof Array.prototype.reduce) { - Array.prototype.reduce = function (callback, opt_initialValue) { - 'use strict'; - - if (null === this || 'undefined' === typeof this) { - // At the moment all modern browsers, that support strict mode, have - // native implementation of Array.prototype.reduce. For instance, IE8 - // does not support strict mode, so this check is actually useless. - throw new TypeError('Array.prototype.reduce called on null or undefined'); - } - - if ('function' !== typeof callback) { - throw new TypeError(callback + ' is not a function'); - } + if (numeral._.includes(output, ')')) { + output = output.split(''); - var index, - value, - length = this.length >>> 0, - isValueSet = false; + output.splice(-1, 0, space + 'BPS'); - if (1 < arguments.length) { - value = opt_initialValue; - isValueSet = true; + output = output.join(''); + } else { + output = output + space + 'BPS'; + } + + return output; + }, + unformat: function(string) { + return +(numeral._.stringToNumber(string) * 0.0001).toFixed(15); } + }); +})(); - for (index = 0; length > index; ++index) { - if (this.hasOwnProperty(index)) { - if (isValueSet) { - value = callback(value, this[index], index, this); - } else { - value = this[index]; - isValueSet = true; + +(function() { + var decimal = { + base: 1000, + suffixes: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] + }, + binary = { + base: 1024, + suffixes: ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'] + }; + + var allSuffixes = decimal.suffixes.concat(binary.suffixes.filter(function (item) { + return decimal.suffixes.indexOf(item) < 0; + })); + var unformatRegex = allSuffixes.join('|'); + // Allow support for BPS (http://www.investopedia.com/terms/b/basispoint.asp) + unformatRegex = '(' + unformatRegex.replace('B', 'B(?!PS)') + ')'; + + numeral.register('format', 'bytes', { + regexps: { + format: /([0\s]i?b)/, + unformat: new RegExp(unformatRegex) + }, + format: function(value, format, roundingFunction) { + var output, + bytes = numeral._.includes(format, 'ib') ? binary : decimal, + suffix = numeral._.includes(format, ' b') || numeral._.includes(format, ' ib') ? ' ' : '', + power, + min, + max; + + // check for space before + format = format.replace(/\s?i?b/, ''); + + for (power = 0; power <= bytes.suffixes.length; power++) { + min = Math.pow(bytes.base, power); + max = Math.pow(bytes.base, power + 1); + + if (value === null || value === 0 || value >= min && value < max) { + suffix += bytes.suffixes[power]; + + if (min > 0) { + value = value / min; } + + break; } } - if (!isValueSet) { - throw new TypeError('Reduce of empty array with no initial value'); - } + output = numeral._.numberToFormat(value, format, roundingFunction); - return value; - }; - } + return output + suffix; + }, + unformat: function(string) { + var value = numeral._.stringToNumber(string), + power, + bytesMultiplier; - - /** - * Computes the multiplier necessary to make x >= 1, - * effectively eliminating miscalculations caused by - * finite precision. - */ - function multiplier(x) { - var parts = x.toString().split('.'); - if (parts.length < 2) { - return 1; - } - return Math.pow(10, parts[1].length); - } + if (value) { + for (power = decimal.suffixes.length - 1; power >= 0; power--) { + if (numeral._.includes(string, decimal.suffixes[power])) { + bytesMultiplier = Math.pow(decimal.base, power); - /** - * Given a variable number of arguments, returns the maximum - * multiplier that must be used to normalize an operation involving - * all of them. - */ - function correctionFactor() { - var args = Array.prototype.slice.call(arguments); - return args.reduce(function (prev, next) { - var mp = multiplier(prev), - mn = multiplier(next); - return mp > mn ? mp : mn; - }, -Infinity); - } + break; + } + if (numeral._.includes(string, binary.suffixes[power])) { + bytesMultiplier = Math.pow(binary.base, power); - /************************************ - Numeral Prototype - ************************************/ + break; + } + } + value *= (bytesMultiplier || 1); + } - numeral.fn = Numeral.prototype = { + return value; + } + }); +})(); - clone : function () { - return numeral(this); - }, - format : function (inputString, roundingFunction) { - return formatNumeral(this, - inputString ? inputString : defaultFormat, - (roundingFunction !== undefined) ? roundingFunction : Math.round - ); +(function() { + numeral.register('format', 'currency', { + regexps: { + format: /(\$)/ }, + format: function(value, format, roundingFunction) { + var locale = numeral.locales[numeral.options.currentLocale], + symbols = { + before: format.match(/^([\+|\-|\(|\s|\$]*)/)[0], + after: format.match(/([\+|\-|\)|\s|\$]*)$/)[0] + }, + output, + symbol, + i; + + // strip format of spaces and $ + format = format.replace(/\s?\$\s?/, ''); + + // format the number + output = numeral._.numberToFormat(value, format, roundingFunction); + + // update the before and after based on value + if (value >= 0) { + symbols.before = symbols.before.replace(/[\-\(]/, ''); + symbols.after = symbols.after.replace(/[\-\)]/, ''); + } else if (value < 0 && (!numeral._.includes(symbols.before, '-') && !numeral._.includes(symbols.before, '('))) { + symbols.before = '-' + symbols.before; + } + + // loop through each before symbol + for (i = 0; i < symbols.before.length; i++) { + symbol = symbols.before[i]; - unformat : function (inputString) { - if (Object.prototype.toString.call(inputString) === '[object Number]') { - return inputString; + switch (symbol) { + case '$': + output = numeral._.insert(output, locale.currency.symbol, i); + break; + case ' ': + output = numeral._.insert(output, ' ', i + locale.currency.symbol.length - 1); + break; + } } - return unformatNumeral(this, inputString ? inputString : defaultFormat); - }, - value : function () { - return this._value; - }, + // loop through each after symbol + for (i = symbols.after.length - 1; i >= 0; i--) { + symbol = symbols.after[i]; - valueOf : function () { - return this._value; + switch (symbol) { + case '$': + output = i === symbols.after.length - 1 ? output + locale.currency.symbol : numeral._.insert(output, locale.currency.symbol, -(symbols.after.length - (1 + i))); + break; + case ' ': + output = i === symbols.after.length - 1 ? output + ' ' : numeral._.insert(output, ' ', -(symbols.after.length - (1 + i) + locale.currency.symbol.length - 1)); + break; + } + } + + + return output; + } + }); +})(); + + +(function() { + numeral.register('format', 'exponential', { + regexps: { + format: /(e\+|e-)/, + unformat: /(e\+|e-)/ }, + format: function(value, format, roundingFunction) { + var output, + exponential = typeof value === 'number' && !numeral._.isNaN(value) ? value.toExponential() : '0e+0', + parts = exponential.split('e'); - set : function (value) { - this._value = Number(value); - return this; + format = format.replace(/e[\+|\-]{1}0/, ''); + + output = numeral._.numberToFormat(Number(parts[0]), format, roundingFunction); + + return output + 'e' + parts[1]; }, + unformat: function(string) { + var parts = numeral._.includes(string, 'e+') ? string.split('e+') : string.split('e-'), + value = Number(parts[0]), + power = Number(parts[1]); + + power = numeral._.includes(string, 'e-') ? power *= -1 : power; - add : function (value) { - var corrFactor = correctionFactor.call(null, this._value, value); function cback(accum, curr, currI, O) { - return accum + corrFactor * curr; + var corrFactor = numeral._.correctionFactor(accum, curr), + num = (accum * corrFactor) * (curr * corrFactor) / (corrFactor * corrFactor); + return num; } - this._value = [this._value, value].reduce(cback, 0) / corrFactor; - return this; + + return numeral._.reduce([value, Math.pow(10, power)], cback, 1); + } + }); +})(); + + +(function() { + numeral.register('format', 'ordinal', { + regexps: { + format: /(o)/ }, + format: function(value, format, roundingFunction) { + var locale = numeral.locales[numeral.options.currentLocale], + output, + ordinal = numeral._.includes(format, ' o') ? ' ' : ''; - subtract : function (value) { - var corrFactor = correctionFactor.call(null, this._value, value); - function cback(accum, curr, currI, O) { - return accum - corrFactor * curr; - } - this._value = [value].reduce(cback, this._value * corrFactor) / corrFactor; - return this; + // check for space before + format = format.replace(/\s?o/, ''); + + ordinal += locale.ordinal(value); + + output = numeral._.numberToFormat(value, format, roundingFunction); + + return output + ordinal; + } + }); +})(); + + +(function() { + numeral.register('format', 'percentage', { + regexps: { + format: /(%)/, + unformat: /(%)/ }, + format: function(value, format, roundingFunction) { + var space = numeral._.includes(format, ' %') ? ' ' : '', + output; - multiply : function (value) { - function cback(accum, curr, currI, O) { - var corrFactor = correctionFactor(accum, curr); - return (accum * corrFactor) * (curr * corrFactor) / - (corrFactor * corrFactor); + if (numeral.options.scalePercentBy100) { + value = value * 100; } - this._value = [this._value, value].reduce(cback, 1); - return this; - }, - divide : function (value) { - function cback(accum, curr, currI, O) { - var corrFactor = correctionFactor(accum, curr); - return (accum * corrFactor) / (curr * corrFactor); + // check for space before % + format = format.replace(/\s?\%/, ''); + + output = numeral._.numberToFormat(value, format, roundingFunction); + + if (numeral._.includes(output, ')')) { + output = output.split(''); + + output.splice(-1, 0, space + '%'); + + output = output.join(''); + } else { + output = output + space + '%'; } - this._value = [this._value, value].reduce(cback); - return this; - }, - difference : function (value) { - return Math.abs(numeral(this._value).subtract(value).value()); + return output; + }, + unformat: function(string) { + var number = numeral._.stringToNumber(string); + if (numeral.options.scalePercentBy100) { + return number * 0.01; + } + return number; } + }); +})(); - }; - /************************************ - Exposing Numeral - ************************************/ - - // CommonJS module is defined - if (hasModule) { - module.exports = numeral; - } +(function() { + numeral.register('format', 'time', { + regexps: { + format: /(:)/, + unformat: /(:)/ + }, + format: function(value, format, roundingFunction) { + var hours = Math.floor(value / 60 / 60), + minutes = Math.floor((value - (hours * 60 * 60)) / 60), + seconds = Math.round(value - (hours * 60 * 60) - (minutes * 60)); - /*global ender:false */ - if (typeof ender === 'undefined') { - // here, `this` means `window` in the browser, or `global` on the server - // add `numeral` as a global object via a string identifier, - // for Closure Compiler 'advanced' mode - this['numeral'] = numeral; - } + return hours + ':' + (minutes < 10 ? '0' + minutes : minutes) + ':' + (seconds < 10 ? '0' + seconds : seconds); + }, + unformat: function(string) { + var timeArray = string.split(':'), + seconds = 0; + + // turn hours and minutes into seconds and add them all up + if (timeArray.length === 3) { + // hours + seconds = seconds + (Number(timeArray[0]) * 60 * 60); + // minutes + seconds = seconds + (Number(timeArray[1]) * 60); + // seconds + seconds = seconds + Number(timeArray[2]); + } else if (timeArray.length === 2) { + // minutes + seconds = seconds + (Number(timeArray[0]) * 60); + // seconds + seconds = seconds + Number(timeArray[1]); + } + return Number(seconds); + } + }); +})(); - /*global define:false */ - if (typeof define === 'function' && define.amd) { - define([], function () { - return numeral; - }); - } -}).call(this); +return numeral; +})); diff --git a/package.json b/package.json index 5e80aef9..d3dafc78 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "numeral", - "version": "1.5.3", + "version": "2.0.6", "description": "Format and manipulate numbers.", "homepage": "http://numeraljs.com/", "author": { @@ -27,24 +27,33 @@ "bugs": { "url": "https://github.com/adamwdraper/Numeral-js/issues" }, - "licenses": [ - { - "type": "MIT" - } - ], + "license": "MIT", "devDependencies": { - "uglify-js": "latest", + "chai": "^3.5.0", "grunt": "latest", - "grunt-contrib-uglify": "latest", + "grunt-contrib-copy": "^1.0.0", "grunt-contrib-jshint": "latest", - "grunt-contrib-nodeunit": "~0.1.2", - "grunt-contrib-concat": "~0.3.0" + "grunt-contrib-nodeunit": "1.0.0", + "grunt-contrib-uglify": "latest", + "grunt-karma": "^2.0.0", + "grunt-mocha-test": "^0.13.2", + "grunt-saucelabs": "*", + "grunt-string-replace": "^1.3.1", + "karma": "^1.3.0", + "karma-chai": "^0.1.0", + "karma-chrome-launcher": "^2.0.0", + "karma-firefox-launcher": "^1.0.0", + "karma-mocha": "^1.3.0", + "karma-mocha-reporter": "^2.2.1", + "karma-sauce-launcher": "^1.1.0", + "load-grunt-tasks": "^3.5.2", + "mocha": "^3.1.2", + "uglify-js": "latest" }, "scripts": { "test": "grunt" }, "ender": "./ender.js", - "readme": "[Numeral.js](http://numeraljs.com)\n=======================================================\n\nA javascript library for formatting and manipulating numbers.\n\n[Website and documentation](http://numeraljs.com)\n\nChangelog\n=========\n\n### 1.5.2\nBug fix: Unformat should pass through if given a number\n\nAdded a mechanism to control rounding behaviour\n\nAdded languageData() for getting and setting language props at runtime### 1.5.1\nBug fix: Make sure values aren't changed during formatting### 1.5.0\nAdd defaultFormat(). numeral().format() uses the default to format if no string is provided\n\n.unformat() returns 0 when passed no string\n\nAdded languages.js that contains all languages\n\nBug fix: Fix bug while unformatting ordinals\n\nAdd format option to always show signed value\n\nAdded ability to instantiate numeral with a string value of a number\n### 1.4.9\nBug fix: Fix bug while unformatting ordinals\n### 1.4.8\nBug fix: Throw error if language is not defined\n### 1.4.7\nBug fix: Fix typo for trillion\n### 1.4.6\nBug fix: remove ' from unformatting regex that was causing an error with fr-ch.js\n### 1.4.5\nAdd zeroFormat() function that accepts a string for custom formating of zeros\n\nAdd valueOf() function\n\nChain functionality to language function\n\nMake all minified files have the same .min.js filename ending\n### 1.4.1\nBug fix: Bytes not formatting correctly\n### 1.4.0\nAdd optional format for all decimals\n### 1.3.4\nRemove AMD module id. (This is encouraged by require.js to make the module more portable, and keep it from creating a global)\n### 1.3.3\nAMD define() compatibility.\n### 1.3.2\nBug fix: Formatting some numbers results in the wrong value. Issue #21\n### 1.3.1\nBug fix: Minor fix to unformatting parser\n### 1.3.0\nAdd support for spaces before/after $, a, o, b in a format string\nBug fix: Fix unformat for languages that use '.' in ordinals\nBug fix: Fix round up floating numbers with no precision correctly.\nBug fix: Fix currency signs at the end in unformat\n### 1.2.6\nAdd support for optional decimal places\n### 1.2.5\nAdd support for appending currency symbol\n### 1.2.4\nAdd support for humanized filesizes\n### 1.2.2\nChanged language definition property 'money' to 'currency'\n### 1.2.1\nBug fix: Fix unformatting non-negative abbreviations\n### 1.2.3\nBug Fix: Fix unformatting for languages that use '.' as thousands delimiter\n### 1.2.0\nAdd localization language support\n\nUpdate testing for to include languages\n### 1.1.0\nAdd Tests\n\nBug fix: Fix difference returning negative values\n### 1.0.4\nBug fix: Non negative numbers were displaying as negative when using parentheses\n### 1.0.3\nAdd ordinal formatting using 'o' in the format\n### 1.0.2\nAdd clone functionality\n### 1.0.1\n\nAdded abbreviations for thousands and millions using 'a' in the format\n\n### 1.0.0\n\nInitial release\n\nAcknowlegements\n===============\n\nNumeral.js, while less complex, was inspired by and heavily borrowed from [Moment.js](http://momentjs.com)\n\nLicense\n=======\nNumeral.js is freely distributable under the terms of the MIT license.\nCopyright (c) 2012 Adam Draper\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use,copy, 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:\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\nTHE 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.", - "_id": "numeral@1.5.2", + "_id": "numeral@1.5.4", "_from": "numeral" } diff --git a/src/formats/bps.js b/src/formats/bps.js new file mode 100644 index 00000000..72362ba7 --- /dev/null +++ b/src/formats/bps.js @@ -0,0 +1,47 @@ +// numeral.js format configuration +// format : BPS +// author : Jack Altiere : https://github.com/jaltiere +// BPS format - http://www.investopedia.com/terms/b/basispoint.asp + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('format', 'bps', { + regexps: { + format: /(BPS)/, + unformat: /(BPS)/ + }, + format: function(value, format, roundingFunction) { + var space = numeral._.includes(format, ' BPS') ? ' ' : '', + output; + + value = value * 10000; + + // check for space before BPS + format = format.replace(/\s?BPS/, ''); + + output = numeral._.numberToFormat(value, format, roundingFunction); + + if (numeral._.includes(output, ')')) { + output = output.split(''); + + output.splice(-1, 0, space + 'BPS'); + + output = output.join(''); + } else { + output = output + space + 'BPS'; + } + + return output; + }, + unformat: function(string) { + return +(numeral._.stringToNumber(string) * 0.0001).toFixed(15); + } + }); +})); diff --git a/src/formats/bytes.js b/src/formats/bytes.js new file mode 100644 index 00000000..a07a85da --- /dev/null +++ b/src/formats/bytes.js @@ -0,0 +1,91 @@ +// numeral.js format configuration +// format : bytes +// author : Adam Draper : https://github.com/adamwdraper + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + var decimal = { + base: 1000, + suffixes: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] + }, + binary = { + base: 1024, + suffixes: ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'] + }; + + var allSuffixes = decimal.suffixes.concat(binary.suffixes.filter(function (item) { + return decimal.suffixes.indexOf(item) < 0; + })); + var unformatRegex = allSuffixes.join('|'); + // Allow support for BPS (http://www.investopedia.com/terms/b/basispoint.asp) + unformatRegex = '(' + unformatRegex.replace('B', 'B(?!PS)') + ')'; + + numeral.register('format', 'bytes', { + regexps: { + format: /([0\s]i?b)/, + unformat: new RegExp(unformatRegex) + }, + format: function(value, format, roundingFunction) { + var output, + bytes = numeral._.includes(format, 'ib') ? binary : decimal, + suffix = numeral._.includes(format, ' b') || numeral._.includes(format, ' ib') ? ' ' : '', + power, + min, + max; + + // check for space before + format = format.replace(/\s?i?b/, ''); + + for (power = 0; power <= bytes.suffixes.length; power++) { + min = Math.pow(bytes.base, power); + max = Math.pow(bytes.base, power + 1); + + if (value === null || value === 0 || value >= min && value < max) { + suffix += bytes.suffixes[power]; + + if (min > 0) { + value = value / min; + } + + break; + } + } + + output = numeral._.numberToFormat(value, format, roundingFunction); + + return output + suffix; + }, + unformat: function(string) { + var value = numeral._.stringToNumber(string), + power, + bytesMultiplier; + + if (value) { + for (power = decimal.suffixes.length - 1; power >= 0; power--) { + if (numeral._.includes(string, decimal.suffixes[power])) { + bytesMultiplier = Math.pow(decimal.base, power); + + break; + } + + if (numeral._.includes(string, binary.suffixes[power])) { + bytesMultiplier = Math.pow(binary.base, power); + + break; + } + } + + value *= (bytesMultiplier || 1); + } + + return value; + } + }); +})); diff --git a/src/formats/currency.js b/src/formats/currency.js new file mode 100644 index 00000000..5a7c4eaa --- /dev/null +++ b/src/formats/currency.js @@ -0,0 +1,74 @@ +// numeral.js format configuration +// format : currency +// author : Adam Draper : https://github.com/adamwdraper + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('format', 'currency', { + regexps: { + format: /(\$)/ + }, + format: function(value, format, roundingFunction) { + var locale = numeral.locales[numeral.options.currentLocale], + symbols = { + before: format.match(/^([\+|\-|\(|\s|\$]*)/)[0], + after: format.match(/([\+|\-|\)|\s|\$]*)$/)[0] + }, + output, + symbol, + i; + + // strip format of spaces and $ + format = format.replace(/\s?\$\s?/, ''); + + // format the number + output = numeral._.numberToFormat(value, format, roundingFunction); + + // update the before and after based on value + if (value >= 0) { + symbols.before = symbols.before.replace(/[\-\(]/, ''); + symbols.after = symbols.after.replace(/[\-\)]/, ''); + } else if (value < 0 && (!numeral._.includes(symbols.before, '-') && !numeral._.includes(symbols.before, '('))) { + symbols.before = '-' + symbols.before; + } + + // loop through each before symbol + for (i = 0; i < symbols.before.length; i++) { + symbol = symbols.before[i]; + + switch (symbol) { + case '$': + output = numeral._.insert(output, locale.currency.symbol, i); + break; + case ' ': + output = numeral._.insert(output, ' ', i + locale.currency.symbol.length - 1); + break; + } + } + + // loop through each after symbol + for (i = symbols.after.length - 1; i >= 0; i--) { + symbol = symbols.after[i]; + + switch (symbol) { + case '$': + output = i === symbols.after.length - 1 ? output + locale.currency.symbol : numeral._.insert(output, locale.currency.symbol, -(symbols.after.length - (1 + i))); + break; + case ' ': + output = i === symbols.after.length - 1 ? output + ' ' : numeral._.insert(output, ' ', -(symbols.after.length - (1 + i) + locale.currency.symbol.length - 1)); + break; + } + } + + + return output; + } + }); +})); diff --git a/src/formats/exponential.js b/src/formats/exponential.js new file mode 100644 index 00000000..21459980 --- /dev/null +++ b/src/formats/exponential.js @@ -0,0 +1,46 @@ +// numeral.js format configuration +// format : exponential +// author : Adam Draper : https://github.com/adamwdraper + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('format', 'exponential', { + regexps: { + format: /(e\+|e-)/, + unformat: /(e\+|e-)/ + }, + format: function(value, format, roundingFunction) { + var output, + exponential = typeof value === 'number' && !numeral._.isNaN(value) ? value.toExponential() : '0e+0', + parts = exponential.split('e'); + + format = format.replace(/e[\+|\-]{1}0/, ''); + + output = numeral._.numberToFormat(Number(parts[0]), format, roundingFunction); + + return output + 'e' + parts[1]; + }, + unformat: function(string) { + var parts = numeral._.includes(string, 'e+') ? string.split('e+') : string.split('e-'), + value = Number(parts[0]), + power = Number(parts[1]); + + power = numeral._.includes(string, 'e-') ? power *= -1 : power; + + function cback(accum, curr, currI, O) { + var corrFactor = numeral._.correctionFactor(accum, curr), + num = (accum * corrFactor) * (curr * corrFactor) / (corrFactor * corrFactor); + return num; + } + + return numeral._.reduce([value, Math.pow(10, power)], cback, 1); + } + }); +})); diff --git a/src/formats/ordinal.js b/src/formats/ordinal.js new file mode 100644 index 00000000..89647859 --- /dev/null +++ b/src/formats/ordinal.js @@ -0,0 +1,33 @@ +// numeral.js format configuration +// format : ordinal +// author : Adam Draper : https://github.com/adamwdraper + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('format', 'ordinal', { + regexps: { + format: /(o)/ + }, + format: function(value, format, roundingFunction) { + var locale = numeral.locales[numeral.options.currentLocale], + output, + ordinal = numeral._.includes(format, ' o') ? ' ' : ''; + + // check for space before + format = format.replace(/\s?o/, ''); + + ordinal += locale.ordinal(value); + + output = numeral._.numberToFormat(value, format, roundingFunction); + + return output + ordinal; + } + }); +})); diff --git a/src/formats/percentage.js b/src/formats/percentage.js new file mode 100644 index 00000000..2c1c3647 --- /dev/null +++ b/src/formats/percentage.js @@ -0,0 +1,52 @@ +// numeral.js format configuration +// format : percentage +// author : Adam Draper : https://github.com/adamwdraper + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('format', 'percentage', { + regexps: { + format: /(%)/, + unformat: /(%)/ + }, + format: function(value, format, roundingFunction) { + var space = numeral._.includes(format, ' %') ? ' ' : '', + output; + + if (numeral.options.scalePercentBy100) { + value = value * 100; + } + + // check for space before % + format = format.replace(/\s?\%/, ''); + + output = numeral._.numberToFormat(value, format, roundingFunction); + + if (numeral._.includes(output, ')')) { + output = output.split(''); + + output.splice(-1, 0, space + '%'); + + output = output.join(''); + } else { + output = output + space + '%'; + } + + return output; + }, + unformat: function(string) { + var number = numeral._.stringToNumber(string); + if (numeral.options.scalePercentBy100) { + return number * 0.01; + } + return number; + } + }); +})); diff --git a/src/formats/time.js b/src/formats/time.js new file mode 100644 index 00000000..b2d6737f --- /dev/null +++ b/src/formats/time.js @@ -0,0 +1,47 @@ +// numeral.js format configuration +// format : time +// author : Adam Draper : https://github.com/adamwdraper + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('format', 'time', { + regexps: { + format: /(:)/, + unformat: /(:)/ + }, + format: function(value, format, roundingFunction) { + var hours = Math.floor(value / 60 / 60), + minutes = Math.floor((value - (hours * 60 * 60)) / 60), + seconds = Math.round(value - (hours * 60 * 60) - (minutes * 60)); + + return hours + ':' + (minutes < 10 ? '0' + minutes : minutes) + ':' + (seconds < 10 ? '0' + seconds : seconds); + }, + unformat: function(string) { + var timeArray = string.split(':'), + seconds = 0; + + // turn hours and minutes into seconds and add them all up + if (timeArray.length === 3) { + // hours + seconds = seconds + (Number(timeArray[0]) * 60 * 60); + // minutes + seconds = seconds + (Number(timeArray[1]) * 60); + // seconds + seconds = seconds + Number(timeArray[2]); + } else if (timeArray.length === 2) { + // minutes + seconds = seconds + (Number(timeArray[0]) * 60); + // seconds + seconds = seconds + Number(timeArray[1]); + } + return Number(seconds); + } + }); +})); diff --git a/src/locales/bg.js b/src/locales/bg.js new file mode 100644 index 00000000..ef71941c --- /dev/null +++ b/src/locales/bg.js @@ -0,0 +1,40 @@ +// numeral.js locale configuration +// locale : Bulgarian +// author : Don Vince : https://github.com/donvince/ + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'bg', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { // I found these here http://www.unicode.org/cldr/charts/28/verify/numbers/bg.html + thousand: 'хил', + million: 'млн', + billion: 'млрд', + trillion: 'трлн' + }, + ordinal: function (number) { + // google translate suggests: + // 1st=1-ви; 2nd=2-ри; 7th=7-ми; + // 8th=8-ми and many others end with -ти + // for example 3rd=3-ти + // However since I've seen suggestions that in + // Bulgarian the ordinal can be taken in + // different forms (masculine, feminine, neuter) + // I've opted to wimp out on commiting that to code + return ''; + }, + currency: { + symbol: 'лв' + } + }); +})); diff --git a/src/locales/chs.js b/src/locales/chs.js new file mode 100644 index 00000000..1bcc9462 --- /dev/null +++ b/src/locales/chs.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : simplified chinese (chs) +// author : badplum : https://github.com/badplum + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'chs', { + delimiters: { + thousands: ',', + decimal: '.' + }, + abbreviations: { + thousand: '千', + million: '百万', + billion: '十亿', + trillion: '兆' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: '¥' + } + }); +})); diff --git a/src/locales/cs.js b/src/locales/cs.js new file mode 100644 index 00000000..316051f2 --- /dev/null +++ b/src/locales/cs.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : czech (cs) +// author : Anatoli Papirovski : https://github.com/apapirovski + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'cs', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'tis.', + million: 'mil.', + billion: 'b', + trillion: 't' + }, + ordinal: function () { + return '.'; + }, + currency: { + symbol: 'Kč' + } + }); +})); diff --git a/src/locales/da-dk.js b/src/locales/da-dk.js new file mode 100644 index 00000000..c21e5a78 --- /dev/null +++ b/src/locales/da-dk.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : danish denmark (dk) +// author : Michael Storgaard : https://github.com/mstorgaard + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'da-dk', { + delimiters: { + thousands: '.', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'mio', + billion: 'mia', + trillion: 'b' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: 'DKK' + } + }); +})); diff --git a/src/locales/de-ch.js b/src/locales/de-ch.js new file mode 100644 index 00000000..5921e46c --- /dev/null +++ b/src/locales/de-ch.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : German in Switzerland (de-ch) +// author : Michael Piefel : https://github.com/piefel (based on work from Marco Krage : https://github.com/sinky) + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'de-ch', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: 'CHF' + } + }); +})); diff --git a/src/locales/de.js b/src/locales/de.js new file mode 100644 index 00000000..87f87880 --- /dev/null +++ b/src/locales/de.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium +// author : Marco Krage : https://github.com/sinky + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'de', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: '€' + } + }); +})); diff --git a/src/locales/en-au.js b/src/locales/en-au.js new file mode 100644 index 00000000..6202c842 --- /dev/null +++ b/src/locales/en-au.js @@ -0,0 +1,36 @@ +// numeral.js locale configuration +// locale : English Australia +// author : Don Vince : https://github.com/donvince/ + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'en-au', { + delimiters: { + thousands: ',', + decimal: '.' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + var b = number % 10; + return (~~ (number % 100 / 10) === 1) ? 'th' : + (b === 1) ? 'st' : + (b === 2) ? 'nd' : + (b === 3) ? 'rd' : 'th'; + }, + currency: { + symbol: '$' + } + }); +})); diff --git a/src/locales/en-gb.js b/src/locales/en-gb.js new file mode 100644 index 00000000..a51190eb --- /dev/null +++ b/src/locales/en-gb.js @@ -0,0 +1,36 @@ +// numeral.js locale configuration +// locale : english united kingdom (uk) +// author : Dan Ristic : https://github.com/dristic + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'en-gb', { + delimiters: { + thousands: ',', + decimal: '.' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + var b = number % 10; + return (~~ (number % 100 / 10) === 1) ? 'th' : + (b === 1) ? 'st' : + (b === 2) ? 'nd' : + (b === 3) ? 'rd' : 'th'; + }, + currency: { + symbol: '£' + } + }); +})); diff --git a/src/locales/en-za.js b/src/locales/en-za.js new file mode 100644 index 00000000..8417268d --- /dev/null +++ b/src/locales/en-za.js @@ -0,0 +1,36 @@ +// numeral.js locale configuration +// locale : english south africa (uk) +// author : Etienne Boshoff : etienne@zailab.com + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'en-za', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + var b = number % 10; + return (~~ (number % 100 / 10) === 1) ? 'th' : + (b === 1) ? 'st' : + (b === 2) ? 'nd' : + (b === 3) ? 'rd' : 'th'; + }, + currency: { + symbol: 'R' + } + }); +})); diff --git a/src/locales/es-es.js b/src/locales/es-es.js new file mode 100644 index 00000000..31e7de5b --- /dev/null +++ b/src/locales/es-es.js @@ -0,0 +1,37 @@ +// numeral.js locale configuration +// locale : spanish Spain +// author : Hernan Garcia : https://github.com/hgarcia + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'es-es', { + delimiters: { + thousands: '.', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'mm', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + var b = number % 10; + return (b === 1 || b === 3) ? 'er' : + (b === 2) ? 'do' : + (b === 7 || b === 0) ? 'mo' : + (b === 8) ? 'vo' : + (b === 9) ? 'no' : 'to'; + }, + currency: { + symbol: '€' + } + }); +})); diff --git a/src/locales/es.js b/src/locales/es.js new file mode 100644 index 00000000..7ca71950 --- /dev/null +++ b/src/locales/es.js @@ -0,0 +1,37 @@ +// numeral.js locale configuration +// locale : spanish +// author : Hernan Garcia : https://github.com/hgarcia + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'es', { + delimiters: { + thousands: '.', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'mm', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + var b = number % 10; + return (b === 1 || b === 3) ? 'er' : + (b === 2) ? 'do' : + (b === 7 || b === 0) ? 'mo' : + (b === 8) ? 'vo' : + (b === 9) ? 'no' : 'to'; + }, + currency: { + symbol: '$' + } + }); +})); diff --git a/src/locales/et.js b/src/locales/et.js new file mode 100644 index 00000000..f8269e12 --- /dev/null +++ b/src/locales/et.js @@ -0,0 +1,33 @@ +// numeral.js locale configuration +// locale : Estonian +// author : Illimar Tambek : https://github.com/ragulka +// Note: in Estonian, abbreviations are always separated from numbers with a space + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'et', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: ' tuh', + million: ' mln', + billion: ' mld', + trillion: ' trl' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: '€' + } + }); +})); diff --git a/src/locales/fi.js b/src/locales/fi.js new file mode 100644 index 00000000..25eaa7fd --- /dev/null +++ b/src/locales/fi.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : Finnish +// author : Sami Saada : https://github.com/samitheberber + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'fi', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'M', + billion: 'G', + trillion: 'T' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: '€' + } + }); +})); diff --git a/src/locales/fr-ca.js b/src/locales/fr-ca.js new file mode 100644 index 00000000..f8dd2061 --- /dev/null +++ b/src/locales/fr-ca.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : french (Canada) (fr-ca) +// author : Léo Renaud-Allaire : https://github.com/renaudleo + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'fr-ca', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'M', + billion: 'G', + trillion: 'T' + }, + ordinal : function (number) { + return number === 1 ? 'er' : 'e'; + }, + currency: { + symbol: '$' + } + }); +})); diff --git a/src/locales/fr-ch.js b/src/locales/fr-ch.js new file mode 100644 index 00000000..ea29b39c --- /dev/null +++ b/src/locales/fr-ch.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : french (fr-ch) +// author : Adam Draper : https://github.com/adamwdraper + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'fr-ch', { + delimiters: { + thousands: '\'', + decimal: '.' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal : function (number) { + return number === 1 ? 'er' : 'e'; + }, + currency: { + symbol: 'CHF' + } + }); +})); diff --git a/src/locales/fr.js b/src/locales/fr.js new file mode 100644 index 00000000..5ddc609d --- /dev/null +++ b/src/locales/fr.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : french (fr) +// author : Adam Draper : https://github.com/adamwdraper + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'fr', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal : function (number) { + return number === 1 ? 'er' : 'e'; + }, + currency: { + symbol: '€' + } + }); +})); diff --git a/src/locales/hu.js b/src/locales/hu.js new file mode 100644 index 00000000..a3d7638a --- /dev/null +++ b/src/locales/hu.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : Hungarian (hu) +// author : Peter Bakondy : https://github.com/pbakondy + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'hu', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'E', // ezer + million: 'M', // millió + billion: 'Mrd', // milliárd + trillion: 'T' // trillió + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: ' Ft' + } + }); +})); diff --git a/src/locales/it.js b/src/locales/it.js new file mode 100644 index 00000000..a5d3406e --- /dev/null +++ b/src/locales/it.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : italian Italy (it) +// author : Giacomo Trombi : http://cinquepunti.it + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'it', { + delimiters: { + thousands: '.', + decimal: ',' + }, + abbreviations: { + thousand: 'mila', + million: 'mil', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + return 'º'; + }, + currency: { + symbol: '€' + } + }); +})); diff --git a/src/locales/ja.js b/src/locales/ja.js new file mode 100644 index 00000000..bb6c8a1e --- /dev/null +++ b/src/locales/ja.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : japanese +// author : teppeis : https://github.com/teppeis + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'ja', { + delimiters: { + thousands: ',', + decimal: '.' + }, + abbreviations: { + thousand: '千', + million: '百万', + billion: '十億', + trillion: '兆' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: '¥' + } + }); +})); diff --git a/src/locales/lv.js b/src/locales/lv.js new file mode 100644 index 00000000..cc46c0e7 --- /dev/null +++ b/src/locales/lv.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : Latvian (lv) +// author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'lv', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: ' tūkst.', + million: ' milj.', + billion: ' mljrd.', + trillion: ' trilj.' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: '€' + } + }); +})); diff --git a/src/locales/nl-be.js b/src/locales/nl-be.js new file mode 100644 index 00000000..6b561904 --- /dev/null +++ b/src/locales/nl-be.js @@ -0,0 +1,35 @@ +// numeral.js locale configuration +// locale : dutch-belgium (nl-be) +// author : Dieter Luypaert : https://github.com/moeriki +// corrected : Olivier Godefroy : https://github.com/godefroyo + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'nl-be', { + delimiters: { + thousands: ' ', + decimal : ',' + }, + abbreviations: { + thousand : 'k', + million : ' mln', + billion : ' mld', + trillion : ' bln' + }, + ordinal : function (number) { + var remainder = number % 100; + + return (number !== 0 && remainder <= 1 || remainder === 8 || remainder >= 20) ? 'ste' : 'de'; + }, + currency: { + symbol: '€ ' + } + }); +})); diff --git a/src/locales/nl-nl.js b/src/locales/nl-nl.js new file mode 100644 index 00000000..00f70f7c --- /dev/null +++ b/src/locales/nl-nl.js @@ -0,0 +1,33 @@ +// numeral.js locale configuration +// locale : netherlands-dutch (nl-nl) +// author : Dave Clayton : https://github.com/davedx + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'nl-nl', { + delimiters: { + thousands: '.', + decimal : ',' + }, + abbreviations: { + thousand : 'k', + million : 'mln', + billion : 'mrd', + trillion : 'bln' + }, + ordinal : function (number) { + var remainder = number % 100; + return (number !== 0 && remainder <= 1 || remainder === 8 || remainder >= 20) ? 'ste' : 'de'; + }, + currency: { + symbol: '€ ' + } + }); +})); diff --git a/src/locales/no.js b/src/locales/no.js new file mode 100644 index 00000000..2a2b06c8 --- /dev/null +++ b/src/locales/no.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : norwegian (bokmål) +// author : Ove Andersen : https://github.com/azzlack + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'no', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: 'kr' + } + }); +})); diff --git a/src/locales/pl.js b/src/locales/pl.js new file mode 100644 index 00000000..b336c090 --- /dev/null +++ b/src/locales/pl.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : polish (pl) +// author : Dominik Bulaj : https://github.com/dominikbulaj + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'pl', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'tys.', + million: 'mln', + billion: 'mld', + trillion: 'bln' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: 'PLN' + } + }); +})); diff --git a/src/locales/pt-br.js b/src/locales/pt-br.js new file mode 100644 index 00000000..94d384b3 --- /dev/null +++ b/src/locales/pt-br.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : portuguese brazil (pt-br) +// author : Ramiro Varandas Jr : https://github.com/ramirovjr + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'pt-br', { + delimiters: { + thousands: '.', + decimal: ',' + }, + abbreviations: { + thousand: 'mil', + million: 'milhões', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + return 'º'; + }, + currency: { + symbol: 'R$' + } + }); +})); diff --git a/src/locales/pt-pt.js b/src/locales/pt-pt.js new file mode 100644 index 00000000..9bf59770 --- /dev/null +++ b/src/locales/pt-pt.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : portuguese (pt-pt) +// author : Diogo Resende : https://github.com/dresende + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'pt-pt', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal : function (number) { + return 'º'; + }, + currency: { + symbol: '€' + } + }); +})); diff --git a/src/locales/ru-ua.js b/src/locales/ru-ua.js new file mode 100644 index 00000000..798f94f4 --- /dev/null +++ b/src/locales/ru-ua.js @@ -0,0 +1,35 @@ +// numeral.js locale configuration +// locale : Russian for the Ukraine (ru-ua) +// author : Anatoli Papirovski : https://github.com/apapirovski + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'ru-ua', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'тыс.', + million: 'млн', + billion: 'b', + trillion: 't' + }, + ordinal: function () { + // not ideal, but since in Russian it can taken on + // different forms (masculine, feminine, neuter) + // this is all we can do + return '.'; + }, + currency: { + symbol: '\u20B4' + } + }); +})); diff --git a/src/locales/ru.js b/src/locales/ru.js new file mode 100644 index 00000000..34dfb7f9 --- /dev/null +++ b/src/locales/ru.js @@ -0,0 +1,35 @@ +// numeral.js locale configuration +// locale : russian (ru) +// author : Anatoli Papirovski : https://github.com/apapirovski + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'ru', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'тыс.', + million: 'млн.', + billion: 'млрд.', + trillion: 'трлн.' + }, + ordinal: function () { + // not ideal, but since in Russian it can taken on + // different forms (masculine, feminine, neuter) + // this is all we can do + return '.'; + }, + currency: { + symbol: 'руб.' + } + }); +})); diff --git a/src/locales/sk.js b/src/locales/sk.js new file mode 100644 index 00000000..cb0e898d --- /dev/null +++ b/src/locales/sk.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : slovak (sk) +// author : Ahmed Al Hafoudh : http://www.freevision.sk + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'sk', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'tis.', + million: 'mil.', + billion: 'b', + trillion: 't' + }, + ordinal: function () { + return '.'; + }, + currency: { + symbol: '€' + } + }); +})); diff --git a/src/locales/sl.js b/src/locales/sl.js new file mode 100644 index 00000000..2f1117eb --- /dev/null +++ b/src/locales/sl.js @@ -0,0 +1,32 @@ +// numeral.js locale configuration +// locale : slovenian (sl) +// author : Boštjan Pišler : https://github.com/BostjanPisler + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'sl', { + delimiters: { + thousands: '.', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'mio', + billion: 'mrd', + trillion: 'trilijon' + }, + ordinal: function () { + return '.'; + }, + currency: { + symbol: '€' + } + }); +})); diff --git a/src/locales/th.js b/src/locales/th.js new file mode 100644 index 00000000..d3e08d00 --- /dev/null +++ b/src/locales/th.js @@ -0,0 +1,34 @@ +// numeral.js locale configuration +// locale : thai (th) +// author : Sathit Jittanupat : https://github.com/jojosati + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + + + numeral.register('locale', 'th', { + delimiters: { + thousands: ',', + decimal: '.' + }, + abbreviations: { + thousand: 'พัน', + million: 'ล้าน', + billion: 'พันล้าน', + trillion: 'ล้านล้าน' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: '฿' + } + }); +})); diff --git a/src/locales/tr.js b/src/locales/tr.js new file mode 100644 index 00000000..07f7ffdd --- /dev/null +++ b/src/locales/tr.js @@ -0,0 +1,66 @@ +// numeral.js locale configuration +// locale : turkish (tr) +// author : Ecmel Ercan : https://github.com/ecmel, Erhan Gundogan : https://github.com/erhangundogan, Burak Yiğit Kaya: https://github.com/BYK + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + var suffixes = { + 1: '\'inci', + 5: '\'inci', + 8: '\'inci', + 70: '\'inci', + 80: '\'inci', + + 2: '\'nci', + 7: '\'nci', + 20: '\'nci', + 50: '\'nci', + + 3: '\'üncü', + 4: '\'üncü', + 100: '\'üncü', + + 6: '\'ncı', + + 9: '\'uncu', + 10: '\'uncu', + 30: '\'uncu', + + 60: '\'ıncı', + 90: '\'ıncı' + }; + + numeral.register('locale', 'tr', { + delimiters: { + thousands: '.', + decimal: ',' + }, + abbreviations: { + thousand: 'bin', + million: 'milyon', + billion: 'milyar', + trillion: 'trilyon' + }, + ordinal: function (number) { + if (number === 0) { // special case for zero + return '\'ıncı'; + } + + var a = number % 10, + b = number % 100 - a, + c = number >= 100 ? 100 : null; + + return suffixes[a] || suffixes[b] || suffixes[c]; + }, + currency: { + symbol: '\u20BA' + } + }); +})); diff --git a/src/locales/uk-ua.js b/src/locales/uk-ua.js new file mode 100644 index 00000000..34b31037 --- /dev/null +++ b/src/locales/uk-ua.js @@ -0,0 +1,35 @@ +// numeral.js locale configuration +// locale : Ukrainian for the Ukraine (uk-ua) +// author : Michael Piefel : https://github.com/piefel (with help from Tetyana Kuzmenko) + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + numeral.register('locale', 'uk-ua', { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'тис.', + million: 'млн', + billion: 'млрд', + trillion: 'блн' + }, + ordinal: function () { + // not ideal, but since in Ukrainian it can taken on + // different forms (masculine, feminine, neuter) + // this is all we can do + return ''; + }, + currency: { + symbol: '\u20B4' + } + }); +})); diff --git a/src/locales/vi.js b/src/locales/vi.js new file mode 100644 index 00000000..a71a1bb8 --- /dev/null +++ b/src/locales/vi.js @@ -0,0 +1,33 @@ +// numeral.js locale configuration +// locale : vietnam (vi) +// author : Harry Nguyen : https://github.com/thaihoa311 + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + + numeral.register('locale', 'vi', { + delimiters: { + thousands: '.', + decimal: ',' + }, + abbreviations: { + thousand: ' nghìn', + million: ' triệu', + billion: ' tỷ', + trillion: ' nghìn tỷ' + }, + ordinal: function () { + return '.'; + }, + currency: { + symbol: '₫' + } + }); +})); diff --git a/src/numeral.js b/src/numeral.js new file mode 100644 index 00000000..3a9d2521 --- /dev/null +++ b/src/numeral.js @@ -0,0 +1,693 @@ +/*! @preserve + * numeral.js + * version : 2.0.6 + * author : Adam Draper + * license : MIT + * http://adamwdraper.github.com/Numeral-js/ + */ + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(factory); + } else if (typeof module === 'object' && module.exports) { + module.exports = factory(); + } else { + global.numeral = factory(); + } +}(this, function () { + /************************************ + Variables + ************************************/ + + var numeral, + _, + VERSION = '2.0.6', + formats = {}, + locales = {}, + defaults = { + currentLocale: 'en', + zeroFormat: null, + nullFormat: null, + defaultFormat: '0,0', + scalePercentBy100: true + }, + options = { + currentLocale: defaults.currentLocale, + zeroFormat: defaults.zeroFormat, + nullFormat: defaults.nullFormat, + defaultFormat: defaults.defaultFormat, + scalePercentBy100: defaults.scalePercentBy100 + }; + + + /************************************ + Constructors + ************************************/ + + // Numeral prototype object + function Numeral(input, number) { + this._input = input; + + this._value = number; + } + + numeral = function(input) { + var value, + kind, + unformatFunction, + regexp; + + if (numeral.isNumeral(input)) { + value = input.value(); + } else if (input === 0 || typeof input === 'undefined') { + value = 0; + } else if (input === null || _.isNaN(input)) { + value = null; + } else if (typeof input === 'string') { + if (options.zeroFormat && input === options.zeroFormat) { + value = 0; + } else if (options.nullFormat && input === options.nullFormat || !input.replace(/[^0-9]+/g, '').length) { + value = null; + } else { + for (kind in formats) { + regexp = typeof formats[kind].regexps.unformat === 'function' ? formats[kind].regexps.unformat() : formats[kind].regexps.unformat; + + if (regexp && input.match(regexp)) { + unformatFunction = formats[kind].unformat; + + break; + } + } + + unformatFunction = unformatFunction || numeral._.stringToNumber; + + value = unformatFunction(input); + } + } else { + value = Number(input)|| null; + } + + return new Numeral(input, value); + }; + + // version number + numeral.version = VERSION; + + // compare numeral object + numeral.isNumeral = function(obj) { + return obj instanceof Numeral; + }; + + // helper functions + numeral._ = _ = { + // formats numbers separators, decimals places, signs, abbreviations + numberToFormat: function(value, format, roundingFunction) { + var locale = locales[numeral.options.currentLocale], + negP = false, + optDec = false, + leadingCount = 0, + abbr = '', + trillion = 1000000000000, + billion = 1000000000, + million = 1000000, + thousand = 1000, + decimal = '', + neg = false, + abbrForce, // force abbreviation + abs, + min, + max, + power, + int, + precision, + signed, + thousands, + output; + + // make sure we never format a null value + value = value || 0; + + abs = Math.abs(value); + + // see if we should use parentheses for negative number or if we should prefix with a sign + // if both are present we default to parentheses + if (numeral._.includes(format, '(')) { + negP = true; + format = format.replace(/[\(|\)]/g, ''); + } else if (numeral._.includes(format, '+') || numeral._.includes(format, '-')) { + signed = numeral._.includes(format, '+') ? format.indexOf('+') : value < 0 ? format.indexOf('-') : -1; + format = format.replace(/[\+|\-]/g, ''); + } + + // see if abbreviation is wanted + if (numeral._.includes(format, 'a')) { + abbrForce = format.match(/a(k|m|b|t)?/); + + abbrForce = abbrForce ? abbrForce[1] : false; + + // check for space before abbreviation + if (numeral._.includes(format, ' a')) { + abbr = ' '; + } + + format = format.replace(new RegExp(abbr + 'a[kmbt]?'), ''); + + if (abs >= trillion && !abbrForce || abbrForce === 't') { + // trillion + abbr += locale.abbreviations.trillion; + value = value / trillion; + } else if (abs < trillion && abs >= billion && !abbrForce || abbrForce === 'b') { + // billion + abbr += locale.abbreviations.billion; + value = value / billion; + } else if (abs < billion && abs >= million && !abbrForce || abbrForce === 'm') { + // million + abbr += locale.abbreviations.million; + value = value / million; + } else if (abs < million && abs >= thousand && !abbrForce || abbrForce === 'k') { + // thousand + abbr += locale.abbreviations.thousand; + value = value / thousand; + } + } + + // check for optional decimals + if (numeral._.includes(format, '[.]')) { + optDec = true; + format = format.replace('[.]', '.'); + } + + // break number and format + int = value.toString().split('.')[0]; + precision = format.split('.')[1]; + thousands = format.indexOf(','); + leadingCount = (format.split('.')[0].split(',')[0].match(/0/g) || []).length; + + if (precision) { + if (numeral._.includes(precision, '[')) { + precision = precision.replace(']', ''); + precision = precision.split('['); + decimal = numeral._.toFixed(value, (precision[0].length + precision[1].length), roundingFunction, precision[1].length); + } else { + decimal = numeral._.toFixed(value, precision.length, roundingFunction); + } + + int = decimal.split('.')[0]; + + if (numeral._.includes(decimal, '.')) { + decimal = locale.delimiters.decimal + decimal.split('.')[1]; + } else { + decimal = ''; + } + + if (optDec && Number(decimal.slice(1)) === 0) { + decimal = ''; + } + } else { + int = numeral._.toFixed(value, 0, roundingFunction); + } + + // check abbreviation again after rounding + if (abbr && !abbrForce && Number(int) >= 1000 && abbr !== locale.abbreviations.trillion) { + int = String(Number(int) / 1000); + + switch (abbr) { + case locale.abbreviations.thousand: + abbr = locale.abbreviations.million; + break; + case locale.abbreviations.million: + abbr = locale.abbreviations.billion; + break; + case locale.abbreviations.billion: + abbr = locale.abbreviations.trillion; + break; + } + } + + + // format number + if (numeral._.includes(int, '-')) { + int = int.slice(1); + neg = true; + } + + if (int.length < leadingCount) { + for (var i = leadingCount - int.length; i > 0; i--) { + int = '0' + int; + } + } + + if (thousands > -1) { + int = int.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + locale.delimiters.thousands); + } + + if (format.indexOf('.') === 0) { + int = ''; + } + + output = int + decimal + (abbr ? abbr : ''); + + if (negP) { + output = (negP && neg ? '(' : '') + output + (negP && neg ? ')' : ''); + } else { + if (signed >= 0) { + output = signed === 0 ? (neg ? '-' : '+') + output : output + (neg ? '-' : '+'); + } else if (neg) { + output = '-' + output; + } + } + + return output; + }, + // unformats numbers separators, decimals places, signs, abbreviations + stringToNumber: function(string) { + var locale = locales[options.currentLocale], + stringOriginal = string, + abbreviations = { + thousand: 3, + million: 6, + billion: 9, + trillion: 12 + }, + abbreviation, + value, + i, + regexp; + + if (options.zeroFormat && string === options.zeroFormat) { + value = 0; + } else if (options.nullFormat && string === options.nullFormat || !string.replace(/[^0-9]+/g, '').length) { + value = null; + } else { + value = 1; + + if (locale.delimiters.decimal !== '.') { + string = string.replace(/\./g, '').replace(locale.delimiters.decimal, '.'); + } + + for (abbreviation in abbreviations) { + regexp = new RegExp('[^a-zA-Z]' + locale.abbreviations[abbreviation] + '(?:\\)|(\\' + locale.currency.symbol + ')?(?:\\))?)?$'); + + if (stringOriginal.match(regexp)) { + value *= Math.pow(10, abbreviations[abbreviation]); + break; + } + } + + // check for negative number + value *= (string.split('-').length + Math.min(string.split('(').length - 1, string.split(')').length - 1)) % 2 ? 1 : -1; + + // remove non numbers + string = string.replace(/[^0-9\.]+/g, ''); + + value *= Number(string); + } + + return value; + }, + isNaN: function(value) { + return typeof value === 'number' && isNaN(value); + }, + includes: function(string, search) { + return string.indexOf(search) !== -1; + }, + insert: function(string, subString, start) { + return string.slice(0, start) + subString + string.slice(start); + }, + reduce: function(array, callback /*, initialValue*/) { + if (this === null) { + throw new TypeError('Array.prototype.reduce called on null or undefined'); + } + + if (typeof callback !== 'function') { + throw new TypeError(callback + ' is not a function'); + } + + var t = Object(array), + len = t.length >>> 0, + k = 0, + value; + + if (arguments.length === 3) { + value = arguments[2]; + } else { + while (k < len && !(k in t)) { + k++; + } + + if (k >= len) { + throw new TypeError('Reduce of empty array with no initial value'); + } + + value = t[k++]; + } + for (; k < len; k++) { + if (k in t) { + value = callback(value, t[k], k, t); + } + } + return value; + }, + /** + * Computes the multiplier necessary to make x >= 1, + * effectively eliminating miscalculations caused by + * finite precision. + */ + multiplier: function (x) { + var parts = x.toString().split('.'); + + return parts.length < 2 ? 1 : Math.pow(10, parts[1].length); + }, + /** + * Given a variable number of arguments, returns the maximum + * multiplier that must be used to normalize an operation involving + * all of them. + */ + correctionFactor: function () { + var args = Array.prototype.slice.call(arguments); + + return args.reduce(function(accum, next) { + var mn = _.multiplier(next); + return accum > mn ? accum : mn; + }, 1); + }, + /** + * Implementation of toFixed() that treats floats more like decimals + * + * Fixes binary rounding issues (eg. (0.615).toFixed(2) === '0.61') that present + * problems for accounting- and finance-related software. + */ + toFixed: function(value, maxDecimals, roundingFunction, optionals) { + var splitValue = value.toString().split('.'), + minDecimals = maxDecimals - (optionals || 0), + boundedPrecision, + optionalsRegExp, + power, + output; + + // Use the smallest precision value possible to avoid errors from floating point representation + if (splitValue.length === 2) { + boundedPrecision = Math.min(Math.max(splitValue[1].length, minDecimals), maxDecimals); + } else { + boundedPrecision = minDecimals; + } + + power = Math.pow(10, boundedPrecision); + + // Multiply up by precision, round accurately, then divide and use native toFixed(): + output = (roundingFunction(value + 'e+' + boundedPrecision) / power).toFixed(boundedPrecision); + + if (optionals > maxDecimals - boundedPrecision) { + optionalsRegExp = new RegExp('\\.?0{1,' + (optionals - (maxDecimals - boundedPrecision)) + '}$'); + output = output.replace(optionalsRegExp, ''); + } + + return output; + } + }; + + // avaliable options + numeral.options = options; + + // avaliable formats + numeral.formats = formats; + + // avaliable formats + numeral.locales = locales; + + // This function sets the current locale. If + // no arguments are passed in, it will simply return the current global + // locale key. + numeral.locale = function(key) { + if (key) { + options.currentLocale = key.toLowerCase(); + } + + return options.currentLocale; + }; + + // This function provides access to the loaded locale data. If + // no arguments are passed in, it will simply return the current + // global locale object. + numeral.localeData = function(key) { + if (!key) { + return locales[options.currentLocale]; + } + + key = key.toLowerCase(); + + if (!locales[key]) { + throw new Error('Unknown locale : ' + key); + } + + return locales[key]; + }; + + numeral.reset = function() { + for (var property in defaults) { + options[property] = defaults[property]; + } + }; + + numeral.zeroFormat = function(format) { + options.zeroFormat = typeof(format) === 'string' ? format : null; + }; + + numeral.nullFormat = function (format) { + options.nullFormat = typeof(format) === 'string' ? format : null; + }; + + numeral.defaultFormat = function(format) { + options.defaultFormat = typeof(format) === 'string' ? format : '0.0'; + }; + + numeral.register = function(type, name, format) { + name = name.toLowerCase(); + + if (this[type + 's'][name]) { + throw new TypeError(name + ' ' + type + ' already registered.'); + } + + this[type + 's'][name] = format; + + return format; + }; + + + numeral.validate = function(val, culture) { + var _decimalSep, + _thousandSep, + _currSymbol, + _valArray, + _abbrObj, + _thousandRegEx, + localeData, + temp; + + //coerce val to string + if (typeof val !== 'string') { + val += ''; + + if (console.warn) { + console.warn('Numeral.js: Value is not string. It has been co-erced to: ', val); + } + } + + //trim whitespaces from either sides + val = val.trim(); + + //if val is just digits return true + if (!!val.match(/^\d+$/)) { + return true; + } + + //if val is empty return false + if (val === '') { + return false; + } + + //get the decimal and thousands separator from numeral.localeData + try { + //check if the culture is understood by numeral. if not, default it to current locale + localeData = numeral.localeData(culture); + } catch (e) { + localeData = numeral.localeData(numeral.locale()); + } + + //setup the delimiters and currency symbol based on culture/locale + _currSymbol = localeData.currency.symbol; + _abbrObj = localeData.abbreviations; + _decimalSep = localeData.delimiters.decimal; + if (localeData.delimiters.thousands === '.') { + _thousandSep = '\\.'; + } else { + _thousandSep = localeData.delimiters.thousands; + } + + // validating currency symbol + temp = val.match(/^[^\d]+/); + if (temp !== null) { + val = val.substr(1); + if (temp[0] !== _currSymbol) { + return false; + } + } + + //validating abbreviation symbol + temp = val.match(/[^\d]+$/); + if (temp !== null) { + val = val.slice(0, -1); + if (temp[0] !== _abbrObj.thousand && temp[0] !== _abbrObj.million && temp[0] !== _abbrObj.billion && temp[0] !== _abbrObj.trillion) { + return false; + } + } + + _thousandRegEx = new RegExp(_thousandSep + '{2}'); + + if (!val.match(/[^\d.,]/g)) { + _valArray = val.split(_decimalSep); + if (_valArray.length > 2) { + return false; + } else { + if (_valArray.length < 2) { + return ( !! _valArray[0].match(/^\d+.*\d$/) && !_valArray[0].match(_thousandRegEx)); + } else { + if (_valArray[0].length === 1) { + return ( !! _valArray[0].match(/^\d+$/) && !_valArray[0].match(_thousandRegEx) && !! _valArray[1].match(/^\d+$/)); + } else { + return ( !! _valArray[0].match(/^\d+.*\d$/) && !_valArray[0].match(_thousandRegEx) && !! _valArray[1].match(/^\d+$/)); + } + } + } + } + + return false; + }; + + + /************************************ + Numeral Prototype + ************************************/ + + numeral.fn = Numeral.prototype = { + clone: function() { + return numeral(this); + }, + format: function(inputString, roundingFunction) { + var value = this._value, + format = inputString || options.defaultFormat, + kind, + output, + formatFunction; + + // make sure we have a roundingFunction + roundingFunction = roundingFunction || Math.round; + + // format based on value + if (value === 0 && options.zeroFormat !== null) { + output = options.zeroFormat; + } else if (value === null && options.nullFormat !== null) { + output = options.nullFormat; + } else { + for (kind in formats) { + if (format.match(formats[kind].regexps.format)) { + formatFunction = formats[kind].format; + + break; + } + } + + formatFunction = formatFunction || numeral._.numberToFormat; + + output = formatFunction(value, format, roundingFunction); + } + + return output; + }, + value: function() { + return this._value; + }, + input: function() { + return this._input; + }, + set: function(value) { + this._value = Number(value); + + return this; + }, + add: function(value) { + var corrFactor = _.correctionFactor.call(null, this._value, value); + + function cback(accum, curr, currI, O) { + return accum + Math.round(corrFactor * curr); + } + + this._value = _.reduce([this._value, value], cback, 0) / corrFactor; + + return this; + }, + subtract: function(value) { + var corrFactor = _.correctionFactor.call(null, this._value, value); + + function cback(accum, curr, currI, O) { + return accum - Math.round(corrFactor * curr); + } + + this._value = _.reduce([value], cback, Math.round(this._value * corrFactor)) / corrFactor; + + return this; + }, + multiply: function(value) { + function cback(accum, curr, currI, O) { + var corrFactor = _.correctionFactor(accum, curr); + return Math.round(accum * corrFactor) * Math.round(curr * corrFactor) / Math.round(corrFactor * corrFactor); + } + + this._value = _.reduce([this._value, value], cback, 1); + + return this; + }, + divide: function(value) { + function cback(accum, curr, currI, O) { + var corrFactor = _.correctionFactor(accum, curr); + return Math.round(accum * corrFactor) / Math.round(curr * corrFactor); + } + + this._value = _.reduce([this._value, value], cback); + + return this; + }, + difference: function(value) { + return Math.abs(numeral(this._value).subtract(value).value()); + } + }; + + /************************************ + Default Locale && Format + ************************************/ + + numeral.register('locale', 'en', { + delimiters: { + thousands: ',', + decimal: '.' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal: function(number) { + var b = number % 10; + return (~~(number % 100 / 10) === 1) ? 'th' : + (b === 1) ? 'st' : + (b === 2) ? 'nd' : + (b === 3) ? 'rd' : 'th'; + }, + currency: { + symbol: '$' + } + }); + + return numeral; +})); diff --git a/templates/anon.js b/templates/anon.js new file mode 100644 index 00000000..50b69540 --- /dev/null +++ b/templates/anon.js @@ -0,0 +1,3 @@ +(function() { + <%= content %> +})(); diff --git a/templates/types.js b/templates/types.js new file mode 100644 index 00000000..c6256a5c --- /dev/null +++ b/templates/types.js @@ -0,0 +1,18 @@ +/*! @preserve + * numeral.js + * <%= type %> : 2.0.6 + * license : MIT + * http://adamwdraper.github.com/Numeral-js/ + */ + +(function (global, factory) { + if (typeof define === 'function' && define.amd) { + define(['numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('./numeral')); + } else { + factory(global.numeral); + } +}(this, function (numeral) { + <%= content %> +})); diff --git a/tests/formats/bps.js b/tests/formats/bps.js new file mode 100644 index 00000000..f844a584 --- /dev/null +++ b/tests/formats/bps.js @@ -0,0 +1,42 @@ + +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; +} + +describe('BPS', function() { + after(function() { + numeral.reset(); + }); + + it('should format to bps', function() { + var tests = [ + [0,'0 BPS','0 BPS'], + [0.0001, '0 BPS', '1 BPS'], + [.0056, '0 BPS', '56 BPS'], + [.25, '0BPS', '2500BPS'], + [.000001, '0.00 BPS', '0.01 BPS'] + ], + i; + + for (i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + + it('should unformat to number', function() { + var tests = [ + ['0 BPS', 0], + ['1 BPS', 0.0001], + ['56 BPS', .0056], + ['2500BPS', .25], + ['0.01 BPS', .000001] + ], + i; + + for (i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); +}); diff --git a/tests/formats/bytes.js b/tests/formats/bytes.js new file mode 100644 index 00000000..8f7e76d9 --- /dev/null +++ b/tests/formats/bytes.js @@ -0,0 +1,62 @@ + +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; +} + +describe('Bytes', function() { + after(function() { + numeral.reset(); + }); + + it('should format to bytes', function() { + var decimal = 1000; + var binary = 1024; + var tests = [ + [0,'0b','0B'], + [null,'0 b','0 B'], + [100,'0b','100B'], + [binary * 2,'0 ib','2 KiB'], + [Math.pow(binary, 2) * 5,'0ib','5MiB'], + [Math.pow(binary, 3) * 7.343,'0.[0] ib','7.3 GiB'], + [Math.pow(binary, 4) * 3.1536544,'0.000ib','3.154TiB'], + [Math.pow(binary, 5) * 2.953454534534,'0ib','3PiB'], + [decimal * 2,'0 b','2 KB'], + [Math.pow(decimal, 2) * 5,'0b','5MB'], + [Math.pow(decimal, 3) * 7.343,'0.[0] b','7.3 GB'], + [Math.pow(decimal, 4) * 3.1536544,'0.000b','3.154TB'], + [Math.pow(decimal, 5) * 2.953454534534,'0b','3PB'] + ], + i; + + for (i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + + it('should unformat to number', function() { + var decimal = 1000; + var binary = 1024; + var tests = [ + ['0B', 0], + ['0 B', 0], + ['100B', 100], + ['2 KiB', binary * 2], + ['5MiB', Math.pow(binary, 2) * 5], + ['7.3 GiB', Math.pow(binary, 3) * 7.3], + ['3.154TiB', Math.pow(binary, 4) * 3.154], + ['3PiB', Math.pow(binary, 5) * 3], + ['2 KB', decimal * 2], + ['5MB', Math.pow(decimal, 2) * 5], + ['7.3 GB', Math.pow(decimal, 3) * 7.3], + ['3.154TB', Math.pow(decimal, 4) * 3.154], + ['3PB', Math.pow(decimal, 5) * 3] + ], + i; + + for (i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); +}); diff --git a/tests/formats/currency.js b/tests/formats/currency.js new file mode 100644 index 00000000..24bbef87 --- /dev/null +++ b/tests/formats/currency.js @@ -0,0 +1,66 @@ + +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; +} + +describe('Currency', function() { + after(function() { + numeral.reset(); + }); + + it('should format to currency', function() { + var tests = [ + [0,'$0.00','$0.00'], + [null,'$0.00','$0.00'], + [0.99,'$0,0.00','$0.99'], + [1000.234,'$0,0.00','$1,000.23'], + [1001,'$ 0,0.[00]','$ 1,001'], + [1000.234,'0,0.00 $','1,000.23 $'], + [-1000.234,'0,0.00 $','-1,000.23 $'], + [-1000.234,'($0,0)','($1,000)'], + [-1000.234,'(0,0$)','(1,000$)'], + [-1000.234,'(0,0 $)','(1,000 $)'], + [-1000.234,'$0.00','-$1000.23'], + [-1000.234,'$ 0.00','-$ 1000.23'], + [1230974,'($0.00 a)','$1.23 m'], + [-1000.234,'$ (0,0)','$ (1,000)'], + [-1000.234,'$(0,0)','$(1,000)'], + [-1000.234,'$ (0,0.00)','$ (1,000.23)'], + [-1000.234,'$(0,0.00)','$(1,000.23)'], + [-1000.238,'$(0,0.00)','$(1,000.24)'], + [-1000.234,'$-0,0','$-1,000'], + [-1000.234,'$ -0,0','$ -1,000'], + [1000.234,'$ (0,0)','$ 1,000'], + [1000.234,'$(0,0)','$1,000'], + [1000.234,'$ (0,0.00)','$ 1,000.23'], + [1000.234,'$(0,0.00)','$1,000.23'], + [1000.238,'$(0,0.00)','$1,000.24'], + [1000.234,'$-0,0','$1,000'], + [1000.234,'$ -0,0','$ 1,000'] + ], + i; + + for (i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + + it('should unformat to currency', function() { + var tests = [ + ['$0.00', 0], + ['$0.99', 0.99], + ['$1,000.23', 1000.23], + ['1,000.23 $', 1000.23], + ['($1,000)', -1000], + ['-1,000$', -1000], + ['$1.23 m', 1230000], + ], + i; + + for (i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); +}); diff --git a/tests/formats/exponential.js b/tests/formats/exponential.js new file mode 100644 index 00000000..4ab26fe7 --- /dev/null +++ b/tests/formats/exponential.js @@ -0,0 +1,46 @@ + +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; +} + +describe('Exponential', function() { + after(function() { + numeral.reset(); + }); + + it('should format to exponential notation', function() { + var tests = [ + [0,'0e+0','0e+0'], + [null,'0e+0','0e+0'], + [1,'0e+0','1e+0'], + [77.1234,'0.0e+0','7.7e+1'], + [0.000000771234,'0.0e-0','7.7e-7'], + [-0.000000771234,'0.00e-0','-7.71e-7'], + [77.1234,'0.000e+0','7.712e+1'], + [-1000830298,'0.0[000]e+0','-1.0008e+9'] + ], + i; + + for (i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + + it('should unformat to exponential notation', function() { + var tests = [ + ['0e+0', 0], + ['1e+0', 1], + ['7.712e+1', 77.12], + ['7.7e-7', 0.00000077], + ['-7.71e-6', -0.00000771], + ['-1.0008e+9', -1000800000] + ], + i; + + for (i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); +}); diff --git a/tests/formats/ordinal.js b/tests/formats/ordinal.js new file mode 100644 index 00000000..dc73f139 --- /dev/null +++ b/tests/formats/ordinal.js @@ -0,0 +1,49 @@ + +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; +} + +describe('Ordinal', function() { + after(function() { + numeral.reset(); + }); + + it('should format to an ordinal', function() { + var tests = [ + [1,'0o','1st'], + [52,'0 o','52 nd'], + [23,'0o','23rd'], + [100,'0o','100th'], + [1234,'0,0o','1,234th'] + ], + i, + n, + output; + + for (i = 0; i < tests.length; i++) { + n = numeral(tests[i][0]); + output = n.format(tests[i][1]); + + expect(output).to.equal(tests[i][2]); + + expect(typeof output).to.equal('string'); + } + }); + + it('should unformat to an ordinal', function() { + var tests = [ + ['1st', 1], + ['52 nd', 52], + ['23rd', 23], + ['100th', 100], + ['1,234th', 1234] + ], + i; + + for (i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); +}); diff --git a/tests/formats/percentage.js b/tests/formats/percentage.js new file mode 100644 index 00000000..1eb61ee9 --- /dev/null +++ b/tests/formats/percentage.js @@ -0,0 +1,109 @@ + +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; +} + +describe('Percentage', function() { + after(function() { + numeral.reset(); + }); + + it('should format to percentages with 100 upscale default', function() { + var tests = [ + [0,'0%','0%'], + [null,'0 %','0 %'], + [1,'0%','100%'], + [0.974878234,'0.000%','97.488%'], + [-0.43,'0 %','-43 %'], + [0.43,'(0.00[0]%)','43.00%'] + ], + i; + + for (i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + + it('should unformat to percentages with 100 downscale default', function() { + var tests = [ + ['0%', 0], + ['100%', 1], + ['97.488%', 0.97488], + ['-43 %', -0.43], + ['43.00%', 0.43] + ], + i; + + for (i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + + it('should format to percentages with 100 upscale enforced', function() { + var tests = [ + [0,'0%','0%'], + [null,'0 %','0 %'], + [1,'0%','100%'], + [0.974878234,'0.000%','97.488%'], + [-0.43,'0 %','-43 %'], + [0.43,'(0.00[0]%)','43.00%'] + ], + i; + + for (i = 0; i < tests.length; i++) { + numeral.options.scalePercentBy100 = true; + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + + it('should unformat to percentages with 100 downscale enforced', function() { + var tests = [ + ['0%', 0], + ['100%', 1], + ['97.488%', 0.97488], + ['-43 %', -0.43], + ['43.00%', 0.43] + ], + i; + + for (i = 0; i < tests.length; i++) { + numeral.options.scalePercentBy100 = true; + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + + it('should format to percentages without 100 upscale', function() { + var tests = [ + [0,'0%','0%'], + [null,'0 %','0 %'], + [1,'0%','1%'], + [97.4878234,'0.000%','97.488%'], + [-43.0,'0 %','-43 %'], + [43.0,'(0.00[0]%)','43.00%'] + ], + i; + + for (i = 0; i < tests.length; i++) { + numeral.options.scalePercentBy100 = false; + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + + it('should unformat to percentages without 100 downscale', function() { + var tests = [ + ['0%', 0], + ['100%', 100.0], + ['97.488%', 97.488], + ['-43 %', -43.0], + ['43.00%', 43.0] + ], + i; + + for (i = 0; i < tests.length; i++) { + numeral.options.scalePercentBy100 = false; + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); +}); diff --git a/tests/formats/time.js b/tests/formats/time.js new file mode 100644 index 00000000..15ecbe3a --- /dev/null +++ b/tests/formats/time.js @@ -0,0 +1,41 @@ + +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; +} + +describe('Time', function() { + after(function() { + numeral.reset(); + }); + + it('should format to time', function() { + var tests = [ + [0,'00:00:00','0:00:00'], + [null,'00:00:00','0:00:00'], + [25,'00:00:00','0:00:25'], + [238,'00:00:00','0:03:58'], + [63846,'00:00:00','17:44:06'] + ], + i; + + for (i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + + it('should unformat to time', function() { + var tests = [ + ['0:00:00', 0], + ['0:00:25', 25], + ['0:03:58', 238], + ['17:44:06', 63846] + ], + i; + + for (i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); +}); diff --git a/tests/languages/be-nl.js b/tests/languages/be-nl.js deleted file mode 100644 index 1ac29771..00000000 --- a/tests/languages/be-nl.js +++ /dev/null @@ -1,107 +0,0 @@ -var numeral = require('../../numeral'), - language = require('../../languages/be-nl'); - -numeral.language('be-nl', language); - -exports['language:be-nl'] = { - setUp: function (callback) { - numeral.language('be-nl'); - callback(); - }, - - tearDown: function (callback) { - numeral.language('en'); - callback(); - }, - - format: function (test) { - test.expect(22); - - var tests = [ - [10000,'0,0.0000','10 000,0000'], - [10000.23,'0,0','10 000'], - [-10000,'0,0.0','-10 000,0'], - [10000.1234,'0.000','10000,123'], - [-10000,'(0,0.0000)','(10 000,0000)'], - [-0.23,'.00','-,23'], - [-0.23,'(.00)','(,23)'], - [0.23,'0.00000','0,23000'], - [1230974,'0.0a','1,2 mln'], - [1460,'0a','1k'], - [-104000,'0a','-104k'], - [0,'0o','0de'], - [1,'0o','1ste'], - [2,'0o','2de'], - [8,'0o','8ste'], - [19,'0o','19de'], - [20,'0o','20ste'], - [100,'0o','100ste'], - [102,'0o','102de'], - [108,'0o','108ste'], - [109,'0o','109de'], - [1,'0[.]0','1'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(4); - - var tests = [ - [1000.234,'$0,0.00','€ 1 000,23'], - [-1000.234,'($0,0)','(€ 1 000)'], - [-1000.234,'$0.00','-€ 1000,23'], - [1230974,'($0.00a)','€ 1,23 mln'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(4); - - var tests = [ - [1,'0%','100%'], - [0.974878234,'0.000%','97,488%'], - [-0.43,'0%','-43%'], - [0.43,'(0.000%)','43,000%'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - unformat: function (test) { - test.expect(9); - - var tests = [ - ['10 000,123',10000.123], - ['(0,12345)',-0.12345], - ['(€ 1,23 mln)',-1230000], - ['10k',10000], - ['-10k',-10000], - ['23e',23], - ['€ 10 000,00',10000], - ['-76%',-0.76], - ['2:23:57',8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file diff --git a/tests/languages/chs.js b/tests/languages/chs.js deleted file mode 100644 index c9afe9f2..00000000 --- a/tests/languages/chs.js +++ /dev/null @@ -1,101 +0,0 @@ -var numeral = require('../../numeral'); -var language = require('../../languages/chs'); - -numeral.language('chs', language); - -exports['language:chs'] = { - setUp: function (callback) { - numeral.language('chs'); - callback(); - }, - - tearDown: function (callback) { - numeral.language('en'); - callback(); - }, - - format: function (test) { - test.expect(16); - - var tests = [ - [10000,'0,0.0000','10,000.0000'], - [10000.23,'0,0','10,000'], - [-10000,'0,0.0','-10,000.0'], - [10000.1234,'0.000','10000.123'], - [-10000,'(0,0.0000)','(10,000.0000)'], - [-0.23,'.00','-.23'], - [-0.23,'(.00)','(.23)'], - [0.23,'0.00000','0.23000'], - [1230974,'0.0a','1.2百万'], - [1460,'0a','1千'], - [-104000,'0a','-104千'], - [1,'0o','1.'], - [52,'0o','52.'], - [23,'0o','23.'], - [100,'0o','100.'], - [1,'0[.]0','1'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(4); - - var tests = [ - [1000.234,'$0,0.00','¥1,000.23'], - [-1000.234,'($0,0)','(¥1,000)'], - [-1000.234,'$0.00','-¥1000.23'], - [1230974,'($0.00a)','¥1.23百万'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(4); - - var tests = [ - [1,'0%','100%'], - [0.974878234,'0.000%','97.488%'], - [-0.43,'0%','-43%'], - [0.43,'(0.000%)','43.000%'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - unformat: function (test) { - test.expect(9); - - var tests = [ - ['10,000.123',10000.123], - ['(0.12345)',-0.12345], - ['(¥1.23百万)',-1230000], - ['10千',10000], - ['-10千',-10000], - ['23.',23], - ['¥10,000.00',10000], - ['-76%',-0.76], - ['2:23:57',8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file diff --git a/tests/languages/cs.js b/tests/languages/cs.js deleted file mode 100644 index 7be84aa1..00000000 --- a/tests/languages/cs.js +++ /dev/null @@ -1,102 +0,0 @@ -var numeral = require('../../numeral'), - language = require('../../languages/cs'); - -numeral.language('cs', language); - -exports['language:cs'] = { - setUp: function (callback) { - numeral.language('cs'); - callback(); - }, - - tearDown: function (callback) { - numeral.language('en'); - callback(); - }, - - format: function (test) { - test.expect(16); - - var tests = [ - [10000,'0,0.0000','10 000,0000'], - [10000.23,'0,0','10 000'], - [-10000,'0,0.0','-10 000,0'], - [10000.1234,'0.000','10000,123'], - [-10000,'(0,0.0000)','(10 000,0000)'], - [-0.23,'.00','-,23'], - [-0.23,'(.00)','(,23)'], - [0.23,'0.00000','0,23000'], - [1230974,'0.0a','1,2mil.'], - [1460,'0a','1tis.'], - [-104000,'0a','-104tis.'], - [1,'0o','1.'], - [52,'0o','52.'], - [23,'0o','23.'], - [100,'0o','100.'], - [1,'0[.]0','1'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(4); - - var tests = [ - [1000.234,'0,0.00$','1 000,23Kč'], - [-1000.234,'(0,0$)','(1 000Kč)'], - [-1000.234,'0.00$','-1000,23Kč'], - [1230974,'(0.00a$)','1,23mil.Kč'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(4); - - var tests = [ - [1,'0%','100%'], - [0.974878234,'0.000%','97,488%'], - [-0.43,'0%','-43%'], - [0.43,'(0.000%)','43,000%'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - unformat: function (test) { - test.expect(10); - - var tests = [ - ['10 000,123',10000.123], - ['(0,12345)',-0.12345], - ['(1,23mil.Kč)',-1230000], - ['1,23mil.Kč',1230000], - ['10tis.',10000], - ['-10tis.',-10000], - ['23.',23], - ['10 000,00Kč',10000], - ['-76%',-0.76], - ['2:23:57',8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file diff --git a/tests/languages/da-dk.js b/tests/languages/da-dk.js deleted file mode 100644 index 2393eb1c..00000000 --- a/tests/languages/da-dk.js +++ /dev/null @@ -1,101 +0,0 @@ -var numeral = require('../../numeral'), - language = require('../../languages/da-dk'); - -numeral.language('da-dk', language); - -exports['language:da-dk'] = { - setUp: function (callback) { - numeral.language('da-dk'); - callback(); - }, - - tearDown: function (callback) { - numeral.language('en'); - callback(); - }, - - format: function (test) { - test.expect(16); - - var tests = [ - [10000,'0,0.0000','10.000,0000'], - [10000.23,'0,0','10.000'], - [-10000,'0,0.0','-10.000,0'], - [10000.1234,'0.000','10000,123'], - [-10000,'(0,0.0000)','(10.000,0000)'], - [-0.23,'.00','-,23'], - [-0.23,'(.00)','(,23)'], - [0.23,'0.00000','0,23000'], - [1230974,'0.0a','1,2mio'], - [1460,'0a','1k'], - [-104000,'0a','-104k'], - [1,'0o','1.'], - [52,'0o','52.'], - [23,'0o','23.'], - [100,'0o','100.'], - [1,'0[.]0','1'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(4); - - var tests = [ - [1000.234,'$0,0.00','DKK1.000,23'], - [-1000.234,'($0,0)','(DKK1.000)'], - [-1000.234,'$0.00','-DKK1000,23'], - [1230974,'($0.00a)','DKK1,23mio'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(4); - - var tests = [ - [1,'0%','100%'], - [0.974878234,'0.000%','97,488%'], - [-0.43,'0%','-43%'], - [0.43,'(0.000%)','43,000%'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - unformat: function (test) { - test.expect(9); - - var tests = [ - ['10.000,123',10000.123], - ['(0,12345)',-0.12345], - ['(DKK1,23mio)',-1230000], - ['10k',10000], - ['-10k',-10000], - ['23.',23], - ['DK10.000,00',10000], - ['-76%',-0.76], - ['2:23:57',8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file diff --git a/tests/languages/de-ch.js b/tests/languages/de-ch.js deleted file mode 100644 index bb989359..00000000 --- a/tests/languages/de-ch.js +++ /dev/null @@ -1,101 +0,0 @@ -var numeral = require('../../numeral'), - language = require('../../languages/de-ch'); - -numeral.language('de-ch', language); - -exports['language:de-ch'] = { - setUp: function (callback) { - numeral.language('de-ch'); - callback(); - }, - - tearDown: function (callback) { - numeral.language('en'); - callback(); - }, - - format: function (test) { - test.expect(16); - - var tests = [ - [10000,'0,0.0000','10 000,0000'], - [10000.23,'0,0','10 000'], - [-10000,'0,0.0','-10 000,0'], - [10000.1234,'0.000','10000,123'], - [-10000,'(0,0.0000)','(10 000,0000)'], - [-0.23,'.00','-,23'], - [-0.23,'(.00)','(,23)'], - [0.23,'0.00000','0,23000'], - [1230974,'0.0a','1,2m'], - [1460,'0a','1k'], - [-104000,'0a','-104k'], - [1,'0o','1.'], - [52,'0o','52.'], - [23,'0o','23.'], - [100,'0o','100.'], - [1,'0[.]0','1'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(4); - - var tests = [ - [1000.234,'$0,0.00','CHF1 000,23'], - [-1000.234,'($0,0)','(CHF1 000)'], - [-1000.234,'$0.00','-CHF1000,23'], - [1230974,'($0.00a)','CHF1,23m'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(4); - - var tests = [ - [1,'0%','100%'], - [.974878234,'0.000%','97,488%'], - [-.43,'0%','-43%'], - [.43,'(0.000%)','43,000%'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - unformat: function (test) { - test.expect(9); - - var tests = [ - ['10 000,123',10000.123], - ['(0,12345)',-.12345], - ['(CHF1,23m)',-1230000], - ['10k',10000], - ['-10k',-10000], - ['23.',23], - ['CHF10 000,00',10000], - ['-76%',-.76], - ['2:23:57',8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file diff --git a/tests/languages/de.js b/tests/languages/de.js deleted file mode 100644 index 3860d66a..00000000 --- a/tests/languages/de.js +++ /dev/null @@ -1,101 +0,0 @@ -var numeral = require('../../numeral'), - language = require('../../languages/de'); - -numeral.language('de', language); - -exports['language:de'] = { - setUp: function (callback) { - numeral.language('de'); - callback(); - }, - - tearDown: function (callback) { - numeral.language('en'); - callback(); - }, - - format: function (test) { - test.expect(16); - - var tests = [ - [10000,'0,0.0000','10 000,0000'], - [10000.23,'0,0','10 000'], - [-10000,'0,0.0','-10 000,0'], - [10000.1234,'0.000','10000,123'], - [-10000,'(0,0.0000)','(10 000,0000)'], - [-0.23,'.00','-,23'], - [-0.23,'(.00)','(,23)'], - [0.23,'0.00000','0,23000'], - [1230974,'0.0a','1,2m'], - [1460,'0a','1k'], - [-104000,'0a','-104k'], - [1,'0o','1.'], - [52,'0o','52.'], - [23,'0o','23.'], - [100,'0o','100.'], - [1,'0[.]0','1'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(4); - - var tests = [ - [1000.234,'$0,0.00','€1 000,23'], - [-1000.234,'($0,0)','(€1 000)'], - [-1000.234,'$0.00','-€1000,23'], - [1230974,'($0.00a)','€1,23m'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(4); - - var tests = [ - [1,'0%','100%'], - [0.974878234,'0.000%','97,488%'], - [-0.43,'0%','-43%'], - [0.43,'(0.000%)','43,000%'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - unformat: function (test) { - test.expect(9); - - var tests = [ - ['10 000,123',10000.123], - ['(0,12345)',-0.12345], - ['(€1,23m)',-1230000], - ['10k',10000], - ['-10k',-10000], - ['23.',23], - ['€10 000,00',10000], - ['-76%',-0.76], - ['2:23:57',8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file diff --git a/tests/languages/en-gb.js b/tests/languages/en-gb.js deleted file mode 100644 index 45fb975b..00000000 --- a/tests/languages/en-gb.js +++ /dev/null @@ -1,101 +0,0 @@ -var numeral = require('../../numeral'), - language = require('../../languages/en-gb'); - -numeral.language('en-gb', language); - -exports['language:en-gb'] = { - setUp: function (callback) { - numeral.language('en-gb'); - callback(); - }, - - tearDown: function (callback) { - numeral.language('en'); - callback(); - }, - - format: function (test) { - test.expect(16); - - var tests = [ - [10000,'0,0.0000','10,000.0000'], - [10000.23,'0,0','10,000'], - [-10000,'0,0.0','-10,000.0'], - [10000.1234,'0.000','10000.123'], - [-10000,'(0,0.0000)','(10,000.0000)'], - [-0.23,'.00','-.23'], - [-0.23,'(.00)','(.23)'], - [0.23,'0.00000','0.23000'], - [1230974,'0.0a','1.2m'], - [1460,'0a','1k'], - [-104000,'0a','-104k'], - [1,'0o','1st'], - [52,'0o','52nd'], - [23,'0o','23rd'], - [100,'0o','100th'], - [1,'0[.]0','1'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(4); - - var tests = [ - [1000.234,'$0,0.00','£1,000.23'], - [-1000.234,'($0,0)','(£1,000)'], - [-1000.234,'$0.00','-£1000.23'], - [1230974,'($0.00a)','£1.23m'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(4); - - var tests = [ - [1,'0%','100%'], - [0.974878234,'0.000%','97.488%'], - [-0.43,'0%','-43%'], - [0.43,'(0.000%)','43.000%'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - unformat: function (test) { - test.expect(9); - - var tests = [ - ['10,000.123',10000.123], - ['(0.12345)',-0.12345], - ['(£1.23m)',-1230000], - ['10k',10000], - ['-10k',-10000], - ['23rd',23], - ['£10,000.00',10000], - ['-76%',-0.76], - ['2:23:57',8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file diff --git a/tests/languages/en.js b/tests/languages/en.js deleted file mode 100644 index 48a34f37..00000000 --- a/tests/languages/en.js +++ /dev/null @@ -1,98 +0,0 @@ -var numeral = require('../../numeral'); - -exports['language:en'] = { - setUp: function (callback) { - numeral.language('en'); - callback(); - }, - - tearDown: function (callback) { - numeral.language('en'); - callback(); - }, - - format: function (test) { - test.expect(16); - - var tests = [ - [10000,'0,0.0000','10,000.0000'], - [10000.23,'0,0','10,000'], - [-10000,'0,0.0','-10,000.0'], - [10000.1234,'0.000','10000.123'], - [-10000,'(0,0.0000)','(10,000.0000)'], - [-0.23,'.00','-.23'], - [-0.23,'(.00)','(.23)'], - [0.23,'0.00000','0.23000'], - [1230974,'0.0a','1.2m'], - [1460,'0a','1k'], - [-104000,'0a','-104k'], - [1,'0o','1st'], - [52,'0o','52nd'], - [23,'0o','23rd'], - [100,'0o','100th'], - [1,'0[.]0','1'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(4); - - var tests = [ - [1000.234,'$0,0.00','$1,000.23'], - [-1000.234,'($0,0)','($1,000)'], - [-1000.234,'$0.00','-$1000.23'], - [1230974,'($0.00a)','$1.23m'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(4); - - var tests = [ - [1,'0%','100%'], - [0.974878234,'0.000%','97.488%'], - [-0.43,'0%','-43%'], - [0.43,'(0.000%)','43.000%'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - unformat: function (test) { - test.expect(9); - - var tests = [ - ['10,000.123',10000.123], - ['(0.12345)',-0.12345], - ['($1.23m)',-1230000], - ['10k',10000], - ['-10k',-10000], - ['23rd',23], - ['$10,000.00',10000], - ['-76%',-0.76], - ['2:23:57',8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file diff --git a/tests/languages/es-ES.js b/tests/languages/es-ES.js deleted file mode 100644 index a0db5368..00000000 --- a/tests/languages/es-ES.js +++ /dev/null @@ -1,101 +0,0 @@ -var numeral = require('../../numeral'), - language = require('../../languages/es-ES'); - -numeral.language('es-ES', language); - -exports['language:es-ES'] = { - setUp: function (callback) { - numeral.language('es-ES'); - callback(); - }, - - tearDown: function (callback) { - numeral.language('en'); - callback(); - }, - - format: function (test) { - test.expect(16); - - var tests = [ - [10000,'0,0.0000','10.000,0000'], - [10000.23,'0,0','10.000'], - [-10000,'0,0.0','-10.000,0'], - [10000.1234,'0.000','10000,123'], - [-10000,'(0,0.0000)','(10.000,0000)'], - [-0.23,'.00','-,23'], - [-0.23,'(.00)','(,23)'], - [0.23,'0.00000','0,23000'], - [1230974,'0.0a','1,2mm'], - [1460,'0a','1k'], - [-104000,'0a','-104k'], - [1,'0o','1er'], - [52,'0o','52do'], - [23,'0o','23er'], - [100,'0o','100mo'], - [1,'0[.]0','1'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(4); - - var tests = [ - [1000.234,'$0,0.00','€1.000,23'], - [-1000.234,'($0,0)','(€1.000)'], - [-1000.234,'$0.00','-€1000,23'], - [1230974,'($0.00a)','€1,23mm'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(4); - - var tests = [ - [1,'0%','100%'], - [0.974878234,'0.000%','97,488%'], - [-0.43,'0%','-43%'], - [0.43,'(0.000%)','43,000%'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - unformat: function (test) { - test.expect(9); - - var tests = [ - ['10.000,123',10000.123], - ['(0,12345)',-0.12345], - ['($1,23mm)',-1230000], - ['10k',10000], - ['-10k',-10000], - ['23er',23], - ['$10.000,00',10000], - ['-76%',-0.76], - ['2:23:57',8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file diff --git a/tests/languages/es.js b/tests/languages/es.js deleted file mode 100644 index 06843184..00000000 --- a/tests/languages/es.js +++ /dev/null @@ -1,101 +0,0 @@ -var numeral = require('../../numeral'), - language = require('../../languages/es'); - -numeral.language('es', language); - -exports['language:es'] = { - setUp: function (callback) { - numeral.language('es'); - callback(); - }, - - tearDown: function (callback) { - numeral.language('en'); - callback(); - }, - - format: function (test) { - test.expect(16); - - var tests = [ - [10000,'0,0.0000','10.000,0000'], - [10000.23,'0,0','10.000'], - [-10000,'0,0.0','-10.000,0'], - [10000.1234,'0.000','10000,123'], - [-10000,'(0,0.0000)','(10.000,0000)'], - [-0.23,'.00','-,23'], - [-0.23,'(.00)','(,23)'], - [0.23,'0.00000','0,23000'], - [1230974,'0.0a','1,2mm'], - [1460,'0a','1k'], - [-104000,'0a','-104k'], - [1,'0o','1er'], - [52,'0o','52do'], - [23,'0o','23er'], - [100,'0o','100mo'], - [1,'0[.]0','1'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(4); - - var tests = [ - [1000.234,'$0,0.00','$1.000,23'], - [-1000.234,'($0,0)','($1.000)'], - [-1000.234,'$0.00','-$1000,23'], - [1230974,'($0.00a)','$1,23mm'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(4); - - var tests = [ - [1,'0%','100%'], - [0.974878234,'0.000%','97,488%'], - [-0.43,'0%','-43%'], - [0.43,'(0.000%)','43,000%'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - unformat: function (test) { - test.expect(9); - - var tests = [ - ['10.000,123',10000.123], - ['(0,12345)',-0.12345], - ['($1,23mm)',-1230000], - ['10k',10000], - ['-10k',-10000], - ['23er',23], - ['$10.000,00',10000], - ['-76%',-0.76], - ['2:23:57',8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file diff --git a/tests/languages/et.js b/tests/languages/et.js deleted file mode 100644 index 1f1e54a3..00000000 --- a/tests/languages/et.js +++ /dev/null @@ -1,101 +0,0 @@ -var numeral = require('../../numeral'), - language = require('../../languages/et'); - -numeral.language('et', language); - -exports['language:et'] = { - setUp: function (callback) { - numeral.language('et'); - callback(); - }, - - tearDown: function (callback) { - numeral.language('en'); - callback(); - }, - - format: function (test) { - test.expect(16); - - var tests = [ - [10000,'0,0.0000','10 000,0000'], - [10000.23,'0,0','10 000'], - [-10000,'0,0.0','-10 000,0'], - [10000.1234,'0.000','10000,123'], - [-10000,'(0,0.0000)','(10 000,0000)'], - [-0.23,'.00','-,23'], - [-0.23,'(.00)','(,23)'], - [0.23,'0.00000','0,23000'], - [1230974,'0.0a','1,2 mln'], - [1460,'0a','1 tuh'], - [-104000,'0a','-104 tuh'], - [1,'0o','1.'], - [52,'0o','52.'], - [23,'0o','23.'], - [100,'0o','100.'], - [1,'0[.]0','1'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(4); - - var tests = [ - [1000.234,'$0,0.00','€1 000,23'], - [-1000.234,'($0,0)','(€1 000)'], - [-1000.234,'$0.00','-€1000,23'], - [1230974,'($0.00a)','€1,23 mln'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(4); - - var tests = [ - [1,'0%','100%'], - [0.974878234,'0.000%','97,488%'], - [-0.43,'0%','-43%'], - [0.43,'(0.000%)','43,000%'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - unformat: function (test) { - test.expect(9); - - var tests = [ - ['10.000,123',10000.123], - ['(0,12345)',-0.12345], - ['(€1,23 mln)',-1230000], - ['10 tuh',10000], - ['-10 tuh',-10000], - ['23.',23], - ['€10.000,00',10000], - ['-76%',-0.76], - ['2:23:57',8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file diff --git a/tests/languages/fi.js b/tests/languages/fi.js deleted file mode 100644 index 2637f074..00000000 --- a/tests/languages/fi.js +++ /dev/null @@ -1,101 +0,0 @@ -var numeral = require('../../numeral'), - language = require('../../languages/fi'); - -numeral.language('fi', language); - -exports['language:fi'] = { - setUp: function (callback) { - numeral.language('fi'); - callback(); - }, - - tearDown: function (callback) { - numeral.language('en'); - callback(); - }, - - format: function (test) { - test.expect(16); - - var tests = [ - [10000,'0,0.0000','10 000,0000'], - [10000.23,'0,0','10 000'], - [-10000,'0,0.0','-10 000,0'], - [10000.1234,'0.000','10000,123'], - [-10000,'(0,0.0000)','(10 000,0000)'], - [-0.23,'.00','-,23'], - [-0.23,'(.00)','(,23)'], - [0.23,'0.00000','0,23000'], - [1230974,'0.0a','1,2M'], - [1460,'0a','1k'], - [-104000,'0a','-104k'], - [1,'0o','1.'], - [52,'0o','52.'], - [23,'0o','23.'], - [100,'0o','100.'], - [1,'0[.]0','1'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(4); - - var tests = [ - [1000.234,'$0,0.00','€1 000,23'], - [-1000.234,'($0,0)','(€1 000)'], - [-1000.234,'$0.00','-€1000,23'], - [1230974,'($0.00a)','€1,23M'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(4); - - var tests = [ - [1,'0%','100%'], - [0.974878234,'0.000%','97,488%'], - [-0.43,'0%','-43%'], - [0.43,'(0.000%)','43,000%'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - unformat: function (test) { - test.expect(9); - - var tests = [ - ['10.000,123',10000.123], - ['(0,12345)',-0.12345], - ['(€1,23M)',-1230000], - ['10k',10000], - ['-10k',-10000], - ['23.',23], - ['€10.000,00',10000], - ['-76%',-0.76], - ['2:23:57',8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file diff --git a/tests/languages/fr-CA.js b/tests/languages/fr-CA.js deleted file mode 100644 index 8ad94bc3..00000000 --- a/tests/languages/fr-CA.js +++ /dev/null @@ -1,101 +0,0 @@ -var numeral = require('../../numeral'), - language = require('../../languages/fr-CA'); - -numeral.language('fr-CA', language); - -exports['language:fr'] = { - setUp: function (callback) { - numeral.language('fr-CA'); - callback(); - }, - - tearDown: function (callback) { - numeral.language('en'); - callback(); - }, - - format: function (test) { - test.expect(16); - - var tests = [ - [10000,'0,0.0000','10 000,0000'], - [10000.23,'0,0','10 000'], - [-10000,'0,0.0','-10 000,0'], - [10000.1234,'0.000','10000,123'], - [-10000,'(0,0.0000)','(10 000,0000)'], - [-0.23,'.00','-,23'], - [-0.23,'(.00)','(,23)'], - [0.23,'0.00000','0,23000'], - [1230974,'0.0 a','1,2 M'], - [1460,'0 a','1 k'], - [-104000,'0 a','-104 k'], - [1,'0o','1er'], - [52,'0o','52e'], - [23,'0o','23e'], - [100,'0o','100e'], - [1,'0[.]0','1'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(4); - - var tests = [ - [1000.234,'0,0.00 $','1 000,23 $'], - [-1000.234,'(0,0 $)','(1 000 $)'], - [-1000.234,'0.00 $','-1000,23 $'], - [1230974,'(0.00 a$)','1,23 M$'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(4); - - var tests = [ - [1,'0 %','100 %'], - [0.974878234,'0.000 %','97,488 %'], - [-0.43,'0 %','-43 %'], - [0.43,'(0.000 %)','43,000 %'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - unformat: function (test) { - test.expect(9); - - var tests = [ - ['10 000,123',10000.123], - ['(0,12345)',-0.12345], - ['(1,23 M$)',-1230000], - ['10 k',10000], - ['-10 k',-10000], - ['23e',23], - ['10 000,00 $',10000], - ['-76 %',-0.76], - ['2:23:57',8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file diff --git a/tests/languages/fr-ch.js b/tests/languages/fr-ch.js deleted file mode 100644 index 14a9a22d..00000000 --- a/tests/languages/fr-ch.js +++ /dev/null @@ -1,101 +0,0 @@ -var numeral = require('../../numeral'), - language = require('../../languages/fr-ch'); - -numeral.language('fr-ch', language); - -exports['language:fr-ch'] = { - setUp: function (callback) { - numeral.language('fr-ch'); - callback(); - }, - - tearDown: function (callback) { - numeral.language('en'); - callback(); - }, - - format: function (test) { - test.expect(16); - - var tests = [ - [10000,'0,0.0000','10\'000.0000'], - [10000.23,'0,0','10\'000'], - [-10000,'0,0.0','-10\'000.0'], - [10000.1234,'0.000','10000.123'], - [-10000,'(0,0.0000)','(10\'000.0000)'], - [-0.23,'.00','-.23'], - [-0.23,'(.00)','(.23)'], - [0.23,'0.00000','0.23000'], - [1230974,'0.0a','1.2m'], - [1460,'0a','1k'], - [-104000,'0a','-104k'], - [1,'0o','1er'], - [52,'0o','52e'], - [23,'0o','23e'], - [100,'0o','100e'], - [1,'0[.]0','1'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(4); - - var tests = [ - [1000.234,'$0,0.00','CHF1\'000.23'], - [-1000.234,'($0,0)','(CHF1\'000)'], - [-1000.234,'$0.00','-CHF1000.23'], - [1230974,'($0.00a)','CHF1.23m'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(4); - - var tests = [ - [1,'0%','100%'], - [0.974878234,'0.000%','97.488%'], - [-0.43,'0%','-43%'], - [0.43,'(0.000%)','43.000%'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - unformat: function (test) { - test.expect(9); - - var tests = [ - ['10\'000.123',10000.123], - ['(0.12345)',-0.12345], - ['(CHF1.23m)',-1230000], - ['10k',10000], - ['-10k',-10000], - ['23e',23], - ['CHF10\'000.00',10000], - ['-76%',-0.76], - ['2:23:57',8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file diff --git a/tests/languages/fr.js b/tests/languages/fr.js deleted file mode 100644 index 3a461538..00000000 --- a/tests/languages/fr.js +++ /dev/null @@ -1,101 +0,0 @@ -var numeral = require('../../numeral'), - language = require('../../languages/fr'); - -numeral.language('fr', language); - -exports['language:fr'] = { - setUp: function (callback) { - numeral.language('fr'); - callback(); - }, - - tearDown: function (callback) { - numeral.language('en'); - callback(); - }, - - format: function (test) { - test.expect(16); - - var tests = [ - [10000,'0,0.0000','10 000,0000'], - [10000.23,'0,0','10 000'], - [-10000,'0,0.0','-10 000,0'], - [10000.1234,'0.000','10000,123'], - [-10000,'(0,0.0000)','(10 000,0000)'], - [-0.23,'.00','-,23'], - [-0.23,'(.00)','(,23)'], - [0.23,'0.00000','0,23000'], - [1230974,'0.0a','1,2m'], - [1460,'0a','1k'], - [-104000,'0a','-104k'], - [1,'0o','1er'], - [52,'0o','52e'], - [23,'0o','23e'], - [100,'0o','100e'], - [1,'0[.]0','1'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(4); - - var tests = [ - [1000.234,'$0,0.00','€1 000,23'], - [-1000.234,'($0,0)','(€1 000)'], - [-1000.234,'$0.00','-€1000,23'], - [1230974,'($0.00a)','€1,23m'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(4); - - var tests = [ - [1,'0%','100%'], - [0.974878234,'0.000%','97,488%'], - [-0.43,'0%','-43%'], - [0.43,'(0.000%)','43,000%'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - unformat: function (test) { - test.expect(9); - - var tests = [ - ['10 000,123',10000.123], - ['(0,12345)',-0.12345], - ['(€1,23m)',-1230000], - ['10k',10000], - ['-10k',-10000], - ['23e',23], - ['€10 000,00',10000], - ['-76%',-0.76], - ['2:23:57',8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file diff --git a/tests/languages/hu.js b/tests/languages/hu.js deleted file mode 100644 index 407baaae..00000000 --- a/tests/languages/hu.js +++ /dev/null @@ -1,101 +0,0 @@ -var numeral = require('../../numeral'), - language = require('../../languages/hu'); - -numeral.language('hu', language); - -exports['language:hu'] = { - setUp: function (callback) { - numeral.language('hu'); - callback(); - }, - - tearDown: function (callback) { - numeral.language('en'); - callback(); - }, - - format: function (test) { - test.expect(16); - - var tests = [ - [10000,'0,0.0000','10 000,0000'], - [10000.23,'0,0','10 000'], - [-10000,'0,0.0','-10 000,0'], - [10000.1234,'0.000','10000,123'], - [-10000,'(0,0.0000)','(10 000,0000)'], - [-0.23,'.00','-,23'], - [-0.23,'(.00)','(,23)'], - [0.23,'0.00000','0,23000'], - [1230974,'0.0a','1,2M'], - [1460,'0a','1E'], - [-104000,'0a','-104E'], - [1,'0o','1.'], - [52,'0o','52.'], - [23,'0o','23.'], - [100,'0o','100.'], - [1,'0[.]0','1'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(4); - - var tests = [ - [1000.234,'0,0.00$','1 000,23 Ft'], - [-1000.234,'(0,0$)','(1 000 Ft)'], - [-1000.234,'0.00$','-1000,23 Ft'], - [1230974,'(0.00a$)','1,23M Ft'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(4); - - var tests = [ - [1,'0%','100%'], - [0.974878234,'0.000%','97,488%'], - [-0.43,'0%','-43%'], - [0.43,'(0.000%)','43,000%'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - unformat: function (test) { - test.expect(9); - - var tests = [ - ['10 000,123',10000.123], - ['(0,12345)',-0.12345], - ['(1,23M Ft)',-1230000], - ['10E',10000], - ['-10E',-10000], - ['23.',23], - ['10 000,00 Ft',10000], - ['-76%',-0.76], - ['2:23:57',8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file diff --git a/tests/languages/it.js b/tests/languages/it.js deleted file mode 100644 index 0d610793..00000000 --- a/tests/languages/it.js +++ /dev/null @@ -1,101 +0,0 @@ -var numeral = require('../../numeral'), - language = require('../../languages/it'); - -numeral.language('it', language); - -exports['language:it'] = { - setUp: function (callback) { - numeral.language('it'); - callback(); - }, - - tearDown: function (callback) { - numeral.language('en'); - callback(); - }, - - format: function (test) { - test.expect(16); - - var tests = [ - [10000,'0,0.0000','10.000,0000'], - [10000.23,'0,0','10.000'], - [-10000,'0,0.0','-10.000,0'], - [10000.1234,'0.000','10000,123'], - [-10000,'(0,0.0000)','(10.000,0000)'], - [-0.23,'.00','-,23'], - [-0.23,'(.00)','(,23)'], - [0.23,'0.00000','0,23000'], - [1230974,'0.0a','1,2mil'], - [1460,'0a','1mila'], - [-104000,'0a','-104mila'], - [1,'0o','1º'], - [52,'0o','52º'], - [23,'0o','23º'], - [100,'0o','100º'], - [1,'0[.]0','1'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(4); - - var tests = [ - [1000.234,'$0,0.00','€1.000,23'], - [-1000.234,'($0,0)','(€1.000)'], - [-1000.234,'$0.00','-€1000,23'], - [1230974,'($0.00a)','€1,23mil'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(4); - - var tests = [ - [1,'0%','100%'], - [0.974878234,'0.000%','97,488%'], - [-0.43,'0%','-43%'], - [0.43,'(0.000%)','43,000%'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - unformat: function (test) { - test.expect(9); - - var tests = [ - ['10.000,123',10000.123], - ['(0,12345)',-0.12345], - ['(€1,23mil)',-1230000], - ['10mila',10000], - ['-10mila',-10000], - ['23º',23], - ['€10.000,00',10000], - ['-76%',-0.76], - ['2:23:57',8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file diff --git a/tests/languages/ja.js b/tests/languages/ja.js deleted file mode 100644 index 6e58bd82..00000000 --- a/tests/languages/ja.js +++ /dev/null @@ -1,101 +0,0 @@ -var numeral = require('../../numeral'), - language = require('../../languages/ja'); - -numeral.language('ja', language); - -exports['language:ja'] = { - setUp: function (callback) { - numeral.language('ja'); - callback(); - }, - - tearDown: function (callback) { - numeral.language('en'); - callback(); - }, - - format: function (test) { - test.expect(16); - - var tests = [ - [10000,'0,0.0000','10,000.0000'], - [10000.23,'0,0','10,000'], - [-10000,'0,0.0','-10,000.0'], - [10000.1234,'0.000','10000.123'], - [-10000,'(0,0.0000)','(10,000.0000)'], - [-0.23,'.00','-.23'], - [-0.23,'(.00)','(.23)'], - [0.23,'0.00000','0.23000'], - [1230974,'0.0a','1.2百万'], - [1460,'0a','1千'], - [-104000,'0a','-104千'], - [1,'0o','1.'], - [52,'0o','52.'], - [23,'0o','23.'], - [100,'0o','100.'], - [1,'0[.]0','1'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(4); - - var tests = [ - [1000.234,'$0,0.00','¥1,000.23'], - [-1000.234,'($0,0)','(¥1,000)'], - [-1000.234,'$0.00','-¥1000.23'], - [1230974,'($0.00a)','¥1.23百万'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(4); - - var tests = [ - [1,'0%','100%'], - [0.974878234,'0.000%','97.488%'], - [-0.43,'0%','-43%'], - [0.43,'(0.000%)','43.000%'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - unformat: function (test) { - test.expect(9); - - var tests = [ - ['10,000.123',10000.123], - ['(0.12345)',-0.12345], - ['(¥1.23百万)',-1230000], - ['10千',10000], - ['-10千',-10000], - ['23.',23], - ['¥10,000.00',10000], - ['-76%',-0.76], - ['2:23:57',8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file diff --git a/tests/languages/nl-nl.js b/tests/languages/nl-nl.js deleted file mode 100644 index ce49b07e..00000000 --- a/tests/languages/nl-nl.js +++ /dev/null @@ -1,109 +0,0 @@ -var numeral = require('../../numeral'), - language = require('../../languages/nl-nl'); - -numeral.language('nl-nl', language); - -exports['language:nl-nl'] = { - setUp: function (callback) { - numeral.language('nl-nl'); - callback(); - }, - - tearDown: function (callback) { - numeral.language('en'); - callback(); - }, - - format: function (test) { - test.expect(24); - - var tests = [ - [10000,'0,0.0000','10.000,0000'], - [10000.23,'0,0','10.000'], - [-10000,'0,0.0','-10.000,0'], - [10000.1234,'0.000','10000,123'], - [-10000,'(0,0.0000)','(10.000,0000)'], - [-0.23,'.00','-,23'], - [-0.23,'(.00)','(,23)'], - [0.23,'0.00000','0,23000'], - [1230974,'0.0a','1,2mln'], - [1430974124,'0.0a','1,4mrd'], - [9123456789234,'0.0a','9,1bln'], - [1460,'0a','1k'], - [-104000,'0a','-104k'], - [0,'0o','0de'], - [1,'0o','1ste'], - [2,'0o','2de'], - [8,'0o','8ste'], - [19,'0o','19de'], - [20,'0o','20ste'], - [100,'0o','100ste'], - [102,'0o','102de'], - [108,'0o','108ste'], - [109,'0o','109de'], - [1,'0[.]0','1'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(4); - - var tests = [ - [1000.234,'$0,0.00','€ 1.000,23'], - [-1000.234,'($0,0)','(€ 1.000)'], - [-1000.234,'$0.00','-€ 1000,23'], - [1230974,'($0.00a)','€ 1,23mln'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(4); - - var tests = [ - [1,'0%','100%'], - [0.974878234,'0.000%','97,488%'], - [-0.43,'0%','-43%'], - [0.43,'(0.000%)','43,000%'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - unformat: function (test) { - test.expect(9); - - var tests = [ - ['10.000,123',10000.123], - ['(0,12345)',-0.12345], - ['(€ 1,23 mln)',-1230000], - ['10k',10000], - ['-10k',-10000], - ['23e',23], - ['€ 10.000,00',10000], - ['-76%',-0.76], - ['2:23:57',8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file diff --git a/tests/languages/pl.js b/tests/languages/pl.js deleted file mode 100644 index 51e5e2d4..00000000 --- a/tests/languages/pl.js +++ /dev/null @@ -1,102 +0,0 @@ -var numeral = require('../../numeral'), - language = require('../../languages/pl'); - -numeral.language('pl', language); - -exports['language:pl'] = { - setUp: function (callback) { - numeral.language('pl'); - callback(); - }, - - tearDown: function (callback) { - numeral.language('en'); - callback(); - }, - - format: function (test) { - test.expect(16); - - var tests = [ - [10000,'0,0.0000','10 000,0000'], - [10000.23,'0,0','10 000'], - [-10000,'0,0.0','-10 000,0'], - [10000.1234,'0.000','10000,123'], - [-10000,'(0,0.0000)','(10 000,0000)'], - [-0.23,'.00','-,23'], - [-0.23,'(.00)','(,23)'], - [0.23,'0.00000','0,23000'], - [1230974,'0.0a','1,2mln'], - [1460,'0a','1tys.'], - [-104000,'0a','-104tys.'], - [1,'0o','1.'], - [52,'0o','52.'], - [23,'0o','23.'], - [100,'0o','100.'], - [1,'0[.]0','1'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(4); - - var tests = [ - [1000.234,'0,0.00$','1 000,23PLN'], - [-1000.234,'(0,0$)','(1 000PLN)'], - [-1000.234,'0.00$','-1000,23PLN'], - [1230974,'(0.00a$)','1,23mlnPLN'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(4); - - var tests = [ - [1,'0%','100%'], - [0.974878234,'0.000%','97,488%'], - [-0.43,'0%','-43%'], - [0.43,'(0.000%)','43,000%'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - unformat: function (test) { - test.expect(10); - - var tests = [ - ['10 000,123',10000.123], - ['(0,12345)',-0.12345], - ['(1,23mlnPLN)',-1230000], - ['1,23mlnPLN',1230000], - ['10tys.',10000], - ['-10tys.',-10000], - ['23.',23], - ['10 000,00PLN',10000], - ['-76%',-0.76], - ['2:23:57',8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file diff --git a/tests/languages/pt-br.js b/tests/languages/pt-br.js deleted file mode 100644 index 965965a1..00000000 --- a/tests/languages/pt-br.js +++ /dev/null @@ -1,101 +0,0 @@ -var numeral = require('../../numeral'), - language = require('../../languages/pt-br'); - -numeral.language('pt-br', language); - -exports['language:pt-br'] = { - setUp: function (callback) { - numeral.language('pt-br'); - callback(); - }, - - tearDown: function (callback) { - numeral.language('en'); - callback(); - }, - - format: function (test) { - test.expect(16); - - var tests = [ - [10000,'0,0.0000','10.000,0000'], - [10000.23,'0,0','10.000'], - [-10000,'0,0.0','-10.000,0'], - [10000.1234,'0.000','10000,123'], - [-10000,'(0,0.0000)','(10.000,0000)'], - [-0.23,'.00','-,23'], - [-0.23,'(.00)','(,23)'], - [0.23,'0.00000','0,23000'], - [1230974,'0.0a','1,2milhões'], - [1460,'0a','1mil'], - [-104000,'0a','-104mil'], - [1,'0o','1º'], - [52,'0o','52º'], - [23,'0o','23º'], - [100,'0o','100º'], - [1,'0[.]0','1'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(4); - - var tests = [ - [1000.234,'$0,0.00','R$1.000,23'], - [-1000.234,'($0,0)','(R$1.000)'], - [-1000.234,'$0.00','-R$1000,23'], - [1230974,'($0.00a)','R$1,23milhões'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(4); - - var tests = [ - [1,'0%','100%'], - [0.974878234,'0.000%','97,488%'], - [-0.43,'0%','-43%'], - [0.43,'(0.000%)','43,000%'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - unformat: function (test) { - test.expect(9); - - var tests = [ - ['10.000,123',10000.123], - ['(0,12345)',-0.12345], - ['(R$1,23milhões)',-1230000], - ['10mil',10000], - ['-10mil',-10000], - ['23º',23], - ['R$10.000,00',10000], - ['-76%',-0.76], - ['2:23:57',8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file diff --git a/tests/languages/pt-pt.js b/tests/languages/pt-pt.js deleted file mode 100644 index d6d1221e..00000000 --- a/tests/languages/pt-pt.js +++ /dev/null @@ -1,101 +0,0 @@ -var numeral = require('../../numeral'), - language = require('../../languages/pt-pt'); - -numeral.language('pt-pt', language); - -exports['language:pt-pt'] = { - setUp: function (callback) { - numeral.language('pt-pt'); - callback(); - }, - - tearDown: function (callback) { - numeral.language('en'); - callback(); - }, - - format: function (test) { - test.expect(16); - - var tests = [ - [10000,'0,0.0000','10 000,0000'], - [10000.23,'0,0','10 000'], - [-10000,'0,0.0','-10 000,0'], - [10000.1234,'0.000','10000,123'], - [-10000,'(0,0.0000)','(10 000,0000)'], - [-0.23,'.00','-,23'], - [-0.23,'(.00)','(,23)'], - [0.23,'0.00000','0,23000'], - [1230974,'0.0a','1,2m'], - [1460,'0a','1k'], - [-104000,'0a','-104k'], - [1,'0o','1º'], - [52,'0o','52º'], - [23,'0o','23º'], - [100,'0o','100º'], - [1,'0[.]0','1'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(4); - - var tests = [ - [1000.234,'$0,0.00','€1 000,23'], - [-1000.234,'($0,0)','(€1 000)'], - [-1000.234,'$0.00','-€1000,23'], - [1230974,'($0.00a)','€1,23m'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(4); - - var tests = [ - [1,'0%','100%'], - [0.974878234,'0.000%','97,488%'], - [-0.43,'0%','-43%'], - [0.43,'(0.000%)','43,000%'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - unformat: function (test) { - test.expect(9); - - var tests = [ - ['10 000,123',10000.123], - ['(0,12345)',-0.12345], - ['(€1,23m)',-1230000], - ['10k',10000], - ['-10k',-10000], - ['23º',23], - ['€10 000,00',10000], - ['-76%',-0.76], - ['2:23:57',8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file diff --git a/tests/languages/ru-UA.js b/tests/languages/ru-UA.js deleted file mode 100644 index 36651dce..00000000 --- a/tests/languages/ru-UA.js +++ /dev/null @@ -1,102 +0,0 @@ -var numeral = require('../../numeral'), - language = require('../../languages/ru-UA'); - -numeral.language('ru-UA', language); - -exports['language:ru-UA'] = { - setUp: function (callback) { - numeral.language('ru-UA'); - callback(); - }, - - tearDown: function (callback) { - numeral.language('en'); - callback(); - }, - - format: function (test) { - test.expect(16); - - var tests = [ - [10000,'0,0.0000','10 000,0000'], - [10000.23,'0,0','10 000'], - [-10000,'0,0.0','-10 000,0'], - [10000.1234,'0.000','10000,123'], - [-10000,'(0,0.0000)','(10 000,0000)'], - [-0.23,'.00','-,23'], - [-0.23,'(.00)','(,23)'], - [0.23,'0.00000','0,23000'], - [1230974,'0.0a','1,2млн'], - [1460,'0a','1тыс.'], - [-104000,'0a','-104тыс.'], - [1,'0o','1.'], - [52,'0o','52.'], - [23,'0o','23.'], - [100,'0o','100.'], - [1,'0[.]0','1'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(4); - - var tests = [ - [1000.234,'0,0.00$','1 000,23₴'], - [-1000.234,'(0,0$)','(1 000₴)'], - [-1000.234,'0.00$','-1000,23₴'], - [1230974,'(0.00a$)','1,23млн₴'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(4); - - var tests = [ - [1,'0%','100%'], - [0.974878234,'0.000%','97,488%'], - [-0.43,'0%','-43%'], - [0.43,'(0.000%)','43,000%'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - unformat: function (test) { - test.expect(10); - - var tests = [ - ['10 000,123',10000.123], - ['(0,12345)',-0.12345], - ['(1,23млн₴)',-1230000], - ['1,23млн₴',1230000], - ['10тыс.',10000], - ['-10тыс.',-10000], - ['23.',23], - ['10 000,00₴',10000], - ['-76%',-0.76], - ['2:23:57',8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file diff --git a/tests/languages/ru.js b/tests/languages/ru.js deleted file mode 100644 index 90ec7723..00000000 --- a/tests/languages/ru.js +++ /dev/null @@ -1,102 +0,0 @@ -var numeral = require('../../numeral'), - language = require('../../languages/ru'); - -numeral.language('ru', language); - -exports['language:ru'] = { - setUp: function (callback) { - numeral.language('ru'); - callback(); - }, - - tearDown: function (callback) { - numeral.language('en'); - callback(); - }, - - format: function (test) { - test.expect(16); - - var tests = [ - [10000,'0,0.0000','10 000,0000'], - [10000.23,'0,0','10 000'], - [-10000,'0,0.0','-10 000,0'], - [10000.1234,'0.000','10000,123'], - [-10000,'(0,0.0000)','(10 000,0000)'], - [-0.23,'.00','-,23'], - [-0.23,'(.00)','(,23)'], - [0.23,'0.00000','0,23000'], - [1230974,'0.0a','1,2млн'], - [1460,'0a','1тыс.'], - [-104000,'0a','-104тыс.'], - [1,'0o','1.'], - [52,'0o','52.'], - [23,'0o','23.'], - [100,'0o','100.'], - [1,'0[.]0','1'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(4); - - var tests = [ - [1000.234,'0,0.00$','1 000,23руб.'], - [-1000.234,'(0,0$)','(1 000руб.)'], - [-1000.234,'0.00$','-1000,23руб.'], - [1230974,'(0.00a$)','1,23млнруб.'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(4); - - var tests = [ - [1,'0%','100%'], - [0.974878234,'0.000%','97,488%'], - [-0.43,'0%','-43%'], - [0.43,'(0.000%)','43,000%'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - unformat: function (test) { - test.expect(10); - - var tests = [ - ['10 000,123',10000.123], - ['(0,12345)',-0.12345], - ['(1,23млнруб.)',-1230000], - ['1,23млнруб.',1230000], - ['10тыс.',10000], - ['-10тыс.',-10000], - ['23.',23], - ['10 000,00руб.',10000], - ['-76%',-0.76], - ['2:23:57',8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file diff --git a/tests/languages/sk.js b/tests/languages/sk.js deleted file mode 100644 index 6e40ba0f..00000000 --- a/tests/languages/sk.js +++ /dev/null @@ -1,101 +0,0 @@ -var numeral = require('../../numeral'), - language = require('../../languages/sk'); - -numeral.language('sk', language); - -exports['language:sk'] = { - setUp: function (callback) { - numeral.language('sk'); - callback(); - }, - - tearDown: function (callback) { - numeral.language('en'); - callback(); - }, - - format: function (test) { - test.expect(16); - - var tests = [ - [10000,'0,0.0000','10 000,0000'], - [10000.23,'0,0','10 000'], - [-10000,'0,0.0','-10 000,0'], - [10000.1234,'0.000','10000,123'], - [-10000,'(0,0.0000)','(10 000,0000)'], - [-0.23,'.00','-,23'], - [-0.23,'(.00)','(,23)'], - [0.23,'0.00000','0,23000'], - [1230974,'0.0a','1,2mil.'], - [1460,'0a','1tis.'], - [-104000,'0a','-104tis.'], - [1,'0o','1.'], - [52,'0o','52.'], - [23,'0o','23.'], - [100,'0o','100.'], - [1,'0[.]0','1'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(4); - - var tests = [ - [1000.234,'$0,0.00','€1 000,23'], - [-1000.234,'($0,0)','(€1 000)'], - [-1000.234,'$0.00','-€1000,23'], - [1230974,'($0.00a)','€1,23mil.'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(4); - - var tests = [ - [1,'0%','100%'], - [0.974878234,'0.000%','97,488%'], - [-0.43,'0%','-43%'], - [0.43,'(0.000%)','43,000%'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - unformat: function (test) { - test.expect(9); - - var tests = [ - ['10 000,123',10000.123], - ['(0,12345)',-0.12345], - ['(€1,23mil.)',-1230000], - ['10tis.',10000], - ['-10tis.',-10000], - ['23e',23], - ['€10 000,00',10000], - ['-76%',-0.76], - ['2:23:57',8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file diff --git a/tests/languages/th.js b/tests/languages/th.js deleted file mode 100644 index e0209aa6..00000000 --- a/tests/languages/th.js +++ /dev/null @@ -1,101 +0,0 @@ -var numeral = require('../../numeral'), - language = require('../../languages/th'); - -numeral.language('th', language); - -exports['language:th'] = { - setUp: function (callback) { - numeral.language('th'); - callback(); - }, - - tearDown: function (callback) { - numeral.language('en'); - callback(); - }, - - format: function (test) { - test.expect(16); - - var tests = [ - [10000,'0,0.0000','10,000.0000'], - [10000.23,'0,0','10,000'], - [-10000,'0,0.0','-10,000.0'], - [10000.1234,'0.000','10000.123'], - [-10000,'(0,0.0000)','(10,000.0000)'], - [-0.23,'.00','-.23'], - [-0.23,'(.00)','(.23)'], - [0.23,'0.00000','0.23000'], - [1230974,'0.0a','1.2ล้าน'], - [1460,'0a','1พัน'], - [-104000,'0a','-104พัน'], - [1,'0o','1.'], - [52,'0o','52.'], - [23,'0o','23.'], - [100,'0o','100.'], - [1,'0[.]0','1'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(4); - - var tests = [ - [1000.234,'$0,0.00','฿1,000.23'], - [-1000.234,'($0,0)','(฿1,000)'], - [-1000.234,'$0.00','-฿1000.23'], - [1230974,'($0.00a)','฿1.23ล้าน'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(4); - - var tests = [ - [1,'0%','100%'], - [0.974878234,'0.000%','97.488%'], - [-0.43,'0%','-43%'], - [0.43,'(0.000%)','43.000%'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - unformat: function (test) { - test.expect(9); - - var tests = [ - ['10,000.123',10000.123], - ['(0.12345)',-0.12345], - ['(฿1.23ล้าน)',-1230000], - ['10พัน',10000], - ['-10พัน',-10000], - ['23.',23], - ['฿10,000.00',10000], - ['-76%',-0.76], - ['2:23:57',8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; diff --git a/tests/languages/tr.js b/tests/languages/tr.js deleted file mode 100644 index 3a34d348..00000000 --- a/tests/languages/tr.js +++ /dev/null @@ -1,101 +0,0 @@ -var numeral = require('../../numeral'), - language = require('../../languages/tr'); - -numeral.language('tr', language); - -exports['language:tr'] = { - setUp: function (callback) { - numeral.language('tr'); - callback(); - }, - - tearDown: function (callback) { - numeral.language('en'); - callback(); - }, - - format: function (test) { - test.expect(16); - - var tests = [ - [10000,'0,0.0000','10.000,0000'], - [10000.23,'0,0','10.000'], - [-10000,'0,0.0','-10.000,0'], - [10000.1234,'0.000','10000,123'], - [-10000,'(0,0.0000)','(10.000,0000)'], - [-0.23,'.00','-,23'], - [-0.23,'(.00)','(,23)'], - [0.23,'0.00000','0,23000'], - [1230974,'0.0a','1,2milyon'], - [1460,'0a','1bin'], - [-104000,'0a','-104bin'], - [1,'0o','1\'inci'], - [52,'0o','52\'nci'], - [23,'0o','23\'üncü'], - [100,'0o','100\'üncü'], - [1,'0[.]0','1'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(4); - - var tests = [ - [1000.234,'$0,0.00','\u20BA1.000,23'], - [-1000.234,'($0,0)','(\u20BA1.000)'], - [-1000.234,'$0.00','-\u20BA1000,23'], - [1230974,'($0.00a)','\u20BA1,23milyon'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(4); - - var tests = [ - [1,'0%','100%'], - [0.974878234,'0.000%','97,488%'], - [-0.43,'0%','-43%'], - [0.43,'(0.000%)','43,000%'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - unformat: function (test) { - test.expect(9); - - var tests = [ - ['10.000,123',10000.123], - ['(0,12345)',-0.12345], - ['(\u20BA1,23milyon)',-1230000], - ['10bin',10000], - ['-10bin',-10000], - ['23üncü',23], - ['\u20BA10.000,00',10000], - ['-76%',-0.76], - ['2:23:57',8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file diff --git a/tests/languages/uk-UA.js b/tests/languages/uk-UA.js deleted file mode 100644 index 38e0e0b0..00000000 --- a/tests/languages/uk-UA.js +++ /dev/null @@ -1,102 +0,0 @@ -var numeral = require('../../numeral'), - language = require('../../languages/uk-UA'); - -numeral.language('uk-UA', language); - -exports['language:uk-UA'] = { - setUp: function (callback) { - numeral.language('uk-UA'); - callback(); - }, - - tearDown: function (callback) { - numeral.language('en'); - callback(); - }, - - format: function (test) { - test.expect(16); - - var tests = [ - [10000,'0,0.0000','10 000,0000'], - [10000.23,'0,0','10 000'], - [-10000,'0,0.0','-10 000,0'], - [10000.1234,'0.000','10000,123'], - [-10000,'(0,0.0000)','(10 000,0000)'], - [-0.23,'.00','-,23'], - [-0.23,'(.00)','(,23)'], - [0.23,'0.00000','0,23000'], - [1230974,'0.0a','1,2млн'], - [1460,'0a','1тис.'], - [-104000,'0a','-104тис.'], - [1,'0o','1'], - [52,'0o','52'], - [23,'0o','23'], - [100,'0o','100'], - [1,'0[.]0','1'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(4); - - var tests = [ - [1000.234,'0,0.00$','1 000,23₴'], - [-1000.234,'(0,0$)','(1 000₴)'], - [-1000.234,'0.00$','-1000,23₴'], - [1230974,'(0.00a$)','1,23млн₴'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(4); - - var tests = [ - [1,'0%','100%'], - [0.974878234,'0.000%','97,488%'], - [-0.43,'0%','-43%'], - [0.43,'(0.000%)','43,000%'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - unformat: function (test) { - test.expect(10); - - var tests = [ - ['10 000,123',10000.123], - ['(0,12345)',-0.12345], - ['(1,23млн₴)',-1230000], - ['1,23млн₴',1230000], - ['10тис.',10000], - ['-10тис.',-10000], - ['23.',23], - ['10 000,00₴',10000], - ['-76%',-0.76], - ['2:23:57',8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file diff --git a/tests/locales/bg.js b/tests/locales/bg.js new file mode 100644 index 00000000..04ccc261 --- /dev/null +++ b/tests/locales/bg.js @@ -0,0 +1,94 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: bg', function() { + + before(function() { + numeral.locale('bg'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10 000,0000'], + [10000.23,'0,0','10 000'], + [-10000,'0,0.0','-10 000,0'], + [10000.1234,'0.000','10000,123'], + [-10000,'(0,0.0000)','(10 000,0000)'], + [-0.23,'.00','-,23'], + [-0.23,'(.00)','(,23)'], + [0.23,'0.00000','0,23000'], + [1230974,'0.0a','1,2млн'], + [1460,'0a','1хил'], + [-104000,'0a','-104хил'], + [1,'0o','1'], + [52,'0o','52'], + [23,'0o','23'], + [100,'0o','100'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'$0,0.00','лв1 000,23'], + [-1000.234,'($0,0)','(лв1 000)'], + [-1000.234,'$0.00','-лв1000,23'], + [1230974,'($0.00a)','лв1,23млн'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97,488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43,000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10 000,123',10000.123], + ['(0,12345)',-0.12345], + ['(лв1,23млн)',-1230000], + ['10хил',10000], + ['-10хил',-10000], + ['23',23], + ['лв10 000,00',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/chs.js b/tests/locales/chs.js new file mode 100644 index 00000000..f476e152 --- /dev/null +++ b/tests/locales/chs.js @@ -0,0 +1,94 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: chs', function() { + + before(function() { + numeral.locale('chs'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format number', function() { + var tests = [ + [10000,'0,0.0000','10,000.0000'], + [10000.23,'0,0','10,000'], + [-10000,'0,0.0','-10,000.0'], + [10000.1234,'0.000','10000.123'], + [-10000,'(0,0.0000)','(10,000.0000)'], + [-0.23,'.00','-.23'], + [-0.23,'(.00)','(.23)'], + [0.23,'0.00000','0.23000'], + [1230974,'0.0a','1.2百万'], + [1460,'0a','1千'], + [-104000,'0a','-104千'], + [1,'0o','1.'], + [52,'0o','52.'], + [23,'0o','23.'], + [100,'0o','100.'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'$0,0.00','¥1,000.23'], + [-1000.234,'($0,0)','(¥1,000)'], + [-1000.234,'$0.00','-¥1000.23'], + [1230974,'($0.00a)','¥1.23百万'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97.488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43.000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10,000.123',10000.123], + ['(0.12345)',-0.12345], + ['(¥1.23百万)',-1230000], + ['10千',10000], + ['-10千',-10000], + ['23.',23], + ['¥10,000.00',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/cs.js b/tests/locales/cs.js new file mode 100644 index 00000000..21b9cb9e --- /dev/null +++ b/tests/locales/cs.js @@ -0,0 +1,95 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: cs', function() { + + before(function() { + numeral.locale('cs'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10 000,0000'], + [10000.23,'0,0','10 000'], + [-10000,'0,0.0','-10 000,0'], + [10000.1234,'0.000','10000,123'], + [-10000,'(0,0.0000)','(10 000,0000)'], + [-0.23,'.00','-,23'], + [-0.23,'(.00)','(,23)'], + [0.23,'0.00000','0,23000'], + [1230974,'0.0a','1,2mil.'], + [1460,'0a','1tis.'], + [-104000,'0a','-104tis.'], + [1,'0o','1.'], + [52,'0o','52.'], + [23,'0o','23.'], + [100,'0o','100.'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'0,0.00$','1 000,23Kč'], + [-1000.234,'(0,0$)','(1 000Kč)'], + [-1000.234,'0.00$','-1000,23Kč'], + [1230974,'(0.00a$)','1,23mil.Kč'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97,488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43,000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10 000,123',10000.123], + ['(0,12345)',-0.12345], + ['(1,23mil.Kč)',-1230000], + ['1,23mil.Kč',1230000], + ['10tis.',10000], + ['-10tis.',-10000], + ['23.',23], + ['10 000,00Kč',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/da-dk.js b/tests/locales/da-dk.js new file mode 100644 index 00000000..800612b1 --- /dev/null +++ b/tests/locales/da-dk.js @@ -0,0 +1,94 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: da-dk', function() { + + before(function() { + numeral.locale('da-dk'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10.000,0000'], + [10000.23,'0,0','10.000'], + [-10000,'0,0.0','-10.000,0'], + [10000.1234,'0.000','10000,123'], + [-10000,'(0,0.0000)','(10.000,0000)'], + [-0.23,'.00','-,23'], + [-0.23,'(.00)','(,23)'], + [0.23,'0.00000','0,23000'], + [1230974,'0.0a','1,2mio'], + [1460,'0a','1k'], + [-104000,'0a','-104k'], + [1,'0o','1.'], + [52,'0o','52.'], + [23,'0o','23.'], + [100,'0o','100.'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'$0,0.00','DKK1.000,23'], + [-1000.234,'($0,0)','(DKK1.000)'], + [-1000.234,'$0.00','-DKK1000,23'], + [1230974,'($0.00a)','DKK1,23mio'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97,488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43,000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10.000,123',10000.123], + ['(0,12345)',-0.12345], + ['(DKK1,23mio)',-1230000], + ['10k',10000], + ['-10k',-10000], + ['23.',23], + ['DK10.000,00',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/de-ch.js b/tests/locales/de-ch.js new file mode 100644 index 00000000..8203e1a4 --- /dev/null +++ b/tests/locales/de-ch.js @@ -0,0 +1,94 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: de-ch', function() { + + before(function() { + numeral.locale('de-ch'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10 000,0000'], + [10000.23,'0,0','10 000'], + [-10000,'0,0.0','-10 000,0'], + [10000.1234,'0.000','10000,123'], + [-10000,'(0,0.0000)','(10 000,0000)'], + [-0.23,'.00','-,23'], + [-0.23,'(.00)','(,23)'], + [0.23,'0.00000','0,23000'], + [1230974,'0.0a','1,2m'], + [1460,'0a','1k'], + [-104000,'0a','-104k'], + [1,'0o','1.'], + [52,'0o','52.'], + [23,'0o','23.'], + [100,'0o','100.'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'$0,0.00','CHF1 000,23'], + [-1000.234,'($0,0)','(CHF1 000)'], + [-1000.234,'$0.00','-CHF1000,23'], + [1230974,'($0.00a)','CHF1,23m'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97,488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43,000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10 000,123',10000.123], + ['(0,12345)',-0.12345], + ['(CHF1,23m)',-1230000], + ['10k',10000], + ['-10k',-10000], + ['23.',23], + ['CHF10 000,00',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/de.js b/tests/locales/de.js new file mode 100644 index 00000000..cf1d652d --- /dev/null +++ b/tests/locales/de.js @@ -0,0 +1,94 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: de', function() { + + before(function() { + numeral.locale('de'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10 000,0000'], + [10000.23,'0,0','10 000'], + [-10000,'0,0.0','-10 000,0'], + [10000.1234,'0.000','10000,123'], + [-10000,'(0,0.0000)','(10 000,0000)'], + [-0.23,'.00','-,23'], + [-0.23,'(.00)','(,23)'], + [0.23,'0.00000','0,23000'], + [1230974,'0.0a','1,2m'], + [1460,'0a','1k'], + [-104000,'0a','-104k'], + [1,'0o','1.'], + [52,'0o','52.'], + [23,'0o','23.'], + [100,'0o','100.'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'$0,0.00','€1 000,23'], + [-1000.234,'($0,0)','(€1 000)'], + [-1000.234,'$0.00','-€1000,23'], + [1230974,'($0.00a)','€1,23m'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97,488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43,000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10 000,123',10000.123], + ['(0,12345)',-0.12345], + ['(€1,23m)',-1230000], + ['10k',10000], + ['-10k',-10000], + ['23.',23], + ['€10 000,00',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/en-au.js b/tests/locales/en-au.js new file mode 100644 index 00000000..97d6a094 --- /dev/null +++ b/tests/locales/en-au.js @@ -0,0 +1,94 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: en-au', function() { + + before(function() { + numeral.locale('en-au'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10,000.0000'], + [10000.23,'0,0','10,000'], + [-10000,'0,0.0','-10,000.0'], + [10000.1234,'0.000','10000.123'], + [-10000,'(0,0.0000)','(10,000.0000)'], + [-0.23,'.00','-.23'], + [-0.23,'(.00)','(.23)'], + [0.23,'0.00000','0.23000'], + [1230974,'0.0a','1.2m'], + [1460,'0a','1k'], + [-104000,'0a','-104k'], + [1,'0o','1st'], + [52,'0o','52nd'], + [23,'0o','23rd'], + [100,'0o','100th'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'$0,0.00','$1,000.23'], + [-1000.234,'($0,0)','($1,000)'], + [-1000.234,'$0.00','-$1000.23'], + [1230974,'($0.00a)','$1.23m'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97.488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43.000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10,000.123',10000.123], + ['(0.12345)',-0.12345], + ['($1.23m)',-1230000], + ['10k',10000], + ['-10k',-10000], + ['23rd',23], + ['$10,000.00',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/en-gb.js b/tests/locales/en-gb.js new file mode 100644 index 00000000..8c35e743 --- /dev/null +++ b/tests/locales/en-gb.js @@ -0,0 +1,94 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: en-gb', function() { + + before(function() { + numeral.locale('en-gb'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10,000.0000'], + [10000.23,'0,0','10,000'], + [-10000,'0,0.0','-10,000.0'], + [10000.1234,'0.000','10000.123'], + [-10000,'(0,0.0000)','(10,000.0000)'], + [-0.23,'.00','-.23'], + [-0.23,'(.00)','(.23)'], + [0.23,'0.00000','0.23000'], + [1230974,'0.0a','1.2m'], + [1460,'0a','1k'], + [-104000,'0a','-104k'], + [1,'0o','1st'], + [52,'0o','52nd'], + [23,'0o','23rd'], + [100,'0o','100th'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'$0,0.00','£1,000.23'], + [-1000.234,'($0,0)','(£1,000)'], + [-1000.234,'$0.00','-£1000.23'], + [1230974,'($0.00a)','£1.23m'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97.488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43.000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10,000.123',10000.123], + ['(0.12345)',-0.12345], + ['(£1.23m)',-1230000], + ['10k',10000], + ['-10k',-10000], + ['23rd',23], + ['£10,000.00',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/en-za.js b/tests/locales/en-za.js new file mode 100644 index 00000000..ed6cdc10 --- /dev/null +++ b/tests/locales/en-za.js @@ -0,0 +1,94 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: en-za', function() { + + before(function() { + numeral.locale('en-za'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10 000,0000'], + [10000.23,'0,0','10 000'], + [-10000,'0,0.0','-10 000,0'], + [10000.1234,'0.000','10000,123'], + [-10000,'(0,0.0000)','(10 000,0000)'], + [-0.23,'.00','-,23'], + [-0.23,'(.00)','(,23)'], + [0.23,'0.00000','0,23000'], + [1230974,'0.0a','1,2m'], + [1460,'0a','1k'], + [-104000,'0a','-104k'], + [1,'0o','1st'], + [52,'0o','52nd'], + [23,'0o','23rd'], + [100,'0o','100th'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'$0,0.00','R1 000,23'], + [-1000.234,'($0,0)','(R1 000)'], + [-1000.234,'$0.00','-R1000,23'], + [1230974,'($0.00a)','R1,23m'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97,488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43,000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10 000,123',10000.123], + ['(0,12345)',-0.12345], + ['(R1,23m)',-1230000], + ['10k',10000], + ['-10k',-10000], + ['23rd',23], + ['R10 000,00',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/es-es.js b/tests/locales/es-es.js new file mode 100644 index 00000000..a2830809 --- /dev/null +++ b/tests/locales/es-es.js @@ -0,0 +1,94 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: es-es', function() { + + before(function() { + numeral.locale('es-es'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10.000,0000'], + [10000.23,'0,0','10.000'], + [-10000,'0,0.0','-10.000,0'], + [10000.1234,'0.000','10000,123'], + [-10000,'(0,0.0000)','(10.000,0000)'], + [-0.23,'.00','-,23'], + [-0.23,'(.00)','(,23)'], + [0.23,'0.00000','0,23000'], + [1230974,'0.0a','1,2mm'], + [1460,'0a','1k'], + [-104000,'0a','-104k'], + [1,'0o','1er'], + [52,'0o','52do'], + [23,'0o','23er'], + [100,'0o','100mo'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'$0,0.00','€1.000,23'], + [-1000.234,'($0,0)','(€1.000)'], + [-1000.234,'$0.00','-€1000,23'], + [1230974,'($0.00a)','€1,23mm'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97,488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43,000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10.000,123',10000.123], + ['(0,12345)',-0.12345], + ['($1,23mm)',-1230000], + ['10k',10000], + ['-10k',-10000], + ['23er',23], + ['$10.000,00',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/es.js b/tests/locales/es.js new file mode 100644 index 00000000..7cc7704d --- /dev/null +++ b/tests/locales/es.js @@ -0,0 +1,94 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: es', function() { + + before(function() { + numeral.locale('es'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10.000,0000'], + [10000.23,'0,0','10.000'], + [-10000,'0,0.0','-10.000,0'], + [10000.1234,'0.000','10000,123'], + [-10000,'(0,0.0000)','(10.000,0000)'], + [-0.23,'.00','-,23'], + [-0.23,'(.00)','(,23)'], + [0.23,'0.00000','0,23000'], + [1230974,'0.0a','1,2mm'], + [1460,'0a','1k'], + [-104000,'0a','-104k'], + [1,'0o','1er'], + [52,'0o','52do'], + [23,'0o','23er'], + [100,'0o','100mo'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'$0,0.00','$1.000,23'], + [-1000.234,'($0,0)','($1.000)'], + [-1000.234,'$0.00','-$1000,23'], + [1230974,'($0.00a)','$1,23mm'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97,488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43,000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10.000,123',10000.123], + ['(0,12345)',-0.12345], + ['($1,23mm)',-1230000], + ['10k',10000], + ['-10k',-10000], + ['23er',23], + ['$10.000,00',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/et.js b/tests/locales/et.js new file mode 100644 index 00000000..87437737 --- /dev/null +++ b/tests/locales/et.js @@ -0,0 +1,94 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: et', function() { + + before(function() { + numeral.locale('et'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10 000,0000'], + [10000.23,'0,0','10 000'], + [-10000,'0,0.0','-10 000,0'], + [10000.1234,'0.000','10000,123'], + [-10000,'(0,0.0000)','(10 000,0000)'], + [-0.23,'.00','-,23'], + [-0.23,'(.00)','(,23)'], + [0.23,'0.00000','0,23000'], + [1230974,'0.0a','1,2 mln'], + [1460,'0a','1 tuh'], + [-104000,'0a','-104 tuh'], + [1,'0o','1.'], + [52,'0o','52.'], + [23,'0o','23.'], + [100,'0o','100.'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'$0,0.00','€1 000,23'], + [-1000.234,'($0,0)','(€1 000)'], + [-1000.234,'$0.00','-€1000,23'], + [1230974,'($0.00a)','€1,23 mln'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97,488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43,000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10.000,123',10000.123], + ['(0,12345)',-0.12345], + ['(€1,23 mln)',-1230000], + ['10 tuh',10000], + ['-10 tuh',-10000], + ['23.',23], + ['€10.000,00',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/fi.js b/tests/locales/fi.js new file mode 100644 index 00000000..711238e6 --- /dev/null +++ b/tests/locales/fi.js @@ -0,0 +1,94 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: fi', function() { + + before(function() { + numeral.locale('fi'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10 000,0000'], + [10000.23,'0,0','10 000'], + [-10000,'0,0.0','-10 000,0'], + [10000.1234,'0.000','10000,123'], + [-10000,'(0,0.0000)','(10 000,0000)'], + [-0.23,'.00','-,23'], + [-0.23,'(.00)','(,23)'], + [0.23,'0.00000','0,23000'], + [1230974,'0.0a','1,2M'], + [1460,'0a','1k'], + [-104000,'0a','-104k'], + [1,'0o','1.'], + [52,'0o','52.'], + [23,'0o','23.'], + [100,'0o','100.'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'$0,0.00','€1 000,23'], + [-1000.234,'($0,0)','(€1 000)'], + [-1000.234,'$0.00','-€1000,23'], + [1230974,'($0.00a)','€1,23M'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97,488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43,000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10.000,123',10000.123], + ['(0,12345)',-0.12345], + ['(€1,23M)',-1230000], + ['10k',10000], + ['-10k',-10000], + ['23.',23], + ['€10.000,00',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/fr-ca.js b/tests/locales/fr-ca.js new file mode 100644 index 00000000..1b386566 --- /dev/null +++ b/tests/locales/fr-ca.js @@ -0,0 +1,94 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: fr-ca', function() { + + before(function() { + numeral.locale('fr-ca'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10 000,0000'], + [10000.23,'0,0','10 000'], + [-10000,'0,0.0','-10 000,0'], + [10000.1234,'0.000','10000,123'], + [-10000,'(0,0.0000)','(10 000,0000)'], + [-0.23,'.00','-,23'], + [-0.23,'(.00)','(,23)'], + [0.23,'0.00000','0,23000'], + [1230974,'0.0 a','1,2 M'], + [1460,'0 a','1 k'], + [-104000,'0 a','-104 k'], + [1,'0o','1er'], + [52,'0o','52e'], + [23,'0o','23e'], + [100,'0o','100e'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'0,0.00 $','1 000,23 $'], + [-1000.234,'(0,0 $)','(1 000 $)'], + [-1000.234,'0.00 $','-1000,23 $'], + [1230974,'(0.00 a$)','1,23 M$'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0 %','100 %'], + [0.974878234,'0.000 %','97,488 %'], + [-0.43,'0 %','-43 %'], + [0.43,'(0.000 %)','43,000 %'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10 000,123',10000.123], + ['(0,12345)',-0.12345], + ['(1,23 M$)',-1230000], + ['10 k',10000], + ['-10 k',-10000], + ['23e',23], + ['10 000,00 $',10000], + ['-76 %',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/fr-ch.js b/tests/locales/fr-ch.js new file mode 100644 index 00000000..ddb17b65 --- /dev/null +++ b/tests/locales/fr-ch.js @@ -0,0 +1,94 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: fr-ch', function() { + + before(function() { + numeral.locale('fr-ch'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10\'000.0000'], + [10000.23,'0,0','10\'000'], + [-10000,'0,0.0','-10\'000.0'], + [10000.1234,'0.000','10000.123'], + [-10000,'(0,0.0000)','(10\'000.0000)'], + [-0.23,'.00','-.23'], + [-0.23,'(.00)','(.23)'], + [0.23,'0.00000','0.23000'], + [1230974,'0.0a','1.2m'], + [1460,'0a','1k'], + [-104000,'0a','-104k'], + [1,'0o','1er'], + [52,'0o','52e'], + [23,'0o','23e'], + [100,'0o','100e'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'$0,0.00','CHF1\'000.23'], + [-1000.234,'($0,0)','(CHF1\'000)'], + [-1000.234,'$0.00','-CHF1000.23'], + [1230974,'($0.00a)','CHF1.23m'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97.488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43.000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10\'000.123',10000.123], + ['(0.12345)',-0.12345], + ['(CHF1.23m)',-1230000], + ['10k',10000], + ['-10k',-10000], + ['23e',23], + ['CHF10\'000.00',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/fr.js b/tests/locales/fr.js new file mode 100644 index 00000000..515e5100 --- /dev/null +++ b/tests/locales/fr.js @@ -0,0 +1,94 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: fr', function() { + + before(function() { + numeral.locale('fr'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10 000,0000'], + [10000.23,'0,0','10 000'], + [-10000,'0,0.0','-10 000,0'], + [10000.1234,'0.000','10000,123'], + [-10000,'(0,0.0000)','(10 000,0000)'], + [-0.23,'.00','-,23'], + [-0.23,'(.00)','(,23)'], + [0.23,'0.00000','0,23000'], + [1230974,'0.0a','1,2m'], + [1460,'0a','1k'], + [-104000,'0a','-104k'], + [1,'0o','1er'], + [52,'0o','52e'], + [23,'0o','23e'], + [100,'0o','100e'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'$0,0.00','€1 000,23'], + [-1000.234,'($0,0)','(€1 000)'], + [-1000.234,'$0.00','-€1000,23'], + [1230974,'($0.00a)','€1,23m'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97,488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43,000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10 000,123',10000.123], + ['(0,12345)',-0.12345], + ['(€1,23m)',-1230000], + ['10k',10000], + ['-10k',-10000], + ['23e',23], + ['€10 000,00',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/hu.js b/tests/locales/hu.js new file mode 100644 index 00000000..b86d8598 --- /dev/null +++ b/tests/locales/hu.js @@ -0,0 +1,94 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: hu', function() { + + before(function() { + numeral.locale('hu'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10 000,0000'], + [10000.23,'0,0','10 000'], + [-10000,'0,0.0','-10 000,0'], + [10000.1234,'0.000','10000,123'], + [-10000,'(0,0.0000)','(10 000,0000)'], + [-0.23,'.00','-,23'], + [-0.23,'(.00)','(,23)'], + [0.23,'0.00000','0,23000'], + [1230974,'0.0a','1,2M'], + [1460,'0a','1E'], + [-104000,'0a','-104E'], + [1,'0o','1.'], + [52,'0o','52.'], + [23,'0o','23.'], + [100,'0o','100.'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'0,0.00$','1 000,23 Ft'], + [-1000.234,'(0,0$)','(1 000 Ft)'], + [-1000.234,'0.00$','-1000,23 Ft'], + [1230974,'(0.00a$)','1,23M Ft'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97,488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43,000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10 000,123',10000.123], + ['(0,12345)',-0.12345], + ['(1,23M Ft)',-1230000], + ['10E',10000], + ['-10E',-10000], + ['23.',23], + ['10 000,00 Ft',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/it.js b/tests/locales/it.js new file mode 100644 index 00000000..af51fc14 --- /dev/null +++ b/tests/locales/it.js @@ -0,0 +1,94 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: it', function() { + + before(function() { + numeral.locale('it'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10.000,0000'], + [10000.23,'0,0','10.000'], + [-10000,'0,0.0','-10.000,0'], + [10000.1234,'0.000','10000,123'], + [-10000,'(0,0.0000)','(10.000,0000)'], + [-0.23,'.00','-,23'], + [-0.23,'(.00)','(,23)'], + [0.23,'0.00000','0,23000'], + [1230974,'0.0a','1,2mil'], + [1460,'0a','1mila'], + [-104000,'0a','-104mila'], + [1,'0o','1º'], + [52,'0o','52º'], + [23,'0o','23º'], + [100,'0o','100º'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'$0,0.00','€1.000,23'], + [-1000.234,'($0,0)','(€1.000)'], + [-1000.234,'$0.00','-€1000,23'], + [1230974,'($0.00a)','€1,23mil'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97,488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43,000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10.000,123',10000.123], + ['(0,12345)',-0.12345], + ['(€1,23mil)',-1230000], + ['10mila',10000], + ['-10mila',-10000], + ['23º',23], + ['€10.000,00',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/ja.js b/tests/locales/ja.js new file mode 100644 index 00000000..762484b6 --- /dev/null +++ b/tests/locales/ja.js @@ -0,0 +1,94 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: ja', function() { + + before(function() { + numeral.locale('ja'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10,000.0000'], + [10000.23,'0,0','10,000'], + [-10000,'0,0.0','-10,000.0'], + [10000.1234,'0.000','10000.123'], + [-10000,'(0,0.0000)','(10,000.0000)'], + [-0.23,'.00','-.23'], + [-0.23,'(.00)','(.23)'], + [0.23,'0.00000','0.23000'], + [1230974,'0.0a','1.2百万'], + [1460,'0a','1千'], + [-104000,'0a','-104千'], + [1,'0o','1.'], + [52,'0o','52.'], + [23,'0o','23.'], + [100,'0o','100.'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'$0,0.00','¥1,000.23'], + [-1000.234,'($0,0)','(¥1,000)'], + [-1000.234,'$0.00','-¥1000.23'], + [1230974,'($0.00a)','¥1.23百万'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97.488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43.000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10,000.123',10000.123], + ['(0.12345)',-0.12345], + ['(¥1.23百万)',-1230000], + ['10千',10000], + ['-10千',-10000], + ['23.',23], + ['¥10,000.00',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/lv.js b/tests/locales/lv.js new file mode 100644 index 00000000..227fc5c0 --- /dev/null +++ b/tests/locales/lv.js @@ -0,0 +1,94 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: lv', function() { + + before(function() { + numeral.locale('lv'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10 000,0000'], + [10000.23,'0,0','10 000'], + [-10000,'0,0.0','-10 000,0'], + [10000.1234,'0.000','10000,123'], + [-10000,'(0,0.0000)','(10 000,0000)'], + [-0.23,'.00','-,23'], + [-0.23,'(.00)','(,23)'], + [0.23,'0.00000','0,23000'], + [1230974,'0.0a','1,2 milj.'], + [1460,'0a','1 tūkst.'], + [-104000,'0a','-104 tūkst.'], + [1,'0o','1.'], + [52,'0o','52.'], + [23,'0o','23.'], + [100,'0o','100.'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'$0,0.00','€1 000,23'], + [-1000.234,'($0,0)','(€1 000)'], + [-1000.234,'$0.00','-€1000,23'], + [1230974,'($0.00a)','€1,23 milj.'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97,488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43,000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10 000,123',10000.123], + ['(0,12345)',-0.12345], + ['(€1,23 milj.)',-1230000], + ['10 tūkst.',10000], + ['-10 tūkst.',-10000], + ['23.',23], + ['€10 000,00',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/nl-be.js b/tests/locales/nl-be.js new file mode 100644 index 00000000..d7adc329 --- /dev/null +++ b/tests/locales/nl-be.js @@ -0,0 +1,100 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: nl-be', function() { + + before(function() { + numeral.locale('nl-be'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10 000,0000'], + [10000.23,'0,0','10 000'], + [-10000,'0,0.0','-10 000,0'], + [10000.1234,'0.000','10000,123'], + [-10000,'(0,0.0000)','(10 000,0000)'], + [-0.23,'.00','-,23'], + [-0.23,'(.00)','(,23)'], + [0.23,'0.00000','0,23000'], + [1230974,'0.0a','1,2 mln'], + [1460,'0a','1k'], + [-104000,'0a','-104k'], + [0,'0o','0de'], + [1,'0o','1ste'], + [2,'0o','2de'], + [8,'0o','8ste'], + [19,'0o','19de'], + [20,'0o','20ste'], + [100,'0o','100ste'], + [102,'0o','102de'], + [108,'0o','108ste'], + [109,'0o','109de'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'$0,0.00','€ 1 000,23'], + [-1000.234,'($0,0)','(€ 1 000)'], + [-1000.234,'$0.00','-€ 1000,23'], + [1230974,'($0.00a)','€ 1,23 mln'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97,488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43,000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10 000,123',10000.123], + ['(0,12345)',-0.12345], + ['(€ 1,23 mln)',-1230000], + ['10k',10000], + ['-10k',-10000], + ['23e',23], + ['€ 10 000,00',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/nl-nl.js b/tests/locales/nl-nl.js new file mode 100644 index 00000000..be59b4c4 --- /dev/null +++ b/tests/locales/nl-nl.js @@ -0,0 +1,102 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: nl-nl', function() { + + before(function() { + numeral.locale('nl-nl'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10.000,0000'], + [10000.23,'0,0','10.000'], + [-10000,'0,0.0','-10.000,0'], + [10000.1234,'0.000','10000,123'], + [-10000,'(0,0.0000)','(10.000,0000)'], + [-0.23,'.00','-,23'], + [-0.23,'(.00)','(,23)'], + [0.23,'0.00000','0,23000'], + [1230974,'0.0a','1,2mln'], + [1430974124,'0.0a','1,4mrd'], + [9123456789234,'0.0a','9,1bln'], + [1460,'0a','1k'], + [-104000,'0a','-104k'], + [0,'0o','0de'], + [1,'0o','1ste'], + [2,'0o','2de'], + [8,'0o','8ste'], + [19,'0o','19de'], + [20,'0o','20ste'], + [100,'0o','100ste'], + [102,'0o','102de'], + [108,'0o','108ste'], + [109,'0o','109de'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'$0,0.00','€ 1.000,23'], + [-1000.234,'($0,0)','(€ 1.000)'], + [-1000.234,'$0.00','-€ 1000,23'], + [1230974,'($0.00a)','€ 1,23mln'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97,488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43,000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10.000,123',10000.123], + ['(0,12345)',-0.12345], + ['(€ 1,23 mln)',-1230000], + ['10k',10000], + ['-10k',-10000], + ['23e',23], + ['€ 10.000,00',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/no.js b/tests/locales/no.js new file mode 100644 index 00000000..e5be2afd --- /dev/null +++ b/tests/locales/no.js @@ -0,0 +1,95 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: no', function() { + + before(function() { + numeral.locale('no'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10 000,0000'], + [10000.23,'0,0','10 000'], + [-10000,'0,0.0','-10 000,0'], + [10000.1234,'0.000','10000,123'], + [-10000,'(0,0.0000)','(10 000,0000)'], + [-0.23,'.00','-,23'], + [-0.23,'(.00)','(,23)'], + [0.23,'0.00000','0,23000'], + [1230974,'0.0a','1,2m'], + [1460,'0a','1k'], + [-104000,'0a','-104k'], + [1,'0o','1.'], + [52,'0o','52.'], + [23,'0o','23.'], + [100,'0o','100.'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'$0,0.00','kr1 000,23'], + [-1000.234,'($0,0)','(kr1 000)'], + [-1000.234,'$0.00','-kr1000,23'], + [1230974,'($0.00a)','kr1,23m'], + [521.67,'0,0[.]00 $','521,67 kr'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97,488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43,000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10 000,123',10000.123], + ['(0,12345)',-0.12345], + ['(kr1,23m)',-1230000], + ['10k',10000], + ['-10k',-10000], + ['23.',23], + ['kr10 000,00',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/pl.js b/tests/locales/pl.js new file mode 100644 index 00000000..c8056681 --- /dev/null +++ b/tests/locales/pl.js @@ -0,0 +1,95 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: pl', function() { + + before(function() { + numeral.locale('pl'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10 000,0000'], + [10000.23,'0,0','10 000'], + [-10000,'0,0.0','-10 000,0'], + [10000.1234,'0.000','10000,123'], + [-10000,'(0,0.0000)','(10 000,0000)'], + [-0.23,'.00','-,23'], + [-0.23,'(.00)','(,23)'], + [0.23,'0.00000','0,23000'], + [1230974,'0.0a','1,2mln'], + [1460,'0a','1tys.'], + [-104000,'0a','-104tys.'], + [1,'0o','1.'], + [52,'0o','52.'], + [23,'0o','23.'], + [100,'0o','100.'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'0,0.00$','1 000,23PLN'], + [-1000.234,'(0,0$)','(1 000PLN)'], + [-1000.234,'0.00$','-1000,23PLN'], + [1230974,'(0.00a$)','1,23mlnPLN'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97,488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43,000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10 000,123',10000.123], + ['(0,12345)',-0.12345], + ['(1,23mlnPLN)',-1230000], + ['1,23mlnPLN',1230000], + ['10tys.',10000], + ['-10tys.',-10000], + ['23.',23], + ['10 000,00PLN',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/pt-br.js b/tests/locales/pt-br.js new file mode 100644 index 00000000..87915554 --- /dev/null +++ b/tests/locales/pt-br.js @@ -0,0 +1,94 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: pt-br', function() { + + before(function() { + numeral.locale('pt-br'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10.000,0000'], + [10000.23,'0,0','10.000'], + [-10000,'0,0.0','-10.000,0'], + [10000.1234,'0.000','10000,123'], + [-10000,'(0,0.0000)','(10.000,0000)'], + [-0.23,'.00','-,23'], + [-0.23,'(.00)','(,23)'], + [0.23,'0.00000','0,23000'], + [1230974,'0.0a','1,2milhões'], + [1460,'0a','1mil'], + [-104000,'0a','-104mil'], + [1,'0o','1º'], + [52,'0o','52º'], + [23,'0o','23º'], + [100,'0o','100º'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'$0,0.00','R$1.000,23'], + [-1000.234,'($0,0)','(R$1.000)'], + [-1000.234,'$0.00','-R$1000,23'], + [1230974,'($0.00a)','R$1,23milhões'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97,488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43,000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10.000,123',10000.123], + ['(0,12345)',-0.12345], + ['(R$1,23milhões)',-1230000], + ['10mil',10000], + ['-10mil',-10000], + ['23º',23], + ['R$10.000,00',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/pt-pt.js b/tests/locales/pt-pt.js new file mode 100644 index 00000000..54073397 --- /dev/null +++ b/tests/locales/pt-pt.js @@ -0,0 +1,94 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: pt-pt', function() { + + before(function() { + numeral.locale('pt-pt'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10 000,0000'], + [10000.23,'0,0','10 000'], + [-10000,'0,0.0','-10 000,0'], + [10000.1234,'0.000','10000,123'], + [-10000,'(0,0.0000)','(10 000,0000)'], + [-0.23,'.00','-,23'], + [-0.23,'(.00)','(,23)'], + [0.23,'0.00000','0,23000'], + [1230974,'0.0a','1,2m'], + [1460,'0a','1k'], + [-104000,'0a','-104k'], + [1,'0o','1º'], + [52,'0o','52º'], + [23,'0o','23º'], + [100,'0o','100º'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'$0,0.00','€1 000,23'], + [-1000.234,'($0,0)','(€1 000)'], + [-1000.234,'$0.00','-€1000,23'], + [1230974,'($0.00a)','€1,23m'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97,488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43,000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10 000,123',10000.123], + ['(0,12345)',-0.12345], + ['(€1,23m)',-1230000], + ['10k',10000], + ['-10k',-10000], + ['23º',23], + ['€10 000,00',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/ru-ua.js b/tests/locales/ru-ua.js new file mode 100644 index 00000000..aa65fcb9 --- /dev/null +++ b/tests/locales/ru-ua.js @@ -0,0 +1,95 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: ru-ua', function() { + + before(function() { + numeral.locale('ru-ua'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10 000,0000'], + [10000.23,'0,0','10 000'], + [-10000,'0,0.0','-10 000,0'], + [10000.1234,'0.000','10000,123'], + [-10000,'(0,0.0000)','(10 000,0000)'], + [-0.23,'.00','-,23'], + [-0.23,'(.00)','(,23)'], + [0.23,'0.00000','0,23000'], + [1230974,'0.0a','1,2млн'], + [1460,'0a','1тыс.'], + [-104000,'0a','-104тыс.'], + [1,'0o','1.'], + [52,'0o','52.'], + [23,'0o','23.'], + [100,'0o','100.'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'0,0.00$','1 000,23₴'], + [-1000.234,'(0,0$)','(1 000₴)'], + [-1000.234,'0.00$','-1000,23₴'], + [1230974,'(0.00a$)','1,23млн₴'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97,488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43,000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10 000,123',10000.123], + ['(0,12345)',-0.12345], + ['(1,23млн₴)',-1230000], + ['1,23млн₴',1230000], + ['10тыс.',10000], + ['-10тыс.',-10000], + ['23.',23], + ['10 000,00₴',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/ru.js b/tests/locales/ru.js new file mode 100644 index 00000000..47e2153a --- /dev/null +++ b/tests/locales/ru.js @@ -0,0 +1,95 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: ru', function() { + + before(function() { + numeral.locale('ru'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10 000,0000'], + [10000.23,'0,0','10 000'], + [-10000,'0,0.0','-10 000,0'], + [10000.1234,'0.000','10000,123'], + [-10000,'(0,0.0000)','(10 000,0000)'], + [-0.23,'.00','-,23'], + [-0.23,'(.00)','(,23)'], + [0.23,'0.00000','0,23000'], + [1230974,'0.0a','1,2млн.'], + [1460,'0a','1тыс.'], + [-104000,'0a','-104тыс.'], + [1,'0o','1.'], + [52,'0o','52.'], + [23,'0o','23.'], + [100,'0o','100.'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'0,0.00$','1 000,23руб.'], + [-1000.234,'(0,0$)','(1 000руб.)'], + [-1000.234,'0.00$','-1000,23руб.'], + [1230974,'(0.00a$)','1,23млн.руб.'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97,488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43,000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10 000,123',10000.123], + ['(0,12345)',-0.12345], + ['(1,23млн.руб.)',-1230000], + ['1,23млн.руб.',1230000], + ['10тыс.',10000], + ['-10тыс.',-10000], + ['23.',23], + ['10 000,00руб.',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/sk.js b/tests/locales/sk.js new file mode 100644 index 00000000..8db57e42 --- /dev/null +++ b/tests/locales/sk.js @@ -0,0 +1,94 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: sk', function() { + + before(function() { + numeral.locale('sk'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10 000,0000'], + [10000.23,'0,0','10 000'], + [-10000,'0,0.0','-10 000,0'], + [10000.1234,'0.000','10000,123'], + [-10000,'(0,0.0000)','(10 000,0000)'], + [-0.23,'.00','-,23'], + [-0.23,'(.00)','(,23)'], + [0.23,'0.00000','0,23000'], + [1230974,'0.0a','1,2mil.'], + [1460,'0a','1tis.'], + [-104000,'0a','-104tis.'], + [1,'0o','1.'], + [52,'0o','52.'], + [23,'0o','23.'], + [100,'0o','100.'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'$0,0.00','€1 000,23'], + [-1000.234,'($0,0)','(€1 000)'], + [-1000.234,'$0.00','-€1000,23'], + [1230974,'($0.00a)','€1,23mil.'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97,488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43,000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10 000,123',10000.123], + ['(0,12345)',-0.12345], + ['(€1,23mil.)',-1230000], + ['10tis.',10000], + ['-10tis.',-10000], + ['23e',23], + ['€10 000,00',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/sl.js b/tests/locales/sl.js new file mode 100644 index 00000000..5dfb9693 --- /dev/null +++ b/tests/locales/sl.js @@ -0,0 +1,94 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: sl', function() { + + before(function() { + numeral.locale('sl'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10.000,0000'], + [10000.23,'0,0','10.000'], + [-10000,'0,0.0','-10.000,0'], + [10000.1234,'0.000','10000,123'], + [-10000,'(0,0.0000)','(10.000,0000)'], + [-0.23,'.00','-,23'], + [-0.23,'(.00)','(,23)'], + [0.23,'0.00000','0,23000'], + [1230974,'0.0a','1,2mio'], + [1460,'0a','1k'], + [-104000,'0a','-104k'], + [1,'0o','1.'], + [52,'0o','52.'], + [23,'0o','23.'], + [100,'0o','100.'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'$0,0.00','€1.000,23'], + [-1000.234,'($0,0)','(€1.000)'], + [-1000.234,'$0.00','-€1000,23'], + [1230974,'($0.00a)','€1,23mio'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97,488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43,000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10.000,123',10000.123], + ['(0,12345)',-0.12345], + ['(€1,23mio)',-1230000], + ['10k',10000], + ['-10k',-10000], + ['23e',23], + ['€10.000,00',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/th.js b/tests/locales/th.js new file mode 100644 index 00000000..7743066b --- /dev/null +++ b/tests/locales/th.js @@ -0,0 +1,94 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: th', function() { + + before(function() { + numeral.locale('th'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10,000.0000'], + [10000.23,'0,0','10,000'], + [-10000,'0,0.0','-10,000.0'], + [10000.1234,'0.000','10000.123'], + [-10000,'(0,0.0000)','(10,000.0000)'], + [-0.23,'.00','-.23'], + [-0.23,'(.00)','(.23)'], + [0.23,'0.00000','0.23000'], + [1230974,'0.0a','1.2ล้าน'], + [1460,'0a','1พัน'], + [-104000,'0a','-104พัน'], + [1,'0o','1.'], + [52,'0o','52.'], + [23,'0o','23.'], + [100,'0o','100.'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'$0,0.00','฿1,000.23'], + [-1000.234,'($0,0)','(฿1,000)'], + [-1000.234,'$0.00','-฿1000.23'], + [1230974,'($0.00a)','฿1.23ล้าน'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97.488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43.000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10,000.123',10000.123], + ['(0.12345)',-0.12345], + ['(฿1.23ล้าน)',-1230000], + ['10พัน',10000], + ['-10พัน',-10000], + ['23.',23], + ['฿10,000.00',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/tr.js b/tests/locales/tr.js new file mode 100644 index 00000000..f1996754 --- /dev/null +++ b/tests/locales/tr.js @@ -0,0 +1,94 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: tr', function() { + + before(function() { + numeral.locale('tr'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10.000,0000'], + [10000.23,'0,0','10.000'], + [-10000,'0,0.0','-10.000,0'], + [10000.1234,'0.000','10000,123'], + [-10000,'(0,0.0000)','(10.000,0000)'], + [-0.23,'.00','-,23'], + [-0.23,'(.00)','(,23)'], + [0.23,'0.00000','0,23000'], + [1230974,'0.0a','1,2milyon'], + [1460,'0a','1bin'], + [-104000,'0a','-104bin'], + [1,'0o','1\'inci'], + [52,'0o','52\'nci'], + [23,'0o','23\'üncü'], + [100,'0o','100\'üncü'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'$0,0.00','\u20BA1.000,23'], + [-1000.234,'($0,0)','(\u20BA1.000)'], + [-1000.234,'$0.00','-\u20BA1000,23'], + [1230974,'($0.00a)','\u20BA1,23milyon'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97,488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43,000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10.000,123',10000.123], + ['(0,12345)',-0.12345], + ['(\u20BA1,23milyon)',-1230000], + ['10bin',10000], + ['-10bin',-10000], + ['23üncü',23], + ['\u20BA10.000,00',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/uk-ua.js b/tests/locales/uk-ua.js new file mode 100644 index 00000000..9155f81a --- /dev/null +++ b/tests/locales/uk-ua.js @@ -0,0 +1,95 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: uk-ua', function() { + + before(function() { + numeral.locale('uk-ua'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10 000,0000'], + [10000.23,'0,0','10 000'], + [-10000,'0,0.0','-10 000,0'], + [10000.1234,'0.000','10000,123'], + [-10000,'(0,0.0000)','(10 000,0000)'], + [-0.23,'.00','-,23'], + [-0.23,'(.00)','(,23)'], + [0.23,'0.00000','0,23000'], + [1230974,'0.0a','1,2млн'], + [1460,'0a','1тис.'], + [-104000,'0a','-104тис.'], + [1,'0o','1'], + [52,'0o','52'], + [23,'0o','23'], + [100,'0o','100'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'0,0.00$','1 000,23₴'], + [-1000.234,'(0,0$)','(1 000₴)'], + [-1000.234,'0.00$','-1000,23₴'], + [1230974,'(0.00a$)','1,23млн₴'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97,488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43,000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10 000,123',10000.123], + ['(0,12345)',-0.12345], + ['(1,23млн₴)',-1230000], + ['1,23млн₴',1230000], + ['10тис.',10000], + ['-10тис.',-10000], + ['23.',23], + ['10 000,00₴',10000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/locales/vi.js b/tests/locales/vi.js new file mode 100644 index 00000000..50d69af6 --- /dev/null +++ b/tests/locales/vi.js @@ -0,0 +1,98 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var locales = require('../../locales'); + var expect = require('chai').expect; +} + +describe('Locale: vi', function() { + + before(function() { + numeral.locale('vi'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Number', function() { + it('should format a number', function() { + var tests = [ + [10000,'0,0.0000','10.000,0000'], + [10000.23,'0,0','10.000'], + [-10000,'0,0.0','-10.000,0'], + [10000.1234,'0.000','10000,123'], + [-10000,'(0,0.0000)','(10.000,0000)'], + [-0.23,'.00','-,23'], + [-0.23,'(.00)','(,23)'], + [0.23,'0.00000','0,23000'], + [1230974,'0.0a','1,2 triệu'], + [1460,'0a','1 nghìn'], + [-104000,'0a','-104 nghìn'], + [1,'0o','1.'], + [52,'0o','52.'], + [23,'0o','23.'], + [100,'0o','100.'], + [1,'0[.]0','1'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Currency', function() { + it('should format a currency', function() { + var tests = [ + [1000.234,'0,0.00 $','1.000,23 ₫'], + [-1000.234,'(0,0 $)','(1.000 ₫)'], + [-1000.234,'0.00 $','-1000,23 ₫'], + [1230974,'(0.00a $)','1,23 triệu ₫'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Percentages', function() { + it('should format a percentages', function() { + var tests = [ + [1,'0%','100%'], + [0.974878234,'0.000%','97,488%'], + [-0.43,'0%','-43%'], + [0.43,'(0.000%)','43,000%'] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Unformat', function() { + it('should unformat', function() { + var tests = [ + ['10.000,123',10000.123], + ['(0,12345)',-0.12345], + ['1 nghìn', 1000], + ['1 triệu',1000000], + ['1 tỷ', 1000000000], + ['1 nghìn tỷ', 1000000000000], + ['1,2 nghìn', 1200], + ['1,2 tỷ', 1200000000], + ['1.000.000', 1000000], + ['1.000.000,2', 1000000.2], + ['10.000.000', 10000000], + ['-76%',-0.76], + ['2:23:57',8637] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/numeral.js b/tests/numeral.js new file mode 100644 index 00000000..4c9208af --- /dev/null +++ b/tests/numeral.js @@ -0,0 +1,475 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../numeral'); + var expect = require('chai').expect; +} + +describe('Numeral', function() { + afterEach(function() { + numeral.reset(); + }); + + describe('Default', function() { + it('should set a default format', function() { + numeral.defaultFormat('0,0'); + + expect(numeral(10000).format()).to.equal('10,000'); + }); + }); + + describe('Types', function() { + it('should return a value as correct type', function() { + var tests = [ + [1234.56,'number'], + ['1234.56','number'], + [0,'number'], + [NaN,'object'], + [null,'object'] + ], + i; + + for (i = 0; i < tests.length; i++) { + expect(typeof numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); + + describe('Value', function() { + it('should return a value', function() { + var tests = [ + [1000, 1000], + [0.5, 0.5], + [null, null], + ['1,000', 1000], + ['not a number', null] + ], + num; + + for (var i = 0; i < tests.length; i++) { + num = numeral(tests[i][0]); + + expect(num.value()).to.equal(tests[i][1]); + } + }); + }); + + describe('Set', function() { + it('should set a value', function() { + var tests = [ + [1000,1000], + [-0.25,-0.25] + ], + num; + + for (var i = 0; i < tests.length; i++) { + num = numeral().set(tests[i][0]); + + expect(num.value()).to.equal(tests[i][1]); + } + }); + }); + + describe('Custom Zero', function() { + it('should change zero value', function() { + var tests = [ + [0,null,'0','0'], + [0,'N/A','0','N/A'], + [0,'','',''] + ]; + + for (var i = 0; i < tests.length; i++) { + numeral.zeroFormat(tests[i][1]); + + expect(numeral(tests[i][0]).format(tests[i][2])).to.equal(tests[i][3]); + } + }); + }); + + describe('Custom Null', function() { + it('should change null value', function() { + var tests = [ + [null,null,'0','0'], + [null,'N/A','0','N/A'], + [null,'','',''] + ]; + + for (var i = 0; i < tests.length; i++) { + numeral.nullFormat(tests[i][1]); + + expect(numeral(tests[i][0]).format(tests[i][2])).to.equal(tests[i][3]); + } + }); + }); + + describe('Clone', function() { + it('should clone', function() { + var a = numeral(1000), + b = numeral(a), + c = a.clone(), + aVal = a.value(), + aSet = a.set(2000).value(), + bVal = b.value(), + cVal = c.add(10).value(); + + expect(aVal).to.equal(1000); + expect(aSet).to.equal(2000); + expect(bVal).to.equal(1000); + expect(cVal).to.equal(1010); + }); + }); + + describe('isNumeral', function() { + it('should return boolean', function() { + var tests = [ + [numeral(),true], + [1,false] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral.isNumeral(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); + + describe('Format', function() { + it('should format to a number', function() { + var tests = [ + [0, null, '0'], + [0, '0.00', '0.00'], + [null, null, '0'], + [NaN, '0.0', '0.0'], + [1.23,'0,0','1'], + [10000,'0,0.0000','10,000.0000'], + [10000.23,'0,0','10,000'], + [-10000,'0,0.0','-10,000.0'], + [10000.1234,'0.000','10000.123'], + [10000,'0[.]00','10000'], + [10000.1,'0[.]00','10000.10'], + [10000.123,'0[.]00','10000.12'], + [10000.456,'0[.]00','10000.46'], + [10000.001,'0[.]00','10000'], + [10000.45,'0[.]00[0]','10000.45'], + [10000.456,'0[.]00[0]','10000.456'], + [10000,'(0,0.0000)','10,000.0000'], + [-10000,'(0,0.0000)','(10,000.0000)'], + [-12300,'+0,0.0000','-12,300.0000'], + [1230,'+0,0','+1,230'], + [1230,'-0,0','1,230'], + [-1230,'-0,0','-1,230'], + [-1230.4,'0,0.0+','1,230.4-'], + [-1230.4,'0,0.0-','1,230.4-'], + [1230.4,'0,0.0-','1,230.4'], + [100.78, '0', '101'], + [100.28, '0', '100'], + [1.932,'0.0','1.9'], + [1.9687,'0','2'], + [1.9687,'0.0','2.0'], + [-0.23,'.00','-.23'], + [-0.23,'(.00)','(.23)'], + [0.23,'0.00000','0.23000'], + [0.67,'0.0[0000]','0.67'], + [3162.63,'0.0[00000000000000]','3162.63'], + [1.99,'0.[0]','2'], + [1.0501,'0.00[0]','1.05'], + [1.005,'0.00','1.01'], + // leading zero + [0, '00.0', '00.0'], + [0.23, '000.[00]', '000.23'], + [4, '000', '004'], + [10, '00000', '00010'], + [1000, '000,0', '1,000'], + [1000, '00000,0', '01,000'], + [1000, '0000000,0', '0,001,000'], + // abbreviations + [2000000000,'0.0a','2.0b'], + [1230974,'0.0a','1.2m'], + [1460,'0a','1k'], + [-104000,'0 a','-104 k'], + [999950,'0.0a','1.0m'], + [999999999,'0a','1b'], + // forced abbreviations + [-5444333222111, '0,0 ak', '-5,444,333,222 k'], + [5444333222111, '0,0 am', '5,444,333 m'], + [-5444333222111, '0,0 ab', '-5,444 b'], + [-5444333222111, '0,0 at', '-5 t'], + [123456, '0.0[0] ak', '123.46 k'], + [150,'0.0 ak','0.2 k'] + ], + i, + n, + output; + + for (i = 0; i < tests.length; i++) { + n = numeral(tests[i][0]); + output = n.format(tests[i][1]); + + expect(output).to.equal(tests[i][2]); + + expect(typeof output).to.equal('string'); + } + }); + }); + + describe('Unformat', function() { + before(function() { + numeral.zeroFormat('N/A'); + numeral.nullFormat('N/A'); + }); + + after(function() { + numeral.reset(); + }); + + it('should unformat a number', function() { + var tests = [ + ['10,000.123', 10000.123], + ['(0.12345)', -0.12345], + ['((--0.12345))', 0.12345], + ['1.23t', 1230000000000], + ['N/A', 0], + ['', null], + // Pass Through for Numbers + [0, 0], + [1, 1], + [1.1, 1.1], + [-0, 0], + [-1, -1], + [-1.1, -1.1] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); + } + }); + }); + + describe('Validate', function() { + var locale = 'en'; + + describe('Numbers', function() { + it('should validate numbers', function() { + var tests = [ + ['1000', true], + ['1,000', true], + ['10,0,0', true], + ['10.123', true], + ['1,000.123', true], + ['1000,123.123', true], + ['1000 ', true], + [' 1000 ', true], + [' 1000', true], + [' 1000,100.123', true], + ['1.0,00', false], + ['1.0.00', false], + ['1 000', false], + ['1.000,123', false], + ['1000.', false], + ['1000,', false], + ['10..00', false], + ['10,,00', false], + ['10, 00', false] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral.validate(tests[i][0], locale)).to.equal(tests[i][1]); + } + }); + }); + + describe('Currency', function() { + it('should validate currency', function() { + var tests = [ + ['$1000', true], + ['$1,000', true], + ['$10,0,0', true], + ['$10.123', true], + ['$1,000.123', true], + ['$1000 ', true], + [' $1000 ', true], + [' $1000', true], + [' $1000,100.123', true], + ['$100.123k', true], + ['$100.123m', true], + ['$100.123b', true], + ['$100.123t', true], + ['100,456.123k', true], + [' 100,456.123t ', true], + ['$1,00.123k', true], + ['%100', false], + [' %1.0.00', false], + [' ^1 000 ', false], + ['^1.000 ', false], + ['$ 1000.', false], + ['%1000', false], + ['100,456.123z', false], + ['$100$', false], + ['$100,213.456l', false], + ['aa100,213.456l', false], + ['$100,213.456kk', false] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral.validate(tests[i][0], locale)).to.equal(tests[i][1]); + } + }); + }); + }); + + describe('Manipulate', function() { + + describe('Add', function() { + it('should add', function() { + var tests = [ + [1000,10,1010], + [0.5,3,3.5], + [-100,200,100], + [0.1,0.2,0.3], + [0.28,0.01,0.29], + [0.289999,0.000001,0.29], + [0.29,0.01,0.3] + ], + num; + + for (var i = 0; i < tests.length; i++) { + num = numeral(tests[i][0]); + + num.add(tests[i][1]); + + expect(num.value()).to.equal(tests[i][2]); + } + }); + }); + + describe('Subtract', function() { + it('should subtract', function() { + var tests = [ + [1000,10,990], + [0.5,3,-2.5], + [-100,200,-300], + [0.3,0.1,0.2], + [0.28,0.01,0.27], + [0.29,0.01,0.28] + ], + num; + + for (var i = 0; i < tests.length; i++) { + num = numeral(tests[i][0]); + + num.subtract(tests[i][1]); + + expect(num.value()).to.equal(tests[i][2]); + } + }); + }); + + + describe('Add', function() { + it('should add', function() { + }); + }); + + + describe('Multiply', function() { + it('should multiply', function() { + var tests = [ + [1000,10,10000], + [0.5,3,1.5], + [-100,200,-20000], + [0.1,0.2,0.02], + [0.28,0.01,0.0028], + [0.29,0.01,0.0029], + [0.00000231,10000000,23.1] + ], + num; + + for (var i = 0; i < tests.length; i++) { + num = numeral(tests[i][0]); + + num.multiply(tests[i][1]); + + expect(num.value()).to.equal(tests[i][2]); + } + }); + }); + + describe('Divide', function() { + it('should divide', function() { + var tests = [ + [1000,10,100], + [0.5,3,0.16666666666666666], + [-100,200,-0.5], + [5.3,0.1,53], + [0.28,0.01,28], + [0.29,0.01,29] + ], + num; + + for (var i = 0; i < tests.length; i++) { + num = numeral(tests[i][0]); + + num.divide(tests[i][1]); + + expect(num.value()).to.equal(tests[i][2]); + } + }); + }); + + describe('Difference', function() { + it('should find a difference', function() { + var tests = [ + [1000,10,990], + [0.5,3,2.5], + [-100,200,300], + [0.3,0.2,0.1], + [0.28,0.01,0.27], + [0.29,0.01,0.28] + ], + num; + + for (var i = 0; i < tests.length; i++) { + num = numeral(tests[i][0]); + + expect(num.difference(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Rounding', function() { + it('should format with rounding', function() { + var tests = [ + // value, format string, expected w/ floor, expected w/ ceil + [2280002, '0.00a', '2.28m', '2.29m'], + [10000.23,'0,0','10,000', '10,001'], + [1000.234,'0,0.00','1,000.23', '1,000.24'], + [0.97487823,'0.000','0.974','0.975'], + [-0.433,'0.0','-0.5', '-0.4'] + ], + i; + + for (i = 0; i < tests.length; i++) { + // floor + expect(numeral(tests[i][0]).format(tests[i][1], Math.floor)).to.equal(tests[i][2]); + + // ceil + expect(numeral(tests[i][0]).format(tests[i][1], Math.ceil)).to.equal(tests[i][3]); + } + }); + }); + }); + + describe('Utilities', function() { + describe('Insert', function() { + it('should insert into string', function() { + var tests = [ + ['1000', '+', 0, '+1000'], + ['1000', '-', 4, '1000-'] + ], + i; + + for (i = 0; i < tests.length; i++) { + expect(numeral._.insert(tests[i][0], tests[i][1], tests[i][2])).to.equal(tests[i][3]); + } + }); + }); + }); +}); diff --git a/tests/numeral/format.js b/tests/numeral/format.js deleted file mode 100644 index 53427ad4..00000000 --- a/tests/numeral/format.js +++ /dev/null @@ -1,204 +0,0 @@ -var numeral = require('../../numeral'); - -exports.format = { - default: function (test) { - test.expect(1); - - numeral.defaultFormat('0,0'); - - test.strictEqual(numeral(10000).format(), '10,000', '0.0'); - - test.done(); - }, - value: function (test) { - var tests = [ - '0,0.00', - '$0,0.00', - '0b', - '0,0%', - '00:00:00' - ], - value = 12345.6, - n = numeral(value), - format, - i; - - test.expect(test.length); - - for (i = 0; i < tests.length; i++) { - format = n.format(test[i]); - test.strictEqual(n.value(), value, 'value unchanged after format' + test[i]); - } - - test.done(); - }, - numbers: function (test) { - var tests = [ - [10000,'0,0.0000','10,000.0000'], - [10000.23,'0,0','10,000'], - [-10000,'0,0.0','-10,000.0'], - [10000.1234,'0.000','10000.123'], - [10000,'0[.]00','10000'], - [10000.1,'0[.]00','10000.10'], - [10000.123,'0[.]00','10000.12'], - [10000.456,'0[.]00','10000.46'], - [10000.001,'0[.]00','10000'], - [10000.45,'0[.]00[0]','10000.45'], - [10000.456,'0[.]00[0]','10000.456'], - [-10000,'(0,0.0000)','(10,000.0000)'], - [-12300,'+0,0.0000','-12,300.0000'], - [1230,'+0,0','+1,230'], - [100.78, '0', '101'], - [100.28, '0', '100'], - [1.932,'0.0','1.9'], - [1.9687,'0','2'], - [1.9687,'0.0','2.0'], - [-0.23,'.00','-.23'], - [-0.23,'(.00)','(.23)'], - [0.23,'0.00000','0.23000'], - [0.67,'0.0[0000]','0.67'], - [2000000000,'0.0a','2.0b'], - [1230974,'0.0a','1.2m'], - [1460,'0a','1k'], - [-104000,'0 a','-104 k'], - [1,'0o','1st'], - [52,'0 o','52 nd'], - [23,'0o','23rd'], - [100,'0o','100th'], - - // specified abbreviations - [-5444333222111, '0,0 aK', '-5,444,333,222 k'], - [-5444333222111, '0,0 aM', '-5,444,333 m'], - [-5444333222111, '0,0 aB', '-5,444 b'], - [-5444333222111, '0,0 aT', '-5 t'] - ], - i; - - test.expect(tests.length); - - for (i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - currency: function (test) { - var tests = [ - [1000.234,'$0,0.00','$1,000.23'], - [1001,'$ 0,0.[00]','$ 1,001'], - [1000.234,'0,0.00 $','1,000.23 $'], - [-1000.234,'($0,0)','($1,000)'], - [-1000.234,'(0,0$)','(1,000$)'], - [-1000.234,'$0.00','-$1000.23'], - [1230974,'($0.00 a)','$1.23 m'], - - // test symbol position before negative sign / open parens - [-1000.234,'$ (0,0)','$ (1,000)'], - [-1000.234,'$(0,0)','$(1,000)'], - [-1000.234,'$ (0,0.00)','$ (1,000.23)'], - [-1000.234,'$(0,0.00)','$(1,000.23)'], - [-1000.238,'$(0,0.00)','$(1,000.24)'], - [-1000.234,'$-0,0','$-1,000'], - [-1000.234,'$ -0,0','$ -1,000'], - - [1000.234,'$ (0,0)','$ 1,000'], - [1000.234,'$(0,0)','$1,000'], - [1000.234,'$ (0,0.00)','$ 1,000.23'], - [1000.234,'$(0,0.00)','$1,000.23'], - [1000.238,'$(0,0.00)','$1,000.24'], - [1000.234,'$-0,0)','$1,000'], - [1000.234,'$ -0,0','$ 1,000'] - ], - i; - - test.expect(tests.length); - - for (i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - bytes: function (test) { - var tests = [ - [100,'0b','100B'], - [1024*2,'0 b','2 KB'], - [1024*1024*5,'0b','5MB'], - [1024*1024*1024*7.343,'0.[0] b','7.3 GB'], - [1024*1024*1024*1024*3.1536544,'0.000b','3.154TB'], - [1024*1024*1024*1024*1024*2.953454534534,'0b','3PB'] - ], - i; - - test.expect(tests.length); - - for (i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - percentages: function (test) { - var tests = [ - [1,'0%','100%'], - [0.974878234,'0.000%','97.488%'], - [-0.43,'0 %','-43 %'], - [0.43,'(0.00[0]%)','43.00%'] - ], - i; - - test.expect(tests.length); - - for (i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - times: function (test) { - var tests = [ - [25,'00:00:00','0:00:25'], - [238,'00:00:00','0:03:58'], - [63846,'00:00:00','17:44:06'] - ], - i; - - test.expect(tests.length); - - for (i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - rounding: function (test) { - var tests = [ - // value, format string, expected w/ floor, expected w/ ceil - [2280002, '0.00a', '2.28m', '2.29m'], - [10000.23,'0,0','10,000', '10,001'], - [1000.234,'$0,0.00','$1,000.23', '$1,000.24'], - [0.974878234,'0.000%','97.487%','97.488%'], - [-0.433,'0 %','-44 %', '-43 %'] - ], - i; - - test.expect(tests.length * 2); - - for (i = 0; i < tests.length; i++) { - // floor - test.strictEqual(numeral(tests[i][0]).format(tests[i][1], Math.floor), tests[i][2], tests[i][1] + ", floor"); - - // ceil - test.strictEqual(numeral(tests[i][0]).format(tests[i][1], Math.ceil), tests[i][3], tests[i][1] + ", ceil"); - - } - - test.done(); - - }, -}; diff --git a/tests/numeral/manipulate.js b/tests/numeral/manipulate.js deleted file mode 100644 index bddd52e8..00000000 --- a/tests/numeral/manipulate.js +++ /dev/null @@ -1,104 +0,0 @@ -var numeral = require('../../numeral'); - -exports.manipulate = { - - add: function (test) { - test.expect(4); - - var tests = [ - [1000,10,1010], - [0.5,3,3.5], - [-100,200,100], - [0.1,0.2,0.3] - ], - num; - - for (var i = 0; i < tests.length; i++) { - num = numeral(tests[i][0]); - num.add(tests[i][1]); - test.strictEqual(num.value(), tests[i][2], tests[i][0] + ' + ' + tests[i][1]); - } - - test.done(); - }, - - subtract: function (test) { - test.expect(4); - - var tests = [ - [1000,10,990], - [0.5,3,-2.5], - [-100,200,-300], - [0.3,0.1,0.2] - ], - num; - - for (var i = 0; i < tests.length; i++) { - num = numeral(tests[i][0]); - num.subtract(tests[i][1]); - test.strictEqual(num.value(), tests[i][2], tests[i][0] + ' - ' + tests[i][1]); - } - - test.done(); - }, - - multiply: function (test) { - test.expect(4); - - var tests = [ - [1000,10,10000], - [0.5,3,1.5], - [-100,200,-20000], - [0.1,0.2,0.02] - ], - num; - - for (var i = 0; i < tests.length; i++) { - num = numeral(tests[i][0]); - num.multiply(tests[i][1]); - test.strictEqual(num.value(), tests[i][2], tests[i][0] + ' * ' + tests[i][1]); - } - - test.done(); - }, - - divide: function (test) { - test.expect(4); - - var tests = [ - [1000,10,100], - [0.5,3,0.16666666666666666], - [-100,200,-0.5], - [5.3,0.1,53] - ], - num; - - for (var i = 0; i < tests.length; i++) { - num = numeral(tests[i][0]); - num.divide(tests[i][1]); - test.strictEqual(num.value(), tests[i][2], tests[i][0] + ' / ' + tests[i][1]); - } - - test.done(); - }, - - difference: function (test) { - test.expect(4); - - var tests = [ - [1000,10,990], - [0.5,3,2.5], - [-100,200,300], - [0.3,0.2,0.1] - ], - num; - - for (var i = 0; i < tests.length; i++) { - num = numeral(tests[i][0]); - test.strictEqual(num.difference(tests[i][1]), tests[i][2], 'Difference between ' + tests[i][0] + ' and ' + tests[i][1]); - } - - test.done(); - } - -}; \ No newline at end of file diff --git a/tests/numeral/misc.js b/tests/numeral/misc.js deleted file mode 100644 index 0a07a482..00000000 --- a/tests/numeral/misc.js +++ /dev/null @@ -1,123 +0,0 @@ -var numeral = require('../../numeral'); - -exports.misc = { - - value: function (test) { - test.expect(5); - - var tests = [ - [1000, 1000], - [0.5, 0.5], - [, 0], - ['1,000', 1000], - ['not a number', 0] - ], - num; - - for (var i = 0; i < tests.length; i++) { - num = numeral(tests[i][0]); - test.strictEqual(num.value(), tests[i][1], tests[i][1]); - } - - test.done(); - }, - - set: function (test) { - test.expect(2); - - var tests = [ - [1000,1000], - [-0.25,-0.25] - ], - num; - - for (var i = 0; i < tests.length; i++) { - num = numeral().set(tests[i][0]); - test.strictEqual(num.value(), tests[i][1], tests[i][0]); - } - - test.done(); - }, - - customZero: function (test) { - test.expect(3); - - var tests = [ - [0,null,'0'], - [0,'N/A','N/A'], - [0,'',''] - ]; - - for (var i = 0; i < tests.length; i++) { - numeral.zeroFormat(tests[i][1]); - test.strictEqual(numeral(tests[i][0]).format('0'), tests[i][2], tests[i][1]); - } - - test.done(); - }, - - clone: function (test) { - test.expect(4); - - var a = numeral(1000), - b = numeral(a), - c = a.clone(), - aVal = a.value(), - aSet = a.set(2000).value(), - bVal = b.value(), - cVal = c.add(10).value(); - - test.strictEqual(aVal, 1000, 'Parent starting value'); - test.strictEqual(aSet, 2000, 'Parent set to 2000'); - test.strictEqual(bVal, 1000, 'Implicit clone unmanipulated'); - test.strictEqual(cVal, 1010, 'Explicit clone + 10'); - - test.done(); - }, - - isNumeral: function (test) { - test.expect(2); - - var tests = [ - [numeral(),true], - [1,false] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral.isNumeral(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - }, - - languageData: function(test) { - test.expect(10); - - var cOld = '$', - cNew = '!', - formatTestVal = function() { return numeral('100').format('$0,0') }, - oldCurrencyVal = cOld + '100', - newCurrencyVal = cNew + '100'; - - test.strictEqual(numeral.languageData().currency.symbol, cOld, 'Current language currency is ' + cOld); - test.strictEqual(numeral.languageData('en').currency.symbol, cOld, 'English language currency is ' + cOld); - - numeral.languageData().currency.symbol = cNew; - test.strictEqual(numeral.languageData().currency.symbol, cNew, 'Current language currency is changed to ' + cNew); - test.strictEqual(formatTestVal(), newCurrencyVal, 'Format uses new currency'); - - numeral.languageData().currency.symbol = cOld; - test.strictEqual(numeral.languageData().currency.symbol, '$', 'Current language currency is reset to ' + cOld); - test.strictEqual(formatTestVal(), oldCurrencyVal, 'Format uses old currency'); - - numeral.languageData('en').currency.symbol = cNew; - test.strictEqual(numeral.languageData().currency.symbol, cNew, 'English language currency is changed to ' + cNew); - test.strictEqual(formatTestVal(), newCurrencyVal, 'Format uses new currency'); - - numeral.languageData('en').currency.symbol = cOld; - test.strictEqual(numeral.languageData().currency.symbol, cOld, 'English language currency is reset to ' + cOld); - test.strictEqual(formatTestVal(), oldCurrencyVal, 'Format uses old currency'); - - test.done(); - } -}; \ No newline at end of file diff --git a/tests/numeral/unformat.js b/tests/numeral/unformat.js deleted file mode 100644 index f0b059b9..00000000 --- a/tests/numeral/unformat.js +++ /dev/null @@ -1,96 +0,0 @@ -var numeral = require('../../numeral'); - -exports.unformat = { - setUp: function (callback) { - numeral.zeroFormat('N/A'); - callback(); - }, - - numbers: function (test) { - test.expect(15); - - var tests = [ - ['10,000.123', 10000.123], - ['(0.12345)', -0.12345], - ['((--0.12345))', 0.12345], - ['23rd', 23], - ['31st', 31], - ['1.23t', 1230000000000], - ['N/A', 0], - [, 0], - ['', 0], - - // Pass Through for Numbers - [0, 0], - [1, 1], - [1.1, 1.1], - [-0, 0], - [-1, -1], - [-1.1, -1.1] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - }, - - currency: function (test) { - test.expect(2); - - var tests = [ - ['($1.23m)', -1230000], - ['$ 10,000.00', 10000] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - }, - - bytes: function (test) { - test.expect(2); - - var tests = [ - ['100B', 100], - ['3.154 TB', 3467859674006] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - }, - - percentages: function (test) { - test.expect(1); - - var tests = [ - ['-76%', -0.76] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - }, - - time: function (test) { - test.expect(1); - - var tests = [ - ['2:23:57', 8637] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file