From 0ed045c2718d9591320f4edbd1878ca4291eb54f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauris=20Buk=C5=A1is-Haberkorns?= Date: Wed, 8 Jan 2014 11:15:55 +0200 Subject: [PATCH 001/150] Add Latvian language --- languages/lv.js | 33 ++++++++++++++ tests/languages/lv.js | 101 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 languages/lv.js create mode 100644 tests/languages/lv.js diff --git a/languages/lv.js b/languages/lv.js new file mode 100644 index 00000000..4abb22e8 --- /dev/null +++ b/languages/lv.js @@ -0,0 +1,33 @@ +/*! + * numeral.js language configuration + * language : Latvian (lv) + * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks + */ +(function () { + var language = { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: ' tūkst.', + million: ' milj.', + billion: ' mljrd.', + trillion: ' trilj.' + }, + 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('lv', language); + } +}()); diff --git a/tests/languages/lv.js b/tests/languages/lv.js new file mode 100644 index 00000000..31109853 --- /dev/null +++ b/tests/languages/lv.js @@ -0,0 +1,101 @@ +var numeral = require('../../numeral'), + language = require('../../languages/lv'); + +numeral.language('lv', language); + +exports['language:lv'] = { + setUp: function (callback) { + numeral.language('lv'); + 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 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++) { + 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 milj.'] + ]; + + 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 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++) { + test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); + } + + test.done(); + } +}; From b30166107595db878195cc789e90a6f06ea1a378 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauris=20Buk=C5=A1is-Haberkorns?= Date: Wed, 8 Jan 2014 11:18:49 +0200 Subject: [PATCH 002/150] Build --- languages.js | 34 ++++++++++++++++++++++++++++++++++ min/languages.min.js | 7 ++++++- min/languages/lv.min.js | 6 ++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 min/languages/lv.min.js diff --git a/languages.js b/languages.js index 2f502ea0..cc2abc41 100644 --- a/languages.js +++ b/languages.js @@ -602,6 +602,40 @@ } }()); +/*! + * numeral.js language configuration + * language : Latvian (lv) + * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks + */ +(function () { + var language = { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: ' tūkst.', + million: ' milj.', + billion: ' mljrd.', + trillion: ' trilj.' + }, + 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('lv', language); + } +}()); + /*! * numeral.js language configuration * language : netherlands-dutch (nl-nl) diff --git a/min/languages.min.js b/min/languages.min.js index 11252868..1207c5e6 100644 --- a/min/languages.min.js +++ b/min/languages.min.js @@ -86,7 +86,12 @@ function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand * 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)}(),/*! +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 : Latvian (lv) + * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks + */ +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("lv",a)}(),/*! * numeral.js language configuration * language : netherlands-dutch (nl-nl) * author : Dave Clayton : https://github.com/davedx diff --git a/min/languages/lv.min.js b/min/languages/lv.min.js new file mode 100644 index 00000000..db627a86 --- /dev/null +++ b/min/languages/lv.min.js @@ -0,0 +1,6 @@ +/*! + * numeral.js language configuration + * language : Latvian (lv) + * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks + */ +!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("lv",a)}(); \ No newline at end of file From 12a97ab7b8c74599b2616add78e34258dffee170 Mon Sep 17 00:00:00 2001 From: Clay Walker Date: Fri, 17 Jan 2014 14:59:37 -0800 Subject: [PATCH 003/150] Changed byte units to use binary prefixes per #37. --- min/numeral.min.js | 2 +- numeral.js | 34 +++++++++++++++++----------------- tests/numeral/format.js | 28 ++++++++++++++-------------- tests/numeral/unformat.js | 4 ++-- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/min/numeral.min.js b/min/numeral.min.js index d17b5571..b463b553 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * 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(){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=["KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],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","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],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 diff --git a/numeral.js b/numeral.js index 9f46ab65..bc789e3f 100644 --- a/numeral.js +++ b/numeral.js @@ -43,7 +43,7 @@ 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); @@ -86,7 +86,7 @@ millionRegExp, billionRegExp, trillionRegExp, - suffixes = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], + suffixes = ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'], bytesMultiplier = false, power; @@ -188,7 +188,7 @@ } output = formatNumber(value, format, roundingFunction); - + if (output.indexOf(')') > -1 ) { output = output.split(''); output.splice(-1, 0, space + '%'); @@ -240,7 +240,7 @@ bytes = '', ord = '', abs = Math.abs(value), - suffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], + suffixes = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'], min, max, power, @@ -433,7 +433,7 @@ 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. @@ -441,11 +441,11 @@ if (!key) { return languages[currentLanguage]; } - + if (!languages[key]) { throw new Error('Unknown language : ' + key); } - + return languages[key]; }; @@ -502,14 +502,14 @@ 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'); } @@ -543,7 +543,7 @@ }; } - + /** * Computes the multiplier necessary to make x >= 1, * effectively eliminating miscalculations caused by @@ -569,7 +569,7 @@ mn = multiplier(next); return mp > mn ? mp : mn; }, -Infinity); - } + } /************************************ @@ -584,15 +584,15 @@ }, format : function (inputString, roundingFunction) { - return formatNumeral(this, - inputString ? inputString : defaultFormat, + return formatNumeral(this, + inputString ? inputString : defaultFormat, (roundingFunction !== undefined) ? roundingFunction : Math.round ); }, unformat : function (inputString) { - if (Object.prototype.toString.call(inputString) === '[object Number]') { - return inputString; + if (Object.prototype.toString.call(inputString) === '[object Number]') { + return inputString; } return unformatNumeral(this, inputString ? inputString : defaultFormat); }, @@ -624,7 +624,7 @@ function cback(accum, curr, currI, O) { return accum - corrFactor * curr; } - this._value = [value].reduce(cback, this._value * corrFactor) / corrFactor; + this._value = [value].reduce(cback, this._value * corrFactor) / corrFactor; return this; }, @@ -643,7 +643,7 @@ var corrFactor = correctionFactor(accum, curr); return (accum * corrFactor) / (curr * corrFactor); } - this._value = [this._value, value].reduce(cback); + this._value = [this._value, value].reduce(cback); return this; }, diff --git a/tests/numeral/format.js b/tests/numeral/format.js index 53427ad4..3ef27b11 100644 --- a/tests/numeral/format.js +++ b/tests/numeral/format.js @@ -24,7 +24,7 @@ exports.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]); @@ -124,11 +124,11 @@ exports.format = { 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'] + [1024*2,'0 b','2 KiB'], + [1024*1024*5,'0b','5MiB'], + [1024*1024*1024*7.343,'0.[0] b','7.3 GiB'], + [1024*1024*1024*1024*3.1536544,'0.000b','3.154TiB'], + [1024*1024*1024*1024*1024*2.953454534534,'0b','3PiB'] ], i; @@ -175,7 +175,7 @@ exports.format = { test.done(); }, - + rounding: function (test) { var tests = [ // value, format string, expected w/ floor, expected w/ ceil @@ -186,19 +186,19 @@ exports.format = { [-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.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/unformat.js b/tests/numeral/unformat.js index f0b059b9..3e63aca8 100644 --- a/tests/numeral/unformat.js +++ b/tests/numeral/unformat.js @@ -56,7 +56,7 @@ exports.unformat = { var tests = [ ['100B', 100], - ['3.154 TB', 3467859674006] + ['3.154 TiB', 3467859674006] ]; for (var i = 0; i < tests.length; i++) { @@ -93,4 +93,4 @@ exports.unformat = { test.done(); } -}; \ No newline at end of file +}; From 4886b9f28c8f73cb604c3c1e64df233b31c98a59 Mon Sep 17 00:00:00 2001 From: Clay Walker Date: Fri, 17 Jan 2014 15:20:49 -0800 Subject: [PATCH 004/150] Implemented binary and decimal bytes with tests. --- min/numeral.min.js | 2 +- numeral.js | 46 +++++++++++++++++++++++++++++---------- tests/numeral/format.js | 7 +++++- tests/numeral/unformat.js | 5 +++-- 4 files changed, 45 insertions(+), 15 deletions(-) diff --git a/min/numeral.min.js b/min/numeral.min.js index b463b553..fa77cb74 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * 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=["KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],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","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],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(){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=["KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],k=["KB","MB","GB","TB","PB","EB","ZB","YB"],l=!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&&!l;g++)l=b.indexOf(j[g])>-1?Math.pow(1024,g+1):b.indexOf(k[g])>-1?Math.pow(1e3,g+1):!1;a._value=(l?l: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=l?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","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],A=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],B="",C=!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}if(c.indexOf("d")>-1)for(c.indexOf(" d")>-1?(w=" ",c=c.replace(" d","")):c=c.replace("d",""),g=0;g<=A.length;g++)if(e=Math.pow(1e3,g),f=Math.pow(1e3,g+1),a>=e&&f>a){w+=A[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("["),B=b(a,i[0].length+i[1].length,d,i[1].length)):B=b(a,i.length,d),h=B.split(".")[0],B=B.split(".")[1].length?o[p].delimiters.decimal+B.split(".")[1]:"",m&&0===Number(B.slice(1))&&(B="")):h=b(a,null,d),h.indexOf("-")>-1&&(h=h.slice(1),C=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+o[p].delimiters.thousands)),0===c.indexOf(".")&&(h=""),(k&&C?"(":"")+(!k&&C?"-":"")+(!C&&l?"+":"")+h+B+(x?x:"")+(n?n:"")+(w?w:"")+(k&&C?")":"")}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 diff --git a/numeral.js b/numeral.js index bc789e3f..b0cde2d9 100644 --- a/numeral.js +++ b/numeral.js @@ -86,7 +86,8 @@ millionRegExp, billionRegExp, trillionRegExp, - suffixes = ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'], + binarySuffixes = ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'], + decimalSuffixes = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], bytesMultiplier = false, power; @@ -107,12 +108,10 @@ trillionRegExp = new RegExp('[^a-zA-Z]' + languages[currentLanguage].abbreviations.trillion + '(?:\\)|(\\' + languages[currentLanguage].currency.symbol + ')?(?:\\))?)?$'); // 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; - } + for (power = 0; power <= binarySuffixes.length && !bytesMultiplier; power++) { + if (string.indexOf(binarySuffixes[power]) > -1) { bytesMultiplier = Math.pow(1024, power + 1); } + else if (string.indexOf(decimalSuffixes[power]) > -1) { bytesMultiplier = Math.pow(1000, power + 1); } + else { bytesMultiplier = false; } } // do some math to create our number @@ -240,7 +239,8 @@ bytes = '', ord = '', abs = Math.abs(value), - suffixes = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'], + binarySuffixes = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'], + decimalSuffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], min, max, power, @@ -300,7 +300,7 @@ } } - // see if we are formatting bytes + // see if we are formatting binary bytes if (format.indexOf('b') > -1) { // check for space before if (format.indexOf(' b') > -1) { @@ -310,12 +310,36 @@ format = format.replace('b', ''); } - for (power = 0; power <= suffixes.length; power++) { + for (power = 0; power <= binarySuffixes.length; power++) { min = Math.pow(1024, power); max = Math.pow(1024, power+1); if (value >= min && value < max) { - bytes = bytes + suffixes[power]; + bytes = bytes + binarySuffixes[power]; + if (min > 0) { + value = value / min; + } + break; + } + } + } + + // see if we are formatting decimal bytes + if (format.indexOf('d') > -1) { + // check for space before + if (format.indexOf(' d') > -1) { + bytes = ' '; + format = format.replace(' d', ''); + } else { + format = format.replace('d', ''); + } + + for (power = 0; power <= decimalSuffixes.length; power++) { + min = Math.pow(1000, power); + max = Math.pow(1000, power+1); + + if (value >= min && value < max) { + bytes = bytes + decimalSuffixes[power]; if (min > 0) { value = value / min; } diff --git a/tests/numeral/format.js b/tests/numeral/format.js index 3ef27b11..0348cead 100644 --- a/tests/numeral/format.js +++ b/tests/numeral/format.js @@ -128,7 +128,12 @@ exports.format = { [1024*1024*5,'0b','5MiB'], [1024*1024*1024*7.343,'0.[0] b','7.3 GiB'], [1024*1024*1024*1024*3.1536544,'0.000b','3.154TiB'], - [1024*1024*1024*1024*1024*2.953454534534,'0b','3PiB'] + [1024*1024*1024*1024*1024*2.953454534534,'0b','3PiB'], + [1000*2,'0 d','2 KB'], + [1000*1000*5,'0d','5MB'], + [1000*1000*1000*7.343,'0.[0] d','7.3 GB'], + [1000*1000*1000*1000*3.1536544,'0.000d','3.154TB'], + [1000*1000*1000*1000*1000*2.953454534534,'0d','3PB'] ], i; diff --git a/tests/numeral/unformat.js b/tests/numeral/unformat.js index 3e63aca8..593b06b3 100644 --- a/tests/numeral/unformat.js +++ b/tests/numeral/unformat.js @@ -52,11 +52,12 @@ exports.unformat = { }, bytes: function (test) { - test.expect(2); + test.expect(3); var tests = [ ['100B', 100], - ['3.154 TiB', 3467859674006] + ['3.154 TiB', 3467859674006], + ['3.154 TB', 3154000000000] ]; for (var i = 0; i < tests.length; i++) { From df6e4040acaa2122cd1ce14dab0a61d6d03e6216 Mon Sep 17 00:00:00 2001 From: Mudit Ameta Date: Wed, 5 Mar 2014 17:11:35 +0530 Subject: [PATCH 005/150] added a forgiving validate method to validate localized numerals --- numeral.js | 185 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 126 insertions(+), 59 deletions(-) diff --git a/numeral.js b/numeral.js index 9f46ab65..9f7022da 100644 --- a/numeral.js +++ b/numeral.js @@ -6,7 +6,7 @@ * http://adamwdraper.github.com/Numeral-js/ */ -(function () { +(function() { /************************************ Constants @@ -29,7 +29,7 @@ // Numeral prototype object - function Numeral (number) { + function Numeral(number) { this._value = number; } @@ -39,11 +39,11 @@ * 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) { + 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); @@ -61,7 +61,7 @@ ************************************/ // determine what type of formatting we need to do - function formatNumeral (n, format, roundingFunction) { + function formatNumeral(n, format, roundingFunction) { var output; // figure out what kind of format we are dealing with @@ -80,7 +80,7 @@ } // revert to number - function unformatNumeral (n, string) { + function unformatNumeral(n, string) { var stringOriginal = string, thousandRegExp, millionRegExp, @@ -97,7 +97,7 @@ n._value = 0; } else { if (languages[currentLanguage].delimiters.decimal !== '.') { - string = string.replace(/\./g,'').replace(languages[currentLanguage].delimiters.decimal, '.'); + string = string.replace(/\./g, '').replace(languages[currentLanguage].delimiters.decimal, '.'); } // see if abbreviations are there so that we can multiply to the correct number @@ -116,7 +116,7 @@ } // 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, '')); + 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, '')); // round if we are talking about bytes n._value = (bytesMultiplier) ? Math.ceil(n._value) : n._value; @@ -125,7 +125,7 @@ return n._value; } - function formatCurrency (n, format, roundingFunction) { + function formatCurrency(n, format, roundingFunction) { var symbolIndex = format.indexOf('$'), openParenIndex = format.indexOf('('), minusSignIndex = format.indexOf('-'), @@ -152,7 +152,7 @@ if (output.indexOf('(') > -1 || output.indexOf('-') > -1) { output = output.split(''); spliceIndex = 1; - if (symbolIndex < openParenIndex || symbolIndex < minusSignIndex){ + if (symbolIndex < openParenIndex || symbolIndex < minusSignIndex) { // the symbol appears before the "(" or "-" spliceIndex = 0; } @@ -174,7 +174,7 @@ return output; } - function formatPercentage (n, format, roundingFunction) { + function formatPercentage(n, format, roundingFunction) { var space = '', output, value = n._value * 100; @@ -188,8 +188,8 @@ } output = formatNumber(value, format, roundingFunction); - - if (output.indexOf(')') > -1 ) { + + if (output.indexOf(')') > -1) { output = output.split(''); output.splice(-1, 0, space + '%'); output = output.join(''); @@ -200,14 +200,14 @@ return output; } - function formatTime (n) { - var hours = Math.floor(n._value/60/60), - minutes = Math.floor((n._value - (hours * 60 * 60))/60), + 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); } - function unformatTime (string) { + function unformatTime(string) { var timeArray = string.split(':'), seconds = 0; // turn hours and minutes into seconds and add them all up @@ -227,7 +227,7 @@ return Number(seconds); } - function formatNumber (value, format, roundingFunction) { + function formatNumber(value, format, roundingFunction) { var negP = false, signed = false, optDec = false, @@ -312,7 +312,7 @@ for (power = 0; power <= suffixes.length; power++) { min = Math.pow(1024, power); - max = Math.pow(1024, power+1); + max = Math.pow(1024, power + 1); if (value >= min && value < max) { bytes = bytes + suffixes[power]; @@ -392,7 +392,7 @@ Top Level Functions ************************************/ - numeral = function (input) { + numeral = function(input) { if (numeral.isNumeral(input)) { input = input.value(); } else if (input === 0 || typeof input === 'undefined') { @@ -408,20 +408,20 @@ numeral.version = VERSION; // compare numeral object - numeral.isNumeral = function (obj) { + numeral.isNumeral = function(obj) { return obj instanceof Numeral; }; // 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) { + numeral.language = function(key, values) { if (!key) { return currentLanguage; } if (key && !values) { - if(!languages[key]) { + if (!languages[key]) { throw new Error('Unknown language : ' + key); } currentLanguage = key; @@ -433,19 +433,19 @@ 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) { + numeral.languageData = function(key) { if (!key) { return languages[currentLanguage]; } - + if (!languages[key]) { throw new Error('Unknown language : ' + key); } - + return languages[key]; }; @@ -460,9 +460,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,11 +472,11 @@ } }); - numeral.zeroFormat = function (format) { + numeral.zeroFormat = function(format) { zeroFormat = typeof(format) === 'string' ? format : null; }; - numeral.defaultFormat = function (format) { + numeral.defaultFormat = function(format) { defaultFormat = typeof(format) === 'string' ? format : '0.0'; }; @@ -500,16 +500,16 @@ * 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) { + 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'); } @@ -543,7 +543,7 @@ }; } - + /** * Computes the multiplier necessary to make x >= 1, * effectively eliminating miscalculations caused by @@ -564,12 +564,12 @@ */ function correctionFactor() { var args = Array.prototype.slice.call(arguments); - return args.reduce(function (prev, next) { + return args.reduce(function(prev, next) { var mp = multiplier(prev), mn = multiplier(next); - return mp > mn ? mp : mn; + return mp > mn ? mp : mn; }, -Infinity); - } + } /************************************ @@ -579,39 +579,39 @@ numeral.fn = Numeral.prototype = { - clone : function () { + clone: function() { return numeral(this); }, - format : function (inputString, roundingFunction) { - return formatNumeral(this, - inputString ? inputString : defaultFormat, - (roundingFunction !== undefined) ? roundingFunction : Math.round - ); + format: function(inputString, roundingFunction) { + return formatNumeral(this, + inputString ? inputString : defaultFormat, (roundingFunction !== undefined) ? roundingFunction : Math.round + ); }, - unformat : function (inputString) { - if (Object.prototype.toString.call(inputString) === '[object Number]') { - return inputString; + unformat: function(inputString) { + if (Object.prototype.toString.call(inputString) === '[object Number]') { + return inputString; } return unformatNumeral(this, inputString ? inputString : defaultFormat); }, - value : function () { + value: function() { return this._value; }, - valueOf : function () { + valueOf: function() { return this._value; }, - set : function (value) { + set: function(value) { this._value = Number(value); return this; }, - add : function (value) { + add: function(value) { var corrFactor = correctionFactor.call(null, this._value, value); + function cback(accum, curr, currI, O) { return accum + corrFactor * curr; } @@ -619,16 +619,17 @@ return this; }, - subtract : function (value) { + 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; + this._value = [value].reduce(cback, this._value * corrFactor) / corrFactor; return this; }, - multiply : function (value) { + multiply: function(value) { function cback(accum, curr, currI, O) { var corrFactor = correctionFactor(accum, curr); return (accum * corrFactor) * (curr * corrFactor) / @@ -638,17 +639,83 @@ return this; }, - divide : function (value) { + divide: function(value) { function cback(accum, curr, currI, O) { var corrFactor = correctionFactor(accum, curr); return (accum * corrFactor) / (curr * corrFactor); } - this._value = [this._value, value].reduce(cback); + this._value = [this._value, value].reduce(cback); return this; }, - difference : function (value) { + difference: function(value) { return Math.abs(numeral(this._value).subtract(value).value()); + }, + + validate: function(val, culture) { + + var _decimalSep, + _thousandSep, + _currSymbol, + _valArray, + _thousandRegEx, + temp; + + //coerce val to string + if (typeof val !== "string") + val += ""; + + //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.languageData + try { + //check if the culture is understood by numeral. if not, default it to current language + numeral.languageData(culture).delimiters; + } catch (e) { + culture = numeral.language(); + } + + //setup the delimiters and currency symbol based on culture/language + _currSymbol = numeral.languageData(culture).currency.symbol; + _decimalSep = numeral.languageData(culture).delimiters.decimal; + if (numeral.languageData(culture).delimiters.thousands == ".") + _thousandSep = "\\."; + else + _thousandSep = numeral.languageData(culture).delimiters.thousands; + + // validating currency symbol + temp = val.match(/^[^\d]/); + if (temp !== null) { + val = val.substr(1); + if (temp[0] !== _currSymbol) + 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; } }; @@ -672,8 +739,8 @@ /*global define:false */ if (typeof define === 'function' && define.amd) { - define([], function () { + define([], function() { return numeral; }); } -}).call(this); +}).call(this); \ No newline at end of file From 6b9c9d3e5c0809596c89a5bb4e940911b04a53cc Mon Sep 17 00:00:00 2001 From: Mudit Ameta Date: Wed, 5 Mar 2014 17:20:11 +0530 Subject: [PATCH 006/150] Fixed formatting etc based on jshint grunt task messages --- numeral.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/numeral.js b/numeral.js index 9f7022da..285ec5dc 100644 --- a/numeral.js +++ b/numeral.js @@ -662,15 +662,15 @@ temp; //coerce val to string - if (typeof val !== "string") - val += ""; + if (typeof val !== 'string') + val += ''; //if val is just digits return true if ( !! val.match(/^\d+$/)) return true; //if val is empty return false - if (val == "") + if (val == '') return false; //get the decimal and thousands separator from numeral.languageData @@ -684,8 +684,8 @@ //setup the delimiters and currency symbol based on culture/language _currSymbol = numeral.languageData(culture).currency.symbol; _decimalSep = numeral.languageData(culture).delimiters.decimal; - if (numeral.languageData(culture).delimiters.thousands == ".") - _thousandSep = "\\."; + if (numeral.languageData(culture).delimiters.thousands == '.') + _thousandSep = '\\.'; else _thousandSep = numeral.languageData(culture).delimiters.thousands; @@ -697,7 +697,7 @@ return false; } - _thousandRegEx = new RegExp(_thousandSep + "{2}"); + _thousandRegEx = new RegExp(_thousandSep + '{2}'); if ( !! !val.match(/[^\d.,]/g)) { _valArray = val.split(_decimalSep); From 7a20e4f6ea7946b912037145af11b1cdc36848c4 Mon Sep 17 00:00:00 2001 From: Mudit Ameta Date: Wed, 5 Mar 2014 17:23:06 +0530 Subject: [PATCH 007/150] Fixed formatting etc based on jshint grunt task messages --- numeral.js | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/numeral.js b/numeral.js index 285ec5dc..bf1baa63 100644 --- a/numeral.js +++ b/numeral.js @@ -662,16 +662,19 @@ temp; //coerce val to string - if (typeof val !== 'string') + if (typeof val !== 'string') { val += ''; + } //if val is just digits return true - if ( !! val.match(/^\d+$/)) + if ( !! val.match(/^\d+$/)) { return true; + } //if val is empty return false - if (val == '') + if (val == '') { return false; + } //get the decimal and thousands separator from numeral.languageData try { @@ -684,33 +687,36 @@ //setup the delimiters and currency symbol based on culture/language _currSymbol = numeral.languageData(culture).currency.symbol; _decimalSep = numeral.languageData(culture).delimiters.decimal; - if (numeral.languageData(culture).delimiters.thousands == '.') + if (numeral.languageData(culture).delimiters.thousands == '.') { _thousandSep = '\\.'; - else + } else { _thousandSep = numeral.languageData(culture).delimiters.thousands; + } // validating currency symbol temp = val.match(/^[^\d]/); if (temp !== null) { val = val.substr(1); - if (temp[0] !== _currSymbol) + if (temp[0] !== _currSymbol) { return false; + } } _thousandRegEx = new RegExp(_thousandSep + '{2}'); if ( !! !val.match(/[^\d.,]/g)) { _valArray = val.split(_decimalSep); - if (_valArray.length > 2) + if (_valArray.length > 2) { return false; - else { - if (_valArray.length < 2) + } else { + if (_valArray.length < 2) { return ( !! _valArray[0].match(/^\d+.*\d$/) && !! !_valArray[0].match(_thousandRegEx)); - else { - if (_valArray[0].length === 1) + } else { + if (_valArray[0].length === 1) { return ( !! _valArray[0].match(/^\d+$/) && !! !_valArray[0].match(_thousandRegEx) && !! _valArray[1].match(/^\d+$/)); - else + } else { return ( !! _valArray[0].match(/^\d+.*\d$/) && !! !_valArray[0].match(_thousandRegEx) && !! _valArray[1].match(/^\d+$/)); + } } } } From d23ee7fb8ce3505f91a17d5f6497346f2444d55c Mon Sep 17 00:00:00 2001 From: Mudit Ameta Date: Wed, 5 Mar 2014 17:30:44 +0530 Subject: [PATCH 008/150] few more jshint warning fixes --- numeral.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/numeral.js b/numeral.js index bf1baa63..e4d27f81 100644 --- a/numeral.js +++ b/numeral.js @@ -672,14 +672,14 @@ } //if val is empty return false - if (val == '') { + if (val === '') { return false; } //get the decimal and thousands separator from numeral.languageData try { //check if the culture is understood by numeral. if not, default it to current language - numeral.languageData(culture).delimiters; + numeral.languageData(culture); } catch (e) { culture = numeral.language(); } @@ -687,7 +687,7 @@ //setup the delimiters and currency symbol based on culture/language _currSymbol = numeral.languageData(culture).currency.symbol; _decimalSep = numeral.languageData(culture).delimiters.decimal; - if (numeral.languageData(culture).delimiters.thousands == '.') { + if (numeral.languageData(culture).delimiters.thousands === '.') { _thousandSep = '\\.'; } else { _thousandSep = numeral.languageData(culture).delimiters.thousands; From 2cbcb02613c360304c49832f8d021aeba3d651e5 Mon Sep 17 00:00:00 2001 From: Mudit Ameta Date: Wed, 5 Mar 2014 18:28:04 +0530 Subject: [PATCH 009/150] Added a top level forgiving validate method to numeral. Also added the tests --- numeral.js | 149 ++++++++++++++++++++------------------ tests/numeral/validate.js | 57 +++++++++++++++ 2 files changed, 134 insertions(+), 72 deletions(-) create mode 100644 tests/numeral/validate.js diff --git a/numeral.js b/numeral.js index e4d27f81..14e36b7a 100644 --- a/numeral.js +++ b/numeral.js @@ -480,6 +480,83 @@ defaultFormat = typeof(format) === 'string' ? format : '0.0'; }; + numeral.validate = function(val, culture) { + + var _decimalSep, + _thousandSep, + _currSymbol, + _valArray, + _thousandRegEx, + temp; + + //coerce val to string + if (typeof val !== 'string') { + if (console.warn){ + console.warn('Numeral.js: Value is not string. It has been co-erced to: ',val); + } + val += ''; + } + + 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.languageData + try { + //check if the culture is understood by numeral. if not, default it to current language + numeral.languageData(culture); + } catch (e) { + culture = numeral.language(); + } + + //setup the delimiters and currency symbol based on culture/language + _currSymbol = numeral.languageData(culture).currency.symbol; + _decimalSep = numeral.languageData(culture).delimiters.decimal; + if (numeral.languageData(culture).delimiters.thousands === '.') { + _thousandSep = '\\.'; + } else { + _thousandSep = numeral.languageData(culture).delimiters.thousands; + } + + // validating currency symbol + temp = val.match(/^[^\d]/); + if (temp !== null) { + val = val.substr(1); + if (temp[0] !== _currSymbol) { + 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; + }; + /************************************ Helpers ************************************/ @@ -650,78 +727,6 @@ difference: function(value) { return Math.abs(numeral(this._value).subtract(value).value()); - }, - - validate: function(val, culture) { - - var _decimalSep, - _thousandSep, - _currSymbol, - _valArray, - _thousandRegEx, - temp; - - //coerce val to string - if (typeof val !== 'string') { - val += ''; - } - - //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.languageData - try { - //check if the culture is understood by numeral. if not, default it to current language - numeral.languageData(culture); - } catch (e) { - culture = numeral.language(); - } - - //setup the delimiters and currency symbol based on culture/language - _currSymbol = numeral.languageData(culture).currency.symbol; - _decimalSep = numeral.languageData(culture).delimiters.decimal; - if (numeral.languageData(culture).delimiters.thousands === '.') { - _thousandSep = '\\.'; - } else { - _thousandSep = numeral.languageData(culture).delimiters.thousands; - } - - // validating currency symbol - temp = val.match(/^[^\d]/); - if (temp !== null) { - val = val.substr(1); - if (temp[0] !== _currSymbol) { - 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; } }; diff --git a/tests/numeral/validate.js b/tests/numeral/validate.js new file mode 100644 index 00000000..9a9ba146 --- /dev/null +++ b/tests/numeral/validate.js @@ -0,0 +1,57 @@ +var numeral = require('../../numeral'), + language = 'en'; + +exports.validate = { + numbers: function(test) { + 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] + ]; + test.expect(tests.length); + for(var i=0; i Date: Thu, 6 Mar 2014 00:26:54 +0530 Subject: [PATCH 010/150] Updated validate method to support validations involving the abbreviations for thousand, million, etc for the current language/culture or the passed language/culture. Added tests to validate.js for the same. Also ran grunt build after a successful grunt test call. --- languages.js | 1910 ++++++++++++++++++------------------- min/numeral.min.js | 2 +- numeral.js | 33 +- tests/numeral/validate.js | 15 +- 4 files changed, 993 insertions(+), 967 deletions(-) diff --git a/languages.js b/languages.js index 2f502ea0..c442275a 100644 --- a/languages.js +++ b/languages.js @@ -1,38 +1,38 @@ -/*! - * 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 : 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 @@ -67,923 +67,923 @@ 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); - } -}()); + +/*! + * 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/min/numeral.min.js b/min/numeral.min.js index d17b5571..e798f2a9 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * 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(){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"},m.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=m.languageData(b)}catch(k){i=m.languageData(m.language())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},"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 diff --git a/numeral.js b/numeral.js index 14e36b7a..34298772 100644 --- a/numeral.js +++ b/numeral.js @@ -486,17 +486,20 @@ _thousandSep, _currSymbol, _valArray, + _abbrObj, _thousandRegEx, + languageData, temp; //coerce val to string if (typeof val !== 'string') { - if (console.warn){ - console.warn('Numeral.js: Value is not string. It has been co-erced to: ',val); - } 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 @@ -512,22 +515,23 @@ //get the decimal and thousands separator from numeral.languageData try { //check if the culture is understood by numeral. if not, default it to current language - numeral.languageData(culture); + languageData = numeral.languageData(culture); } catch (e) { - culture = numeral.language(); + languageData = numeral.languageData(numeral.language()); } //setup the delimiters and currency symbol based on culture/language - _currSymbol = numeral.languageData(culture).currency.symbol; - _decimalSep = numeral.languageData(culture).delimiters.decimal; - if (numeral.languageData(culture).delimiters.thousands === '.') { + _currSymbol = languageData.currency.symbol; + _abbrObj = languageData.abbreviations; + _decimalSep = languageData.delimiters.decimal; + if (languageData.delimiters.thousands === '.') { _thousandSep = '\\.'; } else { - _thousandSep = numeral.languageData(culture).delimiters.thousands; + _thousandSep = languageData.delimiters.thousands; } // validating currency symbol - temp = val.match(/^[^\d]/); + temp = val.match(/^[^\d]+/); if (temp !== null) { val = val.substr(1); if (temp[0] !== _currSymbol) { @@ -535,6 +539,15 @@ } } + //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)) { diff --git a/tests/numeral/validate.js b/tests/numeral/validate.js index 9a9ba146..d36b6dea 100644 --- a/tests/numeral/validate.js +++ b/tests/numeral/validate.js @@ -1,6 +1,7 @@ var numeral = require('../../numeral'), language = 'en'; +//All the tests are for en or en-US exports.validate = { numbers: function(test) { var tests = [ @@ -41,12 +42,24 @@ exports.validate = { [' $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] + ['%1000', false], + ['100,456.123z', false], + ['$100$', false], + ['$100,213.456l', false], + ['aa100,213.456l', false], + ['$100,213.456kk', false] ]; test.expect(tests.length); for(var i=0; i Date: Thu, 6 Mar 2014 00:44:14 +0530 Subject: [PATCH 011/150] Removed triple negations from all conditions. Do not know why I put them there in the first place -.- --- numeral.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/numeral.js b/numeral.js index 34298772..f20faa59 100644 --- a/numeral.js +++ b/numeral.js @@ -550,18 +550,18 @@ _thousandRegEx = new RegExp(_thousandSep + '{2}'); - if ( !! !val.match(/[^\d.,]/g)) { + 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)); + 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+$/)); + 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 ( !! _valArray[0].match(/^\d+.*\d$/) && !_valArray[0].match(_thousandRegEx) && !! _valArray[1].match(/^\d+$/)); } } } From 1693d44589a906bf05ff882a5cc90c05c176d69e Mon Sep 17 00:00:00 2001 From: Mudit Ameta Date: Thu, 6 Mar 2014 02:25:17 +0530 Subject: [PATCH 012/150] Fixed some formatting --- numeral.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numeral.js b/numeral.js index f20faa59..9607627c 100644 --- a/numeral.js +++ b/numeral.js @@ -550,7 +550,7 @@ _thousandRegEx = new RegExp(_thousandSep + '{2}'); - if ( !val.match(/[^\d.,]/g)) { + if (!val.match(/[^\d.,]/g)) { _valArray = val.split(_decimalSep); if (_valArray.length > 2) { return false; From 9805fda3627eda11bbc27d386fb7f952c7a94670 Mon Sep 17 00:00:00 2001 From: Joe Price Date: Wed, 23 Apr 2014 15:05:48 -0700 Subject: [PATCH 013/150] Fixes problem with many optional decimals When using a format with many optional decimals, insignificant trailing digits could be added to the number: Ex: numeral(3162.63).format('0.0[000000000000]') = "3162.6300000000001" Also changed numerals internal toFixed method to never return trailing decimal points. Also fixed a bug where an extra optional decimal was being added when using a specified abbreviation. --- min/numeral.min.js | 2 +- numeral.js | 31 +++++++++++++++++++++---------- tests/numeral/format.js | 6 +++++- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/min/numeral.min.js b/min/numeral.min.js index d17b5571..9cdfe1cb 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * 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(){function a(a){this._value=a}function b(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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}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(new RegExp(n+"a[KMBT]?"),""),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.indexOf(".")>-1?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 diff --git a/numeral.js b/numeral.js index 9f46ab65..e8a92ace 100644 --- a/numeral.js +++ b/numeral.js @@ -39,17 +39,29 @@ * 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), + function toFixed (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); + //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); + output = (roundingFunction(value * power) / power).toFixed(boundedPrecision); - if (optionals) { - optionalsRegExp = new RegExp('0{1,' + optionals + '}$'); + if (optionals > maxDecimals - boundedPrecision) { + optionalsRegExp = new RegExp('\\.?0{1,' + (optionals - (maxDecimals - boundedPrecision)) + '}$'); output = output.replace(optionalsRegExp, ''); } @@ -276,11 +288,10 @@ // check for space before abbreviation if (format.indexOf(' a') > -1) { abbr = ' '; - format = format.replace(' a', ''); - } else { - format = format.replace('a', ''); } + format = format.replace(new RegExp(abbr + 'a[KMBT]?'), ''); + if (abs >= Math.pow(10, 12) && !abbrForce || abbrT) { // trillion abbr = abbr + languages[currentLanguage].abbreviations.trillion; @@ -357,7 +368,7 @@ w = d.split('.')[0]; - if (d.split('.')[1].length) { + if (d.indexOf('.') > -1) { d = languages[currentLanguage].delimiters.decimal + d.split('.')[1]; } else { d = ''; diff --git a/tests/numeral/format.js b/tests/numeral/format.js index 53427ad4..08f81aa1 100644 --- a/tests/numeral/format.js +++ b/tests/numeral/format.js @@ -57,6 +57,9 @@ exports.format = { [-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'], [2000000000,'0.0a','2.0b'], [1230974,'0.0a','1.2m'], [1460,'0a','1k'], @@ -70,7 +73,8 @@ exports.format = { [-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'] + [-5444333222111, '0,0 aT', '-5 t'], + [123456, '0.0[0] aK', '123.46 k'], ], i; From b2b065d1f48b61dda4b4ff57f555b2edcb18b7f5 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Wed, 28 May 2014 20:51:36 -0700 Subject: [PATCH 014/150] update copyright year --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 145e65bc..f9810c58 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2012 Adam Draper +Copyright (c) 2014 Adam Draper Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation From 7f4cf2d514ff775d9588b7621ad81c2248e3bda3 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Wed, 28 May 2014 21:05:04 -0700 Subject: [PATCH 015/150] version grunt contrib uglify --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5e80aef9..acd5fbc8 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "devDependencies": { "uglify-js": "latest", "grunt": "latest", - "grunt-contrib-uglify": "latest", + "grunt-contrib-uglify": "~0.3.0", "grunt-contrib-jshint": "latest", "grunt-contrib-nodeunit": "~0.1.2", "grunt-contrib-concat": "~0.3.0" From c2c7887a57673fd11da9f885813fe3eb6ae07d65 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Wed, 28 May 2014 21:07:14 -0700 Subject: [PATCH 016/150] build --- languages.js | 1910 +++++++++++++++++++++++++------------------------- 1 file changed, 955 insertions(+), 955 deletions(-) diff --git a/languages.js b/languages.js index c442275a..2f502ea0 100644 --- a/languages.js +++ b/languages.js @@ -1,38 +1,38 @@ -/*! - * 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 : 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 @@ -67,923 +67,923 @@ 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); - } -}()); + +/*! + * 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); + } +}()); From a56cca426cf855f71c9477c5d664ecf3ac7c6eea Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Wed, 28 May 2014 21:12:58 -0700 Subject: [PATCH 017/150] remove node v0.8 from build testing --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0fedc343..384c4072 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: node_js node_js: - "0.10" - - "0.8" before_script: - npm install -g grunt-cli script: grunt travis --verbose \ No newline at end of file From 560668c6f0e11bbf2c1cf8d9c240ede5e56e77bf Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Wed, 28 May 2014 21:13:33 -0700 Subject: [PATCH 018/150] back to latest uglify --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index acd5fbc8..5e80aef9 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "devDependencies": { "uglify-js": "latest", "grunt": "latest", - "grunt-contrib-uglify": "~0.3.0", + "grunt-contrib-uglify": "latest", "grunt-contrib-jshint": "latest", "grunt-contrib-nodeunit": "~0.1.2", "grunt-contrib-concat": "~0.3.0" From 186a8a1c1b092cd61c134f01d3927c98f6b3b362 Mon Sep 17 00:00:00 2001 From: Andrea Bertin Date: Mon, 31 Mar 2014 17:36:20 +0200 Subject: [PATCH 019/150] Fix IETF language tag lookup The IETF specification says the language tags should be treated as case insensitive (see http://tools.ietf.org/html/bcp47#section-2.2.1) so we have to discard the case when saving the languages and performing the look-ups. --- numeral.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/numeral.js b/numeral.js index 9607627c..a1b7dfdd 100644 --- a/numeral.js +++ b/numeral.js @@ -419,6 +419,8 @@ if (!key) { return currentLanguage; } + + key = key.toLowerCase(); if (key && !values) { if (!languages[key]) { @@ -767,4 +769,4 @@ return numeral; }); } -}).call(this); \ No newline at end of file +}).call(this); From 85b8e04a4e9e02c1311a87f03108df325836cd67 Mon Sep 17 00:00:00 2001 From: Ove Andersen Date: Thu, 29 May 2014 13:04:45 +0200 Subject: [PATCH 020/150] Added norwegian translation --- languages.js | 38 +++++++++++++++ languages/no.js | 38 +++++++++++++++ min/languages.min.js | 5 ++ min/languages/no.min.js | 6 +++ min/numeral.min.js | 2 +- tests/languages/no.js | 101 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 189 insertions(+), 1 deletion(-) create mode 100644 languages/no.js create mode 100644 min/languages/no.min.js create mode 100644 tests/languages/no.js diff --git a/languages.js b/languages.js index cc2abc41..dd6c8883 100644 --- a/languages.js +++ b/languages.js @@ -671,6 +671,44 @@ this.numeral.language('nl-nl', language); } }()); +/*! + * numeral.js language configuration + * language : norwegian (bokmål) + * author : Ove Andersen : https://github.com/azzlack + */ +(function () { + var language = { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: 'kr' + } + }; + + // Node + if (typeof module !== 'undefined' && module.exports) { + module.exports = language; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { + this.numeral.language('nb-no', language); + this.numeral.language('nn-no', language); + this.numeral.language('no', language); + this.numeral.language('nb', language); + this.numeral.language('nn', language); + } +}()); /*! * numeral.js language configuration * language : polish (pl) diff --git a/languages/no.js b/languages/no.js new file mode 100644 index 00000000..5fc36203 --- /dev/null +++ b/languages/no.js @@ -0,0 +1,38 @@ +/*! + * numeral.js language configuration + * language : norwegian (bokmål) + * author : Ove Andersen : https://github.com/azzlack + */ +(function () { + var language = { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: 'kr' + } + }; + + // Node + if (typeof module !== 'undefined' && module.exports) { + module.exports = language; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { + this.numeral.language('nb-no', language); + this.numeral.language('nn-no', language); + this.numeral.language('no', language); + this.numeral.language('nb', language); + this.numeral.language('nn', language); + } +}()); \ No newline at end of file diff --git a/min/languages.min.js b/min/languages.min.js index 1207c5e6..07ed334f 100644 --- a/min/languages.min.js +++ b/min/languages.min.js @@ -97,6 +97,11 @@ function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand * 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 : norwegian (bokmål) + * author : Ove Andersen : https://github.com/azzlack + */ +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"kr"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&(this.numeral.language("nb-no",a),this.numeral.language("nn-no",a),this.numeral.language("no",a),this.numeral.language("nb",a),this.numeral.language("nn",a))}(),/*! * numeral.js language configuration * language : polish (pl) * author : Dominik Bulaj : https://github.com/dominikbulaj diff --git a/min/languages/no.min.js b/min/languages/no.min.js new file mode 100644 index 00000000..27207a54 --- /dev/null +++ b/min/languages/no.min.js @@ -0,0 +1,6 @@ +/*! + * numeral.js language configuration + * language : norwegian (bokmål) + * author : Ove Andersen : https://github.com/azzlack + */ +!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"kr"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&(this.numeral.language("nb-no",a),this.numeral.language("nn-no",a),this.numeral.language("no",a),this.numeral.language("nb",a),this.numeral.language("nn",a))}(); \ No newline at end of file diff --git a/min/numeral.min.js b/min/numeral.min.js index e798f2a9..95417962 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * 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"},m.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=m.languageData(b)}catch(k){i=m.languageData(m.language())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},"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(){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=a.toLowerCase(),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"},m.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=m.languageData(b)}catch(k){i=m.languageData(m.language())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},"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 diff --git a/tests/languages/no.js b/tests/languages/no.js new file mode 100644 index 00000000..b2409eee --- /dev/null +++ b/tests/languages/no.js @@ -0,0 +1,101 @@ +var numeral = require('../../numeral'), + language = require('../../languages/no'); + +numeral.language('nb-no', language); + +exports['language:nb-no'] = { + setUp: function (callback) { + numeral.language('nb-no'); + 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','kr1 000,23'], + [-1000.234,'($0,0)','(kr1 000)'], + [-1000.234,'$0.00','-kr1000,23'], + [1230974,'($0.00a)','kr1,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], + ['(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++) { + test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); + } + + test.done(); + } +}; \ No newline at end of file From 46e87e2548ac6e05ca76e1404f2b4c1fdf87df0d Mon Sep 17 00:00:00 2001 From: Peter deHaan Date: Sun, 24 May 2015 09:10:01 -0700 Subject: [PATCH 021/150] Update license attribute specifying the type and URL is deprecated: https://docs.npmjs.com/files/package.json#license http://npm1k.org/ --- package.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/package.json b/package.json index 5e80aef9..c40f2f62 100644 --- a/package.json +++ b/package.json @@ -27,11 +27,7 @@ "bugs": { "url": "https://github.com/adamwdraper/Numeral-js/issues" }, - "licenses": [ - { - "type": "MIT" - } - ], + "license": "MIT", "devDependencies": { "uglify-js": "latest", "grunt": "latest", From ac799789ae87fc0c48f8b4ab5e26402242dc5328 Mon Sep 17 00:00:00 2001 From: Etienne Boshoff Date: Thu, 20 Oct 2016 07:25:14 +0200 Subject: [PATCH 022/150] feat(language): Added South African currency to languages --- languages/en-za.js | 38 +++++++++++++++ tests/languages/en-za.js | 101 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 languages/en-za.js create mode 100644 tests/languages/en-za.js diff --git a/languages/en-za.js b/languages/en-za.js new file mode 100644 index 00000000..0a57b45c --- /dev/null +++ b/languages/en-za.js @@ -0,0 +1,38 @@ +/*! + * numeral.js language configuration + * language : english south africa (uk) + * author : Etienne Boshoff : etienne@zailab.com + */ +(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: 'R' + } + }; + + // Node + if (typeof module !== 'undefined' && module.exports) { + module.exports = language; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { + this.numeral.language('en-za', language); + } +}()); \ No newline at end of file diff --git a/tests/languages/en-za.js b/tests/languages/en-za.js new file mode 100644 index 00000000..66dcd1b4 --- /dev/null +++ b/tests/languages/en-za.js @@ -0,0 +1,101 @@ +var numeral = require('../../numeral'), + language = require('../../languages/en-za'); + +numeral.language('en-za', language); + +exports['language:en-za'] = { + setUp: function (callback) { + numeral.language('en-za'); + 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','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++) { + 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], + ['(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++) { + test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); + } + + test.done(); + } +}; \ No newline at end of file From acd1cf5daafb88fd36445db3fff9435f722779f8 Mon Sep 17 00:00:00 2001 From: Vitaly Date: Tue, 8 Nov 2016 18:15:21 +0400 Subject: [PATCH 023/150] Russian abbreviations correction --- languages/ru.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/languages/ru.js b/languages/ru.js index 14d9e83a..186d73da 100644 --- a/languages/ru.js +++ b/languages/ru.js @@ -11,9 +11,9 @@ }, abbreviations: { thousand: 'тыс.', - million: 'млн', - billion: 'b', - trillion: 't' + million: 'млн.', + billion: 'млрд.', + trillion: 'трлн.' }, ordinal: function () { // not ideal, but since in Russian it can taken on From cef262baf9c9d63aba306f71a99cf0a367a7a9e0 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 17 Nov 2016 21:31:08 -0800 Subject: [PATCH 024/150] svg --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 79f6e0e9..b6c45c64 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,13 @@ 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/) # Contributing @@ -34,7 +34,7 @@ Please submit all pull requests to the `develop` branch. 7. Submit a pull request to the `develop` branch. -### Languages +### Languages 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. From ca194b868981d32aadc52592ff5406d5d6d27b02 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 17 Nov 2016 22:58:09 -0800 Subject: [PATCH 025/150] update build --- Gruntfile.js | 2 +- languages.js | 50 +++++++++++++++++++------------------- languages/be-nl.js | 2 +- languages/chs.js | 2 +- languages/cs.js | 2 +- languages/da-dk.js | 2 +- languages/de-ch.js | 2 +- languages/de.js | 2 +- languages/en-gb.js | 2 +- languages/es-ES.js | 2 +- languages/es.js | 2 +- languages/et.js | 2 +- languages/fi.js | 2 +- languages/fr-CA.js | 2 +- languages/fr-ch.js | 2 +- languages/fr.js | 2 +- languages/hu.js | 2 +- languages/it.js | 2 +- languages/ja.js | 2 +- languages/nl-nl.js | 2 +- languages/pl.js | 2 +- languages/pt-br.js | 2 +- languages/pt-pt.js | 2 +- languages/ru.js | 2 +- languages/sk.js | 2 +- languages/th.js | 2 +- languages/tr.js | 2 +- min/languages.min.js | 50 +++++++++++++++++++------------------- min/languages/be-nl.min.js | 4 +-- min/languages/chs.min.js | 4 +-- min/languages/cs.min.js | 2 +- min/languages/da-dk.min.js | 4 +-- min/languages/de-ch.min.js | 4 +-- min/languages/de.min.js | 4 +-- min/languages/en-gb.min.js | 2 +- min/languages/es-ES.min.js | 2 +- min/languages/es.min.js | 2 +- min/languages/et.min.js | 4 +-- min/languages/fi.min.js | 4 +-- min/languages/fr-CA.min.js | 2 +- min/languages/fr-ch.min.js | 2 +- min/languages/fr.min.js | 2 +- min/languages/hu.min.js | 4 +-- min/languages/it.min.js | 4 +-- min/languages/ja.min.js | 4 +-- min/languages/nl-nl.min.js | 4 +-- min/languages/pl.min.js | 4 +-- min/languages/pt-br.min.js | 4 +-- min/languages/pt-pt.min.js | 4 +-- min/languages/ru.min.js | 2 +- min/languages/sk.min.js | 2 +- min/languages/th.min.js | 4 +-- min/languages/tr.min.js | 2 +- min/numeral.min.js | 4 +-- numeral.js | 32 ++++++++++++------------ package.json | 4 +-- 56 files changed, 136 insertions(+), 136 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index b90e008c..4e0e1bf1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -88,4 +88,4 @@ module.exports = function(grunt) { // Travis CI task. grunt.registerTask('travis', ['test']); -}; \ No newline at end of file +}; diff --git a/languages.js b/languages.js index 2f502ea0..3aab651d 100644 --- a/languages.js +++ b/languages.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : belgium-dutch (be-nl) * author : Dieter Luypaert : https://github.com/moeriki @@ -33,7 +33,7 @@ this.numeral.language('be-nl', language); } }()); -/*! +/*! @preserve * numeral.js language configuration * language : simplified chinese * author : badplum : https://github.com/badplum @@ -68,7 +68,7 @@ } }()); -/*! +/*! @preserve * numeral.js language configuration * language : czech (cs) * author : Anatoli Papirovski : https://github.com/apapirovski @@ -103,7 +103,7 @@ } }()); -/*! +/*! @preserve * numeral.js language configuration * language : danish denmark (dk) * author : Michael Storgaard : https://github.com/mstorgaard @@ -137,7 +137,7 @@ this.numeral.language('da-dk', language); } }()); -/*! +/*! @preserve * 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) @@ -171,7 +171,7 @@ this.numeral.language('de-ch', language); } }()); -/*! +/*! @preserve * numeral.js language configuration * language : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium * author : Marco Krage : https://github.com/sinky @@ -205,7 +205,7 @@ this.numeral.language('de', language); } }()); -/*! +/*! @preserve * numeral.js language configuration * language : english united kingdom (uk) * author : Dan Ristic : https://github.com/dristic @@ -243,7 +243,7 @@ this.numeral.language('en-gb', language); } }()); -/*! +/*! @preserve * numeral.js language configuration * language : spanish Spain * author : Hernan Garcia : https://github.com/hgarcia @@ -283,7 +283,7 @@ } }()); -/*! +/*! @preserve * numeral.js language configuration * language : spanish * author : Hernan Garcia : https://github.com/hgarcia @@ -323,7 +323,7 @@ } }()); -/*! +/*! @preserve * numeral.js language configuration * language : Estonian * author : Illimar Tambek : https://github.com/ragulka @@ -361,7 +361,7 @@ } }()); -/*! +/*! @preserve * numeral.js language configuration * language : Finnish * author : Sami Saada : https://github.com/samitheberber @@ -396,7 +396,7 @@ } }()); -/*! +/*! @preserve * numeral.js language configuration * language : french (Canada) (fr-CA) * author : Léo Renaud-Allaire : https://github.com/renaudleo @@ -430,7 +430,7 @@ this.numeral.language('fr-CA', language); } }()); -/*! +/*! @preserve * numeral.js language configuration * language : french (fr-ch) * author : Adam Draper : https://github.com/adamwdraper @@ -465,7 +465,7 @@ } }()); -/*! +/*! @preserve * numeral.js language configuration * language : french (fr) * author : Adam Draper : https://github.com/adamwdraper @@ -499,7 +499,7 @@ this.numeral.language('fr', language); } }()); -/*! +/*! @preserve * numeral.js language configuration * language : Hungarian (hu) * author : Peter Bakondy : https://github.com/pbakondy @@ -533,7 +533,7 @@ this.numeral.language('hu', language); } }()); -/*! +/*! @preserve * numeral.js language configuration * language : italian Italy (it) * author : Giacomo Trombi : http://cinquepunti.it @@ -567,7 +567,7 @@ this.numeral.language('it', language); } }()); -/*! +/*! @preserve * numeral.js language configuration * language : japanese * author : teppeis : https://github.com/teppeis @@ -602,7 +602,7 @@ } }()); -/*! +/*! @preserve * numeral.js language configuration * language : netherlands-dutch (nl-nl) * author : Dave Clayton : https://github.com/davedx @@ -637,7 +637,7 @@ this.numeral.language('nl-nl', language); } }()); -/*! +/*! @preserve * numeral.js language configuration * language : polish (pl) * author : Dominik Bulaj : https://github.com/dominikbulaj @@ -671,7 +671,7 @@ this.numeral.language('pl', language); } }()); -/*! +/*! @preserve * numeral.js language configuration * language : portuguese brazil (pt-br) * author : Ramiro Varandas Jr : https://github.com/ramirovjr @@ -705,7 +705,7 @@ this.numeral.language('pt-br', language); } }()); -/*! +/*! @preserve * numeral.js language configuration * language : portuguese (pt-pt) * author : Diogo Resende : https://github.com/dresende @@ -776,7 +776,7 @@ } }()); -/*! +/*! @preserve * numeral.js language configuration * language : russian (ru) * author : Anatoli Papirovski : https://github.com/apapirovski @@ -814,7 +814,7 @@ } }()); -/*! +/*! @preserve * numeral.js language configuration * language : slovak (sk) * author : Ahmed Al Hafoudh : http://www.freevision.sk @@ -849,7 +849,7 @@ } }()); -/*! +/*! @preserve * numeral.js language configuration * language : thai (th) * author : Sathit Jittanupat : https://github.com/jojosati @@ -884,7 +884,7 @@ } }()); -/*! +/*! @preserve * 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 diff --git a/languages/be-nl.js b/languages/be-nl.js index b26d840a..78d8cd06 100644 --- a/languages/be-nl.js +++ b/languages/be-nl.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : belgium-dutch (be-nl) * author : Dieter Luypaert : https://github.com/moeriki diff --git a/languages/chs.js b/languages/chs.js index 9c54f2f1..ab88f61d 100644 --- a/languages/chs.js +++ b/languages/chs.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : simplified chinese * author : badplum : https://github.com/badplum diff --git a/languages/cs.js b/languages/cs.js index 248a9118..15aa7121 100644 --- a/languages/cs.js +++ b/languages/cs.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : czech (cs) * author : Anatoli Papirovski : https://github.com/apapirovski diff --git a/languages/da-dk.js b/languages/da-dk.js index 27078741..ae7b41ec 100644 --- a/languages/da-dk.js +++ b/languages/da-dk.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : danish denmark (dk) * author : Michael Storgaard : https://github.com/mstorgaard diff --git a/languages/de-ch.js b/languages/de-ch.js index 29187385..cd5afa5b 100644 --- a/languages/de-ch.js +++ b/languages/de-ch.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * 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) diff --git a/languages/de.js b/languages/de.js index d6bd5f07..422408bb 100644 --- a/languages/de.js +++ b/languages/de.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium * author : Marco Krage : https://github.com/sinky diff --git a/languages/en-gb.js b/languages/en-gb.js index 5b99c7a8..f1bac3e3 100644 --- a/languages/en-gb.js +++ b/languages/en-gb.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : english united kingdom (uk) * author : Dan Ristic : https://github.com/dristic diff --git a/languages/es-ES.js b/languages/es-ES.js index a62abc07..7df615e4 100644 --- a/languages/es-ES.js +++ b/languages/es-ES.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : spanish Spain * author : Hernan Garcia : https://github.com/hgarcia diff --git a/languages/es.js b/languages/es.js index b078fe55..d084de38 100644 --- a/languages/es.js +++ b/languages/es.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : spanish * author : Hernan Garcia : https://github.com/hgarcia diff --git a/languages/et.js b/languages/et.js index f45dd7de..cb81dd67 100644 --- a/languages/et.js +++ b/languages/et.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : Estonian * author : Illimar Tambek : https://github.com/ragulka diff --git a/languages/fi.js b/languages/fi.js index 2e247431..a8c16915 100644 --- a/languages/fi.js +++ b/languages/fi.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : Finnish * author : Sami Saada : https://github.com/samitheberber diff --git a/languages/fr-CA.js b/languages/fr-CA.js index ea1c9a50..3e95f0cd 100644 --- a/languages/fr-CA.js +++ b/languages/fr-CA.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : french (Canada) (fr-CA) * author : Léo Renaud-Allaire : https://github.com/renaudleo diff --git a/languages/fr-ch.js b/languages/fr-ch.js index 64ffbd22..40072e49 100644 --- a/languages/fr-ch.js +++ b/languages/fr-ch.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : french (fr-ch) * author : Adam Draper : https://github.com/adamwdraper diff --git a/languages/fr.js b/languages/fr.js index 960defad..d2b3dd69 100644 --- a/languages/fr.js +++ b/languages/fr.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : french (fr) * author : Adam Draper : https://github.com/adamwdraper diff --git a/languages/hu.js b/languages/hu.js index 9710ac23..dc2119e7 100644 --- a/languages/hu.js +++ b/languages/hu.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : Hungarian (hu) * author : Peter Bakondy : https://github.com/pbakondy diff --git a/languages/it.js b/languages/it.js index 5bc1f9c3..502c7b9b 100644 --- a/languages/it.js +++ b/languages/it.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : italian Italy (it) * author : Giacomo Trombi : http://cinquepunti.it diff --git a/languages/ja.js b/languages/ja.js index d0816b27..d7d41aa9 100644 --- a/languages/ja.js +++ b/languages/ja.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : japanese * author : teppeis : https://github.com/teppeis diff --git a/languages/nl-nl.js b/languages/nl-nl.js index ab577867..5ea7354a 100644 --- a/languages/nl-nl.js +++ b/languages/nl-nl.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : netherlands-dutch (nl-nl) * author : Dave Clayton : https://github.com/davedx diff --git a/languages/pl.js b/languages/pl.js index 5cb6056e..3ffd9011 100644 --- a/languages/pl.js +++ b/languages/pl.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : polish (pl) * author : Dominik Bulaj : https://github.com/dominikbulaj diff --git a/languages/pt-br.js b/languages/pt-br.js index 51ab7dab..c9ff8424 100644 --- a/languages/pt-br.js +++ b/languages/pt-br.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : portuguese brazil (pt-br) * author : Ramiro Varandas Jr : https://github.com/ramirovjr diff --git a/languages/pt-pt.js b/languages/pt-pt.js index cce9a271..83a174e0 100644 --- a/languages/pt-pt.js +++ b/languages/pt-pt.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : portuguese (pt-pt) * author : Diogo Resende : https://github.com/dresende diff --git a/languages/ru.js b/languages/ru.js index 14d9e83a..2a9ea0ec 100644 --- a/languages/ru.js +++ b/languages/ru.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : russian (ru) * author : Anatoli Papirovski : https://github.com/apapirovski diff --git a/languages/sk.js b/languages/sk.js index ac48faf7..6bae7213 100644 --- a/languages/sk.js +++ b/languages/sk.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : slovak (sk) * author : Ahmed Al Hafoudh : http://www.freevision.sk diff --git a/languages/th.js b/languages/th.js index ca73c7d7..f1f8a214 100644 --- a/languages/th.js +++ b/languages/th.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : thai (th) * author : Sathit Jittanupat : https://github.com/jojosati diff --git a/languages/tr.js b/languages/tr.js index 79b9a498..1f333876 100644 --- a/languages/tr.js +++ b/languages/tr.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * 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 diff --git a/min/languages.min.js b/min/languages.min.js index 11252868..dc2861e8 100644 --- a/min/languages.min.js +++ b/min/languages.min.js @@ -1,49 +1,49 @@ -/*! +/*! @preserve * 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)}(),/*! +!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&&b<=1||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)}(),/*! @preserve * 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)}(),/*! +function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("chs",a)}(),/*! @preserve * 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)}(),/*! +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)}(),/*! @preserve * 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)}(),/*! +function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mia",trillion:"b"},ordinal:function(a){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)}(),/*! @preserve * 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)}(),/*! +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){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)}(),/*! @preserve * 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)}(),/*! +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("de",a)}(),/*! @preserve * 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)}(),/*! +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)}(),/*! @preserve * 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)}(),/*! +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)}(),/*! @preserve * 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)}(),/*! +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)}(),/*! @preserve * numeral.js language configuration * language : Estonian * author : Illimar Tambek : https://github.com/ragulka @@ -51,77 +51,77 @@ function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand * 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)}(),/*! +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("et",a)}(),/*! @preserve * 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)}(),/*! +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("fi",a)}(),/*! @preserve * 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)}(),/*! +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)}(),/*! @preserve * 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)}(),/*! +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)}(),/*! @preserve * 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)}(),/*! +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)}(),/*! @preserve * 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)}(),/*! +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){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)}(),/*! @preserve * 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)}(),/*! +function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("it",a)}(),/*! @preserve * 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)}(),/*! +function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("ja",a)}(),/*! @preserve * 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)}(),/*! +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&&b<=1||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)}(),/*! @preserve * 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)}(),/*! +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){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)}(),/*! @preserve * 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)}(),/*! +function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mil",million:"milhões",billion:"b",trillion:"t"},ordinal:function(a){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)}(),/*! @preserve * 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)}(),/*! +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){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)}(),/*! @preserve * 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)}(),/*! +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)}(),/*! @preserve * 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)}(),/*! +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)}(),/*! @preserve * 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)}(),/*! +function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("th",a)}(),/*! @preserve * 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 diff --git a/min/languages/be-nl.min.js b/min/languages/be-nl.min.js index d17a383f..a4cb5c36 100644 --- a/min/languages/be-nl.min.js +++ b/min/languages/be-nl.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * 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 +!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&&b<=1||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 index 6d375969..18840388 100644 --- a/min/languages/chs.min.js +++ b/min/languages/chs.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * 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 +!function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){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 index b1d1ff57..0fddd92d 100644 --- a/min/languages/cs.min.js +++ b/min/languages/cs.min.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : czech (cs) * author : Anatoli Papirovski : https://github.com/apapirovski diff --git a/min/languages/da-dk.min.js b/min/languages/da-dk.min.js index 19f1a7b3..5697c3fe 100644 --- a/min/languages/da-dk.min.js +++ b/min/languages/da-dk.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * 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 +!function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mia",trillion:"b"},ordinal:function(a){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 index 5279f430..8f359117 100644 --- a/min/languages/de-ch.min.js +++ b/min/languages/de-ch.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * 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 +!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){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 index 0c54a30a..6911e0c5 100644 --- a/min/languages/de.min.js +++ b/min/languages/de.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * 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 +!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){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 index b6d97446..9938bf28 100644 --- a/min/languages/en-gb.min.js +++ b/min/languages/en-gb.min.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : english united kingdom (uk) * author : Dan Ristic : https://github.com/dristic diff --git a/min/languages/es-ES.min.js b/min/languages/es-ES.min.js index 3f936943..16b80447 100644 --- a/min/languages/es-ES.min.js +++ b/min/languages/es-ES.min.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : spanish Spain * author : Hernan Garcia : https://github.com/hgarcia diff --git a/min/languages/es.min.js b/min/languages/es.min.js index 40ac3354..6dd1e380 100644 --- a/min/languages/es.min.js +++ b/min/languages/es.min.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : spanish * author : Hernan Garcia : https://github.com/hgarcia diff --git a/min/languages/et.min.js b/min/languages/et.min.js index cf9f7e38..9376cdc8 100644 --- a/min/languages/et.min.js +++ b/min/languages/et.min.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : Estonian * author : Illimar Tambek : https://github.com/ragulka @@ -6,4 +6,4 @@ * 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 +!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){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 index c841275f..821e7a00 100644 --- a/min/languages/fi.min.js +++ b/min/languages/fi.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * 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 +!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){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 index b687e50e..60e58b6f 100644 --- a/min/languages/fr-CA.min.js +++ b/min/languages/fr-CA.min.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : french (Canada) (fr-CA) * author : Léo Renaud-Allaire : https://github.com/renaudleo diff --git a/min/languages/fr-ch.min.js b/min/languages/fr-ch.min.js index 6ef1af8b..b354bcd3 100644 --- a/min/languages/fr-ch.min.js +++ b/min/languages/fr-ch.min.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : french (fr-ch) * author : Adam Draper : https://github.com/adamwdraper diff --git a/min/languages/fr.min.js b/min/languages/fr.min.js index 3cc2e70d..fdc97c19 100644 --- a/min/languages/fr.min.js +++ b/min/languages/fr.min.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : french (fr) * author : Adam Draper : https://github.com/adamwdraper diff --git a/min/languages/hu.min.js b/min/languages/hu.min.js index 084551b2..52d5d94b 100644 --- a/min/languages/hu.min.js +++ b/min/languages/hu.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * 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 +!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){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 index 186a70d0..16f30ac4 100644 --- a/min/languages/it.min.js +++ b/min/languages/it.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * 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 +!function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){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 index 99d8e74b..a4a77164 100644 --- a/min/languages/ja.min.js +++ b/min/languages/ja.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * 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 +!function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){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 index 3321d4a0..1c22e84b 100644 --- a/min/languages/nl-nl.min.js +++ b/min/languages/nl-nl.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * 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 +!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&&b<=1||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 index e0875827..7faaa0d1 100644 --- a/min/languages/pl.min.js +++ b/min/languages/pl.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * 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 +!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){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 index 3f57b0c6..67835eb8 100644 --- a/min/languages/pt-br.min.js +++ b/min/languages/pt-br.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * 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 +!function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mil",million:"milhões",billion:"b",trillion:"t"},ordinal:function(a){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 index cd707074..c85431f1 100644 --- a/min/languages/pt-pt.min.js +++ b/min/languages/pt-pt.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * 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 +!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){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.min.js b/min/languages/ru.min.js index 6a3762f3..043efbaa 100644 --- a/min/languages/ru.min.js +++ b/min/languages/ru.min.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : russian (ru) * author : Anatoli Papirovski : https://github.com/apapirovski diff --git a/min/languages/sk.min.js b/min/languages/sk.min.js index e68e4dc7..6b75a44e 100644 --- a/min/languages/sk.min.js +++ b/min/languages/sk.min.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : slovak (sk) * author : Ahmed Al Hafoudh : http://www.freevision.sk diff --git a/min/languages/th.min.js b/min/languages/th.min.js index c165048c..cbd6ce5c 100644 --- a/min/languages/th.min.js +++ b/min/languages/th.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * 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 +!function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){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 index 265d16d6..9d9e0cbc 100644 --- a/min/languages/tr.min.js +++ b/min/languages/tr.min.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * 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 diff --git a/min/numeral.min.js b/min/numeral.min.js index d17b5571..be8dbe7d 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -1,8 +1,8 @@ -/*! +/*! @preserve * numeral.js * version : 1.5.3 * 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(){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));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),f<=1?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(f-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+":"+(c<10?"0"+c:c)+":"+(d<10?"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&&a0&&(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,d,e){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,d,e){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,c,d){var e=l(a,b);return a*e*(b*e)/(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=l(a,b);return a*e/(b*e)}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 diff --git a/numeral.js b/numeral.js index 9f46ab65..514d56ce 100644 --- a/numeral.js +++ b/numeral.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js * version : 1.5.3 * author : Adam Draper @@ -43,7 +43,7 @@ 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); @@ -188,7 +188,7 @@ } output = formatNumber(value, format, roundingFunction); - + if (output.indexOf(')') > -1 ) { output = output.split(''); output.splice(-1, 0, space + '%'); @@ -433,7 +433,7 @@ 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. @@ -441,11 +441,11 @@ if (!key) { return languages[currentLanguage]; } - + if (!languages[key]) { throw new Error('Unknown language : ' + key); } - + return languages[key]; }; @@ -502,14 +502,14 @@ 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'); } @@ -543,7 +543,7 @@ }; } - + /** * Computes the multiplier necessary to make x >= 1, * effectively eliminating miscalculations caused by @@ -569,7 +569,7 @@ mn = multiplier(next); return mp > mn ? mp : mn; }, -Infinity); - } + } /************************************ @@ -584,15 +584,15 @@ }, format : function (inputString, roundingFunction) { - return formatNumeral(this, - inputString ? inputString : defaultFormat, + return formatNumeral(this, + inputString ? inputString : defaultFormat, (roundingFunction !== undefined) ? roundingFunction : Math.round ); }, unformat : function (inputString) { - if (Object.prototype.toString.call(inputString) === '[object Number]') { - return inputString; + if (Object.prototype.toString.call(inputString) === '[object Number]') { + return inputString; } return unformatNumeral(this, inputString ? inputString : defaultFormat); }, @@ -624,7 +624,7 @@ function cback(accum, curr, currI, O) { return accum - corrFactor * curr; } - this._value = [value].reduce(cback, this._value * corrFactor) / corrFactor; + this._value = [value].reduce(cback, this._value * corrFactor) / corrFactor; return this; }, @@ -643,7 +643,7 @@ var corrFactor = correctionFactor(accum, curr); return (accum * corrFactor) / (curr * corrFactor); } - this._value = [this._value, value].reduce(cback); + this._value = [this._value, value].reduce(cback); return this; }, diff --git a/package.json b/package.json index 5e80aef9..ecaa7447 100644 --- a/package.json +++ b/package.json @@ -37,8 +37,8 @@ "grunt": "latest", "grunt-contrib-uglify": "latest", "grunt-contrib-jshint": "latest", - "grunt-contrib-nodeunit": "~0.1.2", - "grunt-contrib-concat": "~0.3.0" + "grunt-contrib-nodeunit": "1.0.0", + "grunt-contrib-concat": "1.0.1" }, "scripts": { "test": "grunt" From 0ebfb9461a4f923a213fb9f207c6b83fcdf6a533 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 17 Nov 2016 23:03:33 -0800 Subject: [PATCH 026/150] upgrade node versions for travis --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0fedc343..f6a53c30 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: node_js node_js: - - "0.10" - - "0.8" + - "6.x" + - "4.x" before_script: - npm install -g grunt-cli -script: grunt travis --verbose \ No newline at end of file +script: grunt travis --verbose From 7ffdffb16f208d473dd802e074b826608d50a026 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 17 Nov 2016 23:08:54 -0800 Subject: [PATCH 027/150] travis node version --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f6a53c30..f22dff0d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: node_js node_js: - - "6.x" - - "4.x" + - "6" + - "4" before_script: - npm install -g grunt-cli script: grunt travis --verbose From bd7e8e2f3627c961edb2663c7862c9b865a5db91 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 17 Nov 2016 23:25:16 -0800 Subject: [PATCH 028/150] Revert "Merge branch 'master' into develop" This reverts commit 4d7532018f825caa706a3c6f5611b64bf97e9b3a, reversing changes made to db869414232af71a6f780b4e7f23eceb189c0d1d. --- .travis.yml | 7 +---- Gruntfile.js | 2 +- README.md | 9 +++---- languages.js | 52 ++++++++++++++++++-------------------- languages/be-nl.js | 2 +- languages/chs.js | 2 +- languages/cs.js | 2 +- languages/da-dk.js | 2 +- languages/de-ch.js | 2 +- languages/de.js | 2 +- languages/en-gb.js | 2 +- languages/es-ES.js | 2 +- languages/es.js | 2 +- languages/et.js | 2 +- languages/fi.js | 2 +- languages/fr-CA.js | 2 +- languages/fr-ch.js | 2 +- languages/fr.js | 2 +- languages/hu.js | 2 +- languages/it.js | 2 +- languages/ja.js | 2 +- languages/nl-nl.js | 2 +- languages/pl.js | 2 +- languages/pt-br.js | 2 +- languages/pt-pt.js | 2 +- languages/ru.js | 2 +- languages/sk.js | 2 +- languages/th.js | 2 +- languages/tr.js | 2 +- min/languages.min.js | 52 ++++++++++++++++++-------------------- min/languages/be-nl.min.js | 4 +-- min/languages/chs.min.js | 4 +-- min/languages/cs.min.js | 2 +- min/languages/da-dk.min.js | 4 +-- min/languages/de-ch.min.js | 4 +-- min/languages/de.min.js | 4 +-- min/languages/en-gb.min.js | 2 +- min/languages/es-ES.min.js | 2 +- min/languages/es.min.js | 2 +- min/languages/et.min.js | 4 +-- min/languages/fi.min.js | 4 +-- min/languages/fr-CA.min.js | 2 +- min/languages/fr-ch.min.js | 2 +- min/languages/fr.min.js | 2 +- min/languages/hu.min.js | 4 +-- min/languages/it.min.js | 4 +-- min/languages/ja.min.js | 4 +-- min/languages/nl-nl.min.js | 4 +-- min/languages/pl.min.js | 4 +-- min/languages/pt-br.min.js | 4 +-- min/languages/pt-pt.min.js | 4 +-- min/languages/ru.min.js | 2 +- min/languages/sk.min.js | 2 +- min/languages/th.min.js | 4 +-- min/languages/tr.min.js | 2 +- min/numeral.min.js | 8 ++---- numeral.js | 17 +------------ package.json | 4 +-- 58 files changed, 123 insertions(+), 158 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5f55c505..384c4072 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,6 @@ language: node_js node_js: -<<<<<<< HEAD - "0.10" -======= - - "6" - - "4" ->>>>>>> master before_script: - npm install -g grunt-cli -script: grunt travis --verbose +script: grunt travis --verbose \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index 4e0e1bf1..b90e008c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -88,4 +88,4 @@ module.exports = function(grunt) { // Travis CI task. grunt.registerTask('travis', ['test']); -}; +}; \ No newline at end of file diff --git a/README.md b/README.md index b6c45c64..948781cb 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,10 @@ A javascript library for formatting and manipulating numbers. # Travis Build Status -Master [![Build Status](https://api.travis-ci.org/adamwdraper/Numeral-js.svg)](https://travis-ci.org/adamwdraper/Numeral-js) +Master [![Build Status](https://api.travis-ci.org/adamwdraper/Numeral-js.png)](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) +Develop [![Build Status](https://travis-ci.org/adamwdraper/Numeral-js.png?branch=develop)](https://travis-ci.org/adamwdraper/Numeral-js) -# NPM - -[![NPM](https://nodei.co/npm/numeral.svg?downloads=true)](https://nodei.co/npm/numeral/) # Contributing @@ -34,7 +31,7 @@ Please submit all pull requests to the `develop` branch. 7. Submit a pull request to the `develop` branch. -### Languages +### Languages 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. diff --git a/languages.js b/languages.js index b69c985c..cc2abc41 100644 --- a/languages.js +++ b/languages.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : belgium-dutch (be-nl) * author : Dieter Luypaert : https://github.com/moeriki @@ -33,7 +33,7 @@ this.numeral.language('be-nl', language); } }()); -/*! @preserve +/*! * numeral.js language configuration * language : simplified chinese * author : badplum : https://github.com/badplum @@ -68,7 +68,7 @@ } }()); -/*! @preserve +/*! * numeral.js language configuration * language : czech (cs) * author : Anatoli Papirovski : https://github.com/apapirovski @@ -103,7 +103,7 @@ } }()); -/*! @preserve +/*! * numeral.js language configuration * language : danish denmark (dk) * author : Michael Storgaard : https://github.com/mstorgaard @@ -137,7 +137,7 @@ this.numeral.language('da-dk', language); } }()); -/*! @preserve +/*! * 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) @@ -171,7 +171,7 @@ this.numeral.language('de-ch', language); } }()); -/*! @preserve +/*! * numeral.js language configuration * language : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium * author : Marco Krage : https://github.com/sinky @@ -205,7 +205,7 @@ this.numeral.language('de', language); } }()); -/*! @preserve +/*! * numeral.js language configuration * language : english united kingdom (uk) * author : Dan Ristic : https://github.com/dristic @@ -243,7 +243,7 @@ this.numeral.language('en-gb', language); } }()); -/*! @preserve +/*! * numeral.js language configuration * language : spanish Spain * author : Hernan Garcia : https://github.com/hgarcia @@ -283,7 +283,7 @@ } }()); -/*! @preserve +/*! * numeral.js language configuration * language : spanish * author : Hernan Garcia : https://github.com/hgarcia @@ -323,7 +323,7 @@ } }()); -/*! @preserve +/*! * numeral.js language configuration * language : Estonian * author : Illimar Tambek : https://github.com/ragulka @@ -361,7 +361,7 @@ } }()); -/*! @preserve +/*! * numeral.js language configuration * language : Finnish * author : Sami Saada : https://github.com/samitheberber @@ -396,7 +396,7 @@ } }()); -/*! @preserve +/*! * numeral.js language configuration * language : french (Canada) (fr-CA) * author : Léo Renaud-Allaire : https://github.com/renaudleo @@ -430,7 +430,7 @@ this.numeral.language('fr-CA', language); } }()); -/*! @preserve +/*! * numeral.js language configuration * language : french (fr-ch) * author : Adam Draper : https://github.com/adamwdraper @@ -465,7 +465,7 @@ } }()); -/*! @preserve +/*! * numeral.js language configuration * language : french (fr) * author : Adam Draper : https://github.com/adamwdraper @@ -499,7 +499,7 @@ this.numeral.language('fr', language); } }()); -/*! @preserve +/*! * numeral.js language configuration * language : Hungarian (hu) * author : Peter Bakondy : https://github.com/pbakondy @@ -533,7 +533,7 @@ this.numeral.language('hu', language); } }()); -/*! @preserve +/*! * numeral.js language configuration * language : italian Italy (it) * author : Giacomo Trombi : http://cinquepunti.it @@ -567,7 +567,7 @@ this.numeral.language('it', language); } }()); -/*! @preserve +/*! * numeral.js language configuration * language : japanese * author : teppeis : https://github.com/teppeis @@ -602,7 +602,6 @@ } }()); -<<<<<<< HEAD /*! * numeral.js language configuration * language : Latvian (lv) @@ -638,9 +637,6 @@ }()); /*! -======= -/*! @preserve ->>>>>>> master * numeral.js language configuration * language : netherlands-dutch (nl-nl) * author : Dave Clayton : https://github.com/davedx @@ -675,7 +671,7 @@ this.numeral.language('nl-nl', language); } }()); -/*! @preserve +/*! * numeral.js language configuration * language : polish (pl) * author : Dominik Bulaj : https://github.com/dominikbulaj @@ -709,7 +705,7 @@ this.numeral.language('pl', language); } }()); -/*! @preserve +/*! * numeral.js language configuration * language : portuguese brazil (pt-br) * author : Ramiro Varandas Jr : https://github.com/ramirovjr @@ -743,7 +739,7 @@ this.numeral.language('pt-br', language); } }()); -/*! @preserve +/*! * numeral.js language configuration * language : portuguese (pt-pt) * author : Diogo Resende : https://github.com/dresende @@ -814,7 +810,7 @@ } }()); -/*! @preserve +/*! * numeral.js language configuration * language : russian (ru) * author : Anatoli Papirovski : https://github.com/apapirovski @@ -852,7 +848,7 @@ } }()); -/*! @preserve +/*! * numeral.js language configuration * language : slovak (sk) * author : Ahmed Al Hafoudh : http://www.freevision.sk @@ -887,7 +883,7 @@ } }()); -/*! @preserve +/*! * numeral.js language configuration * language : thai (th) * author : Sathit Jittanupat : https://github.com/jojosati @@ -922,7 +918,7 @@ } }()); -/*! @preserve +/*! * 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 diff --git a/languages/be-nl.js b/languages/be-nl.js index 78d8cd06..b26d840a 100644 --- a/languages/be-nl.js +++ b/languages/be-nl.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : belgium-dutch (be-nl) * author : Dieter Luypaert : https://github.com/moeriki diff --git a/languages/chs.js b/languages/chs.js index ab88f61d..9c54f2f1 100644 --- a/languages/chs.js +++ b/languages/chs.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : simplified chinese * author : badplum : https://github.com/badplum diff --git a/languages/cs.js b/languages/cs.js index 15aa7121..248a9118 100644 --- a/languages/cs.js +++ b/languages/cs.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : czech (cs) * author : Anatoli Papirovski : https://github.com/apapirovski diff --git a/languages/da-dk.js b/languages/da-dk.js index ae7b41ec..27078741 100644 --- a/languages/da-dk.js +++ b/languages/da-dk.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : danish denmark (dk) * author : Michael Storgaard : https://github.com/mstorgaard diff --git a/languages/de-ch.js b/languages/de-ch.js index cd5afa5b..29187385 100644 --- a/languages/de-ch.js +++ b/languages/de-ch.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * 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) diff --git a/languages/de.js b/languages/de.js index 422408bb..d6bd5f07 100644 --- a/languages/de.js +++ b/languages/de.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium * author : Marco Krage : https://github.com/sinky diff --git a/languages/en-gb.js b/languages/en-gb.js index f1bac3e3..5b99c7a8 100644 --- a/languages/en-gb.js +++ b/languages/en-gb.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : english united kingdom (uk) * author : Dan Ristic : https://github.com/dristic diff --git a/languages/es-ES.js b/languages/es-ES.js index 7df615e4..a62abc07 100644 --- a/languages/es-ES.js +++ b/languages/es-ES.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : spanish Spain * author : Hernan Garcia : https://github.com/hgarcia diff --git a/languages/es.js b/languages/es.js index d084de38..b078fe55 100644 --- a/languages/es.js +++ b/languages/es.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : spanish * author : Hernan Garcia : https://github.com/hgarcia diff --git a/languages/et.js b/languages/et.js index cb81dd67..f45dd7de 100644 --- a/languages/et.js +++ b/languages/et.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : Estonian * author : Illimar Tambek : https://github.com/ragulka diff --git a/languages/fi.js b/languages/fi.js index a8c16915..2e247431 100644 --- a/languages/fi.js +++ b/languages/fi.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : Finnish * author : Sami Saada : https://github.com/samitheberber diff --git a/languages/fr-CA.js b/languages/fr-CA.js index 3e95f0cd..ea1c9a50 100644 --- a/languages/fr-CA.js +++ b/languages/fr-CA.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : french (Canada) (fr-CA) * author : Léo Renaud-Allaire : https://github.com/renaudleo diff --git a/languages/fr-ch.js b/languages/fr-ch.js index 40072e49..64ffbd22 100644 --- a/languages/fr-ch.js +++ b/languages/fr-ch.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : french (fr-ch) * author : Adam Draper : https://github.com/adamwdraper diff --git a/languages/fr.js b/languages/fr.js index d2b3dd69..960defad 100644 --- a/languages/fr.js +++ b/languages/fr.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : french (fr) * author : Adam Draper : https://github.com/adamwdraper diff --git a/languages/hu.js b/languages/hu.js index dc2119e7..9710ac23 100644 --- a/languages/hu.js +++ b/languages/hu.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : Hungarian (hu) * author : Peter Bakondy : https://github.com/pbakondy diff --git a/languages/it.js b/languages/it.js index 502c7b9b..5bc1f9c3 100644 --- a/languages/it.js +++ b/languages/it.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : italian Italy (it) * author : Giacomo Trombi : http://cinquepunti.it diff --git a/languages/ja.js b/languages/ja.js index d7d41aa9..d0816b27 100644 --- a/languages/ja.js +++ b/languages/ja.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : japanese * author : teppeis : https://github.com/teppeis diff --git a/languages/nl-nl.js b/languages/nl-nl.js index 5ea7354a..ab577867 100644 --- a/languages/nl-nl.js +++ b/languages/nl-nl.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : netherlands-dutch (nl-nl) * author : Dave Clayton : https://github.com/davedx diff --git a/languages/pl.js b/languages/pl.js index 3ffd9011..5cb6056e 100644 --- a/languages/pl.js +++ b/languages/pl.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : polish (pl) * author : Dominik Bulaj : https://github.com/dominikbulaj diff --git a/languages/pt-br.js b/languages/pt-br.js index c9ff8424..51ab7dab 100644 --- a/languages/pt-br.js +++ b/languages/pt-br.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : portuguese brazil (pt-br) * author : Ramiro Varandas Jr : https://github.com/ramirovjr diff --git a/languages/pt-pt.js b/languages/pt-pt.js index 83a174e0..cce9a271 100644 --- a/languages/pt-pt.js +++ b/languages/pt-pt.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : portuguese (pt-pt) * author : Diogo Resende : https://github.com/dresende diff --git a/languages/ru.js b/languages/ru.js index 2a9ea0ec..14d9e83a 100644 --- a/languages/ru.js +++ b/languages/ru.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : russian (ru) * author : Anatoli Papirovski : https://github.com/apapirovski diff --git a/languages/sk.js b/languages/sk.js index 6bae7213..ac48faf7 100644 --- a/languages/sk.js +++ b/languages/sk.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : slovak (sk) * author : Ahmed Al Hafoudh : http://www.freevision.sk diff --git a/languages/th.js b/languages/th.js index f1f8a214..ca73c7d7 100644 --- a/languages/th.js +++ b/languages/th.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : thai (th) * author : Sathit Jittanupat : https://github.com/jojosati diff --git a/languages/tr.js b/languages/tr.js index 1f333876..79b9a498 100644 --- a/languages/tr.js +++ b/languages/tr.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * 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 diff --git a/min/languages.min.js b/min/languages.min.js index 2d041f34..1207c5e6 100644 --- a/min/languages.min.js +++ b/min/languages.min.js @@ -1,49 +1,49 @@ -/*! @preserve +/*! * 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&&b<=1||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)}(),/*! @preserve +!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(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("chs",a)}(),/*! @preserve +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)}(),/*! @preserve +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(a){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)}(),/*! @preserve +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(a){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)}(),/*! @preserve +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(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("de",a)}(),/*! @preserve +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)}(),/*! @preserve +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)}(),/*! @preserve +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)}(),/*! @preserve +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 @@ -51,86 +51,82 @@ function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand * 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(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("et",a)}(),/*! @preserve +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(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("fi",a)}(),/*! @preserve +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)}(),/*! @preserve +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)}(),/*! @preserve +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)}(),/*! @preserve +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(a){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)}(),/*! @preserve +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(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("it",a)}(),/*! @preserve +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 */ -<<<<<<< HEAD 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 : Latvian (lv) * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks */ function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("lv",a)}(),/*! -======= -function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("ja",a)}(),/*! @preserve ->>>>>>> master * 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&&b<=1||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)}(),/*! @preserve +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(a){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)}(),/*! @preserve +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(a){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)}(),/*! @preserve +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(a){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)}(),/*! @preserve +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)}(),/*! @preserve +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)}(),/*! @preserve +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(a){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("th",a)}(),/*! @preserve +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 diff --git a/min/languages/be-nl.min.js b/min/languages/be-nl.min.js index a4cb5c36..d17a383f 100644 --- a/min/languages/be-nl.min.js +++ b/min/languages/be-nl.min.js @@ -1,6 +1,6 @@ -/*! @preserve +/*! * 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&&b<=1||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 +!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 index 18840388..6d375969 100644 --- a/min/languages/chs.min.js +++ b/min/languages/chs.min.js @@ -1,6 +1,6 @@ -/*! @preserve +/*! * 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(a){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 +!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 index 0fddd92d..b1d1ff57 100644 --- a/min/languages/cs.min.js +++ b/min/languages/cs.min.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : czech (cs) * author : Anatoli Papirovski : https://github.com/apapirovski diff --git a/min/languages/da-dk.min.js b/min/languages/da-dk.min.js index 5697c3fe..19f1a7b3 100644 --- a/min/languages/da-dk.min.js +++ b/min/languages/da-dk.min.js @@ -1,6 +1,6 @@ -/*! @preserve +/*! * 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(a){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 +!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 index 8f359117..5279f430 100644 --- a/min/languages/de-ch.min.js +++ b/min/languages/de-ch.min.js @@ -1,6 +1,6 @@ -/*! @preserve +/*! * 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(a){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 +!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 index 6911e0c5..0c54a30a 100644 --- a/min/languages/de.min.js +++ b/min/languages/de.min.js @@ -1,6 +1,6 @@ -/*! @preserve +/*! * 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(a){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 +!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 index 9938bf28..b6d97446 100644 --- a/min/languages/en-gb.min.js +++ b/min/languages/en-gb.min.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : english united kingdom (uk) * author : Dan Ristic : https://github.com/dristic diff --git a/min/languages/es-ES.min.js b/min/languages/es-ES.min.js index 16b80447..3f936943 100644 --- a/min/languages/es-ES.min.js +++ b/min/languages/es-ES.min.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : spanish Spain * author : Hernan Garcia : https://github.com/hgarcia diff --git a/min/languages/es.min.js b/min/languages/es.min.js index 6dd1e380..40ac3354 100644 --- a/min/languages/es.min.js +++ b/min/languages/es.min.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : spanish * author : Hernan Garcia : https://github.com/hgarcia diff --git a/min/languages/et.min.js b/min/languages/et.min.js index 9376cdc8..cf9f7e38 100644 --- a/min/languages/et.min.js +++ b/min/languages/et.min.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : Estonian * author : Illimar Tambek : https://github.com/ragulka @@ -6,4 +6,4 @@ * 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(a){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 +!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 index 821e7a00..c841275f 100644 --- a/min/languages/fi.min.js +++ b/min/languages/fi.min.js @@ -1,6 +1,6 @@ -/*! @preserve +/*! * 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(a){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 +!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 index 60e58b6f..b687e50e 100644 --- a/min/languages/fr-CA.min.js +++ b/min/languages/fr-CA.min.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : french (Canada) (fr-CA) * author : Léo Renaud-Allaire : https://github.com/renaudleo diff --git a/min/languages/fr-ch.min.js b/min/languages/fr-ch.min.js index b354bcd3..6ef1af8b 100644 --- a/min/languages/fr-ch.min.js +++ b/min/languages/fr-ch.min.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : french (fr-ch) * author : Adam Draper : https://github.com/adamwdraper diff --git a/min/languages/fr.min.js b/min/languages/fr.min.js index fdc97c19..3cc2e70d 100644 --- a/min/languages/fr.min.js +++ b/min/languages/fr.min.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : french (fr) * author : Adam Draper : https://github.com/adamwdraper diff --git a/min/languages/hu.min.js b/min/languages/hu.min.js index 52d5d94b..084551b2 100644 --- a/min/languages/hu.min.js +++ b/min/languages/hu.min.js @@ -1,6 +1,6 @@ -/*! @preserve +/*! * 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(a){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 +!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 index 16f30ac4..186a70d0 100644 --- a/min/languages/it.min.js +++ b/min/languages/it.min.js @@ -1,6 +1,6 @@ -/*! @preserve +/*! * 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(a){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 +!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 index a4a77164..99d8e74b 100644 --- a/min/languages/ja.min.js +++ b/min/languages/ja.min.js @@ -1,6 +1,6 @@ -/*! @preserve +/*! * 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(a){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 +!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 index 1c22e84b..3321d4a0 100644 --- a/min/languages/nl-nl.min.js +++ b/min/languages/nl-nl.min.js @@ -1,6 +1,6 @@ -/*! @preserve +/*! * 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&&b<=1||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 +!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 index 7faaa0d1..e0875827 100644 --- a/min/languages/pl.min.js +++ b/min/languages/pl.min.js @@ -1,6 +1,6 @@ -/*! @preserve +/*! * 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(a){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 +!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 index 67835eb8..3f57b0c6 100644 --- a/min/languages/pt-br.min.js +++ b/min/languages/pt-br.min.js @@ -1,6 +1,6 @@ -/*! @preserve +/*! * 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(a){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 +!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 index c85431f1..cd707074 100644 --- a/min/languages/pt-pt.min.js +++ b/min/languages/pt-pt.min.js @@ -1,6 +1,6 @@ -/*! @preserve +/*! * 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(a){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 +!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.min.js b/min/languages/ru.min.js index 043efbaa..6a3762f3 100644 --- a/min/languages/ru.min.js +++ b/min/languages/ru.min.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : russian (ru) * author : Anatoli Papirovski : https://github.com/apapirovski diff --git a/min/languages/sk.min.js b/min/languages/sk.min.js index 6b75a44e..e68e4dc7 100644 --- a/min/languages/sk.min.js +++ b/min/languages/sk.min.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js language configuration * language : slovak (sk) * author : Ahmed Al Hafoudh : http://www.freevision.sk diff --git a/min/languages/th.min.js b/min/languages/th.min.js index cbd6ce5c..c165048c 100644 --- a/min/languages/th.min.js +++ b/min/languages/th.min.js @@ -1,6 +1,6 @@ -/*! @preserve +/*! * 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(a){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 +!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 index 9d9e0cbc..265d16d6 100644 --- a/min/languages/tr.min.js +++ b/min/languages/tr.min.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * 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 diff --git a/min/numeral.min.js b/min/numeral.min.js index 0dd8e8fe..e798f2a9 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -1,12 +1,8 @@ -/*! @preserve +/*! * numeral.js * version : 1.5.3 * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -<<<<<<< HEAD -(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"},m.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=m.languageData(b)}catch(k){i=m.languageData(m.language())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},"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); -======= -(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));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),f<=1?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(f-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+":"+(c<10?"0"+c:c)+":"+(d<10?"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&&a0&&(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,d,e){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,d,e){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,c,d){var e=l(a,b);return a*e*(b*e)/(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=l(a,b);return a*e/(b*e)}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); ->>>>>>> master +(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"},m.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=m.languageData(b)}catch(k){i=m.languageData(m.language())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},"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 diff --git a/numeral.js b/numeral.js index 245dd978..a1b7dfdd 100644 --- a/numeral.js +++ b/numeral.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! * numeral.js * version : 1.5.3 * author : Adam Draper @@ -189,11 +189,7 @@ output = formatNumber(value, format, roundingFunction); -<<<<<<< HEAD if (output.indexOf(')') > -1) { -======= - if (output.indexOf(')') > -1 ) { ->>>>>>> master output = output.split(''); output.splice(-1, 0, space + '%'); output = output.join(''); @@ -679,7 +675,6 @@ return numeral(this); }, -<<<<<<< HEAD format: function(inputString, roundingFunction) { return formatNumeral(this, inputString ? inputString : defaultFormat, (roundingFunction !== undefined) ? roundingFunction : Math.round @@ -687,16 +682,6 @@ }, unformat: function(inputString) { -======= - format : function (inputString, roundingFunction) { - return formatNumeral(this, - inputString ? inputString : defaultFormat, - (roundingFunction !== undefined) ? roundingFunction : Math.round - ); - }, - - unformat : function (inputString) { ->>>>>>> master if (Object.prototype.toString.call(inputString) === '[object Number]') { return inputString; } diff --git a/package.json b/package.json index ecaa7447..5e80aef9 100644 --- a/package.json +++ b/package.json @@ -37,8 +37,8 @@ "grunt": "latest", "grunt-contrib-uglify": "latest", "grunt-contrib-jshint": "latest", - "grunt-contrib-nodeunit": "1.0.0", - "grunt-contrib-concat": "1.0.1" + "grunt-contrib-nodeunit": "~0.1.2", + "grunt-contrib-concat": "~0.3.0" }, "scripts": { "test": "grunt" From 5d7568b093436cbbd6e6044cfc56524ff30bb20c Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 17 Nov 2016 23:34:54 -0800 Subject: [PATCH 029/150] Revert "Revert "Merge branch 'master' into develop"" This reverts commit bd7e8e2f3627c961edb2663c7862c9b865a5db91. --- .travis.yml | 7 ++++- Gruntfile.js | 2 +- README.md | 9 ++++--- languages.js | 52 ++++++++++++++++++++------------------ languages/be-nl.js | 2 +- languages/chs.js | 2 +- languages/cs.js | 2 +- languages/da-dk.js | 2 +- languages/de-ch.js | 2 +- languages/de.js | 2 +- languages/en-gb.js | 2 +- languages/es-ES.js | 2 +- languages/es.js | 2 +- languages/et.js | 2 +- languages/fi.js | 2 +- languages/fr-CA.js | 2 +- languages/fr-ch.js | 2 +- languages/fr.js | 2 +- languages/hu.js | 2 +- languages/it.js | 2 +- languages/ja.js | 2 +- languages/nl-nl.js | 2 +- languages/pl.js | 2 +- languages/pt-br.js | 2 +- languages/pt-pt.js | 2 +- languages/ru.js | 2 +- languages/sk.js | 2 +- languages/th.js | 2 +- languages/tr.js | 2 +- min/languages.min.js | 52 ++++++++++++++++++++------------------ min/languages/be-nl.min.js | 4 +-- min/languages/chs.min.js | 4 +-- min/languages/cs.min.js | 2 +- min/languages/da-dk.min.js | 4 +-- min/languages/de-ch.min.js | 4 +-- min/languages/de.min.js | 4 +-- min/languages/en-gb.min.js | 2 +- min/languages/es-ES.min.js | 2 +- min/languages/es.min.js | 2 +- min/languages/et.min.js | 4 +-- min/languages/fi.min.js | 4 +-- min/languages/fr-CA.min.js | 2 +- min/languages/fr-ch.min.js | 2 +- min/languages/fr.min.js | 2 +- min/languages/hu.min.js | 4 +-- min/languages/it.min.js | 4 +-- min/languages/ja.min.js | 4 +-- min/languages/nl-nl.min.js | 4 +-- min/languages/pl.min.js | 4 +-- min/languages/pt-br.min.js | 4 +-- min/languages/pt-pt.min.js | 4 +-- min/languages/ru.min.js | 2 +- min/languages/sk.min.js | 2 +- min/languages/th.min.js | 4 +-- min/languages/tr.min.js | 2 +- min/numeral.min.js | 8 ++++-- numeral.js | 17 ++++++++++++- package.json | 4 +-- 58 files changed, 158 insertions(+), 123 deletions(-) diff --git a/.travis.yml b/.travis.yml index 384c4072..5f55c505 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,11 @@ language: node_js node_js: +<<<<<<< HEAD - "0.10" +======= + - "6" + - "4" +>>>>>>> master 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..4e0e1bf1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -88,4 +88,4 @@ module.exports = function(grunt) { // Travis CI task. grunt.registerTask('travis', ['test']); -}; \ No newline at end of file +}; diff --git a/README.md b/README.md index 948781cb..b6c45c64 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,13 @@ 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.svg?downloads=true)](https://nodei.co/npm/numeral/) # Contributing @@ -31,7 +34,7 @@ Please submit all pull requests to the `develop` branch. 7. Submit a pull request to the `develop` branch. -### Languages +### Languages 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. diff --git a/languages.js b/languages.js index cc2abc41..b69c985c 100644 --- a/languages.js +++ b/languages.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : belgium-dutch (be-nl) * author : Dieter Luypaert : https://github.com/moeriki @@ -33,7 +33,7 @@ this.numeral.language('be-nl', language); } }()); -/*! +/*! @preserve * numeral.js language configuration * language : simplified chinese * author : badplum : https://github.com/badplum @@ -68,7 +68,7 @@ } }()); -/*! +/*! @preserve * numeral.js language configuration * language : czech (cs) * author : Anatoli Papirovski : https://github.com/apapirovski @@ -103,7 +103,7 @@ } }()); -/*! +/*! @preserve * numeral.js language configuration * language : danish denmark (dk) * author : Michael Storgaard : https://github.com/mstorgaard @@ -137,7 +137,7 @@ this.numeral.language('da-dk', language); } }()); -/*! +/*! @preserve * 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) @@ -171,7 +171,7 @@ this.numeral.language('de-ch', language); } }()); -/*! +/*! @preserve * numeral.js language configuration * language : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium * author : Marco Krage : https://github.com/sinky @@ -205,7 +205,7 @@ this.numeral.language('de', language); } }()); -/*! +/*! @preserve * numeral.js language configuration * language : english united kingdom (uk) * author : Dan Ristic : https://github.com/dristic @@ -243,7 +243,7 @@ this.numeral.language('en-gb', language); } }()); -/*! +/*! @preserve * numeral.js language configuration * language : spanish Spain * author : Hernan Garcia : https://github.com/hgarcia @@ -283,7 +283,7 @@ } }()); -/*! +/*! @preserve * numeral.js language configuration * language : spanish * author : Hernan Garcia : https://github.com/hgarcia @@ -323,7 +323,7 @@ } }()); -/*! +/*! @preserve * numeral.js language configuration * language : Estonian * author : Illimar Tambek : https://github.com/ragulka @@ -361,7 +361,7 @@ } }()); -/*! +/*! @preserve * numeral.js language configuration * language : Finnish * author : Sami Saada : https://github.com/samitheberber @@ -396,7 +396,7 @@ } }()); -/*! +/*! @preserve * numeral.js language configuration * language : french (Canada) (fr-CA) * author : Léo Renaud-Allaire : https://github.com/renaudleo @@ -430,7 +430,7 @@ this.numeral.language('fr-CA', language); } }()); -/*! +/*! @preserve * numeral.js language configuration * language : french (fr-ch) * author : Adam Draper : https://github.com/adamwdraper @@ -465,7 +465,7 @@ } }()); -/*! +/*! @preserve * numeral.js language configuration * language : french (fr) * author : Adam Draper : https://github.com/adamwdraper @@ -499,7 +499,7 @@ this.numeral.language('fr', language); } }()); -/*! +/*! @preserve * numeral.js language configuration * language : Hungarian (hu) * author : Peter Bakondy : https://github.com/pbakondy @@ -533,7 +533,7 @@ this.numeral.language('hu', language); } }()); -/*! +/*! @preserve * numeral.js language configuration * language : italian Italy (it) * author : Giacomo Trombi : http://cinquepunti.it @@ -567,7 +567,7 @@ this.numeral.language('it', language); } }()); -/*! +/*! @preserve * numeral.js language configuration * language : japanese * author : teppeis : https://github.com/teppeis @@ -602,6 +602,7 @@ } }()); +<<<<<<< HEAD /*! * numeral.js language configuration * language : Latvian (lv) @@ -637,6 +638,9 @@ }()); /*! +======= +/*! @preserve +>>>>>>> master * numeral.js language configuration * language : netherlands-dutch (nl-nl) * author : Dave Clayton : https://github.com/davedx @@ -671,7 +675,7 @@ this.numeral.language('nl-nl', language); } }()); -/*! +/*! @preserve * numeral.js language configuration * language : polish (pl) * author : Dominik Bulaj : https://github.com/dominikbulaj @@ -705,7 +709,7 @@ this.numeral.language('pl', language); } }()); -/*! +/*! @preserve * numeral.js language configuration * language : portuguese brazil (pt-br) * author : Ramiro Varandas Jr : https://github.com/ramirovjr @@ -739,7 +743,7 @@ this.numeral.language('pt-br', language); } }()); -/*! +/*! @preserve * numeral.js language configuration * language : portuguese (pt-pt) * author : Diogo Resende : https://github.com/dresende @@ -810,7 +814,7 @@ } }()); -/*! +/*! @preserve * numeral.js language configuration * language : russian (ru) * author : Anatoli Papirovski : https://github.com/apapirovski @@ -848,7 +852,7 @@ } }()); -/*! +/*! @preserve * numeral.js language configuration * language : slovak (sk) * author : Ahmed Al Hafoudh : http://www.freevision.sk @@ -883,7 +887,7 @@ } }()); -/*! +/*! @preserve * numeral.js language configuration * language : thai (th) * author : Sathit Jittanupat : https://github.com/jojosati @@ -918,7 +922,7 @@ } }()); -/*! +/*! @preserve * 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 diff --git a/languages/be-nl.js b/languages/be-nl.js index b26d840a..78d8cd06 100644 --- a/languages/be-nl.js +++ b/languages/be-nl.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : belgium-dutch (be-nl) * author : Dieter Luypaert : https://github.com/moeriki diff --git a/languages/chs.js b/languages/chs.js index 9c54f2f1..ab88f61d 100644 --- a/languages/chs.js +++ b/languages/chs.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : simplified chinese * author : badplum : https://github.com/badplum diff --git a/languages/cs.js b/languages/cs.js index 248a9118..15aa7121 100644 --- a/languages/cs.js +++ b/languages/cs.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : czech (cs) * author : Anatoli Papirovski : https://github.com/apapirovski diff --git a/languages/da-dk.js b/languages/da-dk.js index 27078741..ae7b41ec 100644 --- a/languages/da-dk.js +++ b/languages/da-dk.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : danish denmark (dk) * author : Michael Storgaard : https://github.com/mstorgaard diff --git a/languages/de-ch.js b/languages/de-ch.js index 29187385..cd5afa5b 100644 --- a/languages/de-ch.js +++ b/languages/de-ch.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * 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) diff --git a/languages/de.js b/languages/de.js index d6bd5f07..422408bb 100644 --- a/languages/de.js +++ b/languages/de.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium * author : Marco Krage : https://github.com/sinky diff --git a/languages/en-gb.js b/languages/en-gb.js index 5b99c7a8..f1bac3e3 100644 --- a/languages/en-gb.js +++ b/languages/en-gb.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : english united kingdom (uk) * author : Dan Ristic : https://github.com/dristic diff --git a/languages/es-ES.js b/languages/es-ES.js index a62abc07..7df615e4 100644 --- a/languages/es-ES.js +++ b/languages/es-ES.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : spanish Spain * author : Hernan Garcia : https://github.com/hgarcia diff --git a/languages/es.js b/languages/es.js index b078fe55..d084de38 100644 --- a/languages/es.js +++ b/languages/es.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : spanish * author : Hernan Garcia : https://github.com/hgarcia diff --git a/languages/et.js b/languages/et.js index f45dd7de..cb81dd67 100644 --- a/languages/et.js +++ b/languages/et.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : Estonian * author : Illimar Tambek : https://github.com/ragulka diff --git a/languages/fi.js b/languages/fi.js index 2e247431..a8c16915 100644 --- a/languages/fi.js +++ b/languages/fi.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : Finnish * author : Sami Saada : https://github.com/samitheberber diff --git a/languages/fr-CA.js b/languages/fr-CA.js index ea1c9a50..3e95f0cd 100644 --- a/languages/fr-CA.js +++ b/languages/fr-CA.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : french (Canada) (fr-CA) * author : Léo Renaud-Allaire : https://github.com/renaudleo diff --git a/languages/fr-ch.js b/languages/fr-ch.js index 64ffbd22..40072e49 100644 --- a/languages/fr-ch.js +++ b/languages/fr-ch.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : french (fr-ch) * author : Adam Draper : https://github.com/adamwdraper diff --git a/languages/fr.js b/languages/fr.js index 960defad..d2b3dd69 100644 --- a/languages/fr.js +++ b/languages/fr.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : french (fr) * author : Adam Draper : https://github.com/adamwdraper diff --git a/languages/hu.js b/languages/hu.js index 9710ac23..dc2119e7 100644 --- a/languages/hu.js +++ b/languages/hu.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : Hungarian (hu) * author : Peter Bakondy : https://github.com/pbakondy diff --git a/languages/it.js b/languages/it.js index 5bc1f9c3..502c7b9b 100644 --- a/languages/it.js +++ b/languages/it.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : italian Italy (it) * author : Giacomo Trombi : http://cinquepunti.it diff --git a/languages/ja.js b/languages/ja.js index d0816b27..d7d41aa9 100644 --- a/languages/ja.js +++ b/languages/ja.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : japanese * author : teppeis : https://github.com/teppeis diff --git a/languages/nl-nl.js b/languages/nl-nl.js index ab577867..5ea7354a 100644 --- a/languages/nl-nl.js +++ b/languages/nl-nl.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : netherlands-dutch (nl-nl) * author : Dave Clayton : https://github.com/davedx diff --git a/languages/pl.js b/languages/pl.js index 5cb6056e..3ffd9011 100644 --- a/languages/pl.js +++ b/languages/pl.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : polish (pl) * author : Dominik Bulaj : https://github.com/dominikbulaj diff --git a/languages/pt-br.js b/languages/pt-br.js index 51ab7dab..c9ff8424 100644 --- a/languages/pt-br.js +++ b/languages/pt-br.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : portuguese brazil (pt-br) * author : Ramiro Varandas Jr : https://github.com/ramirovjr diff --git a/languages/pt-pt.js b/languages/pt-pt.js index cce9a271..83a174e0 100644 --- a/languages/pt-pt.js +++ b/languages/pt-pt.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : portuguese (pt-pt) * author : Diogo Resende : https://github.com/dresende diff --git a/languages/ru.js b/languages/ru.js index 14d9e83a..2a9ea0ec 100644 --- a/languages/ru.js +++ b/languages/ru.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : russian (ru) * author : Anatoli Papirovski : https://github.com/apapirovski diff --git a/languages/sk.js b/languages/sk.js index ac48faf7..6bae7213 100644 --- a/languages/sk.js +++ b/languages/sk.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : slovak (sk) * author : Ahmed Al Hafoudh : http://www.freevision.sk diff --git a/languages/th.js b/languages/th.js index ca73c7d7..f1f8a214 100644 --- a/languages/th.js +++ b/languages/th.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : thai (th) * author : Sathit Jittanupat : https://github.com/jojosati diff --git a/languages/tr.js b/languages/tr.js index 79b9a498..1f333876 100644 --- a/languages/tr.js +++ b/languages/tr.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * 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 diff --git a/min/languages.min.js b/min/languages.min.js index 1207c5e6..2d041f34 100644 --- a/min/languages.min.js +++ b/min/languages.min.js @@ -1,49 +1,49 @@ -/*! +/*! @preserve * 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)}(),/*! +!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&&b<=1||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)}(),/*! @preserve * 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)}(),/*! +function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("chs",a)}(),/*! @preserve * 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)}(),/*! +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)}(),/*! @preserve * 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)}(),/*! +function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mia",trillion:"b"},ordinal:function(a){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)}(),/*! @preserve * 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)}(),/*! +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){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)}(),/*! @preserve * 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)}(),/*! +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("de",a)}(),/*! @preserve * 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)}(),/*! +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)}(),/*! @preserve * 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)}(),/*! +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)}(),/*! @preserve * 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)}(),/*! +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)}(),/*! @preserve * numeral.js language configuration * language : Estonian * author : Illimar Tambek : https://github.com/ragulka @@ -51,82 +51,86 @@ function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand * 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)}(),/*! +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("et",a)}(),/*! @preserve * 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)}(),/*! +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("fi",a)}(),/*! @preserve * 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)}(),/*! +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)}(),/*! @preserve * 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)}(),/*! +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)}(),/*! @preserve * 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)}(),/*! +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)}(),/*! @preserve * 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)}(),/*! +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){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)}(),/*! @preserve * 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)}(),/*! +function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("it",a)}(),/*! @preserve * numeral.js language configuration * language : japanese * author : teppeis : https://github.com/teppeis */ +<<<<<<< HEAD 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 : Latvian (lv) * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks */ function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("lv",a)}(),/*! +======= +function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("ja",a)}(),/*! @preserve +>>>>>>> master * 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)}(),/*! +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&&b<=1||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)}(),/*! @preserve * 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)}(),/*! +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){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)}(),/*! @preserve * 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)}(),/*! +function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mil",million:"milhões",billion:"b",trillion:"t"},ordinal:function(a){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)}(),/*! @preserve * 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)}(),/*! +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){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)}(),/*! @preserve * 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)}(),/*! +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)}(),/*! @preserve * 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)}(),/*! +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)}(),/*! @preserve * 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)}(),/*! +function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("th",a)}(),/*! @preserve * 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 diff --git a/min/languages/be-nl.min.js b/min/languages/be-nl.min.js index d17a383f..a4cb5c36 100644 --- a/min/languages/be-nl.min.js +++ b/min/languages/be-nl.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * 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 +!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&&b<=1||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 index 6d375969..18840388 100644 --- a/min/languages/chs.min.js +++ b/min/languages/chs.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * 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 +!function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){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 index b1d1ff57..0fddd92d 100644 --- a/min/languages/cs.min.js +++ b/min/languages/cs.min.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : czech (cs) * author : Anatoli Papirovski : https://github.com/apapirovski diff --git a/min/languages/da-dk.min.js b/min/languages/da-dk.min.js index 19f1a7b3..5697c3fe 100644 --- a/min/languages/da-dk.min.js +++ b/min/languages/da-dk.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * 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 +!function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mia",trillion:"b"},ordinal:function(a){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 index 5279f430..8f359117 100644 --- a/min/languages/de-ch.min.js +++ b/min/languages/de-ch.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * 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 +!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){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 index 0c54a30a..6911e0c5 100644 --- a/min/languages/de.min.js +++ b/min/languages/de.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * 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 +!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){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 index b6d97446..9938bf28 100644 --- a/min/languages/en-gb.min.js +++ b/min/languages/en-gb.min.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : english united kingdom (uk) * author : Dan Ristic : https://github.com/dristic diff --git a/min/languages/es-ES.min.js b/min/languages/es-ES.min.js index 3f936943..16b80447 100644 --- a/min/languages/es-ES.min.js +++ b/min/languages/es-ES.min.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : spanish Spain * author : Hernan Garcia : https://github.com/hgarcia diff --git a/min/languages/es.min.js b/min/languages/es.min.js index 40ac3354..6dd1e380 100644 --- a/min/languages/es.min.js +++ b/min/languages/es.min.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : spanish * author : Hernan Garcia : https://github.com/hgarcia diff --git a/min/languages/et.min.js b/min/languages/et.min.js index cf9f7e38..9376cdc8 100644 --- a/min/languages/et.min.js +++ b/min/languages/et.min.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : Estonian * author : Illimar Tambek : https://github.com/ragulka @@ -6,4 +6,4 @@ * 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 +!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){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 index c841275f..821e7a00 100644 --- a/min/languages/fi.min.js +++ b/min/languages/fi.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * 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 +!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){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 index b687e50e..60e58b6f 100644 --- a/min/languages/fr-CA.min.js +++ b/min/languages/fr-CA.min.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : french (Canada) (fr-CA) * author : Léo Renaud-Allaire : https://github.com/renaudleo diff --git a/min/languages/fr-ch.min.js b/min/languages/fr-ch.min.js index 6ef1af8b..b354bcd3 100644 --- a/min/languages/fr-ch.min.js +++ b/min/languages/fr-ch.min.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : french (fr-ch) * author : Adam Draper : https://github.com/adamwdraper diff --git a/min/languages/fr.min.js b/min/languages/fr.min.js index 3cc2e70d..fdc97c19 100644 --- a/min/languages/fr.min.js +++ b/min/languages/fr.min.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : french (fr) * author : Adam Draper : https://github.com/adamwdraper diff --git a/min/languages/hu.min.js b/min/languages/hu.min.js index 084551b2..52d5d94b 100644 --- a/min/languages/hu.min.js +++ b/min/languages/hu.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * 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 +!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){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 index 186a70d0..16f30ac4 100644 --- a/min/languages/it.min.js +++ b/min/languages/it.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * 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 +!function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){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 index 99d8e74b..a4a77164 100644 --- a/min/languages/ja.min.js +++ b/min/languages/ja.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * 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 +!function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){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 index 3321d4a0..1c22e84b 100644 --- a/min/languages/nl-nl.min.js +++ b/min/languages/nl-nl.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * 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 +!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&&b<=1||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 index e0875827..7faaa0d1 100644 --- a/min/languages/pl.min.js +++ b/min/languages/pl.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * 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 +!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){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 index 3f57b0c6..67835eb8 100644 --- a/min/languages/pt-br.min.js +++ b/min/languages/pt-br.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * 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 +!function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mil",million:"milhões",billion:"b",trillion:"t"},ordinal:function(a){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 index cd707074..c85431f1 100644 --- a/min/languages/pt-pt.min.js +++ b/min/languages/pt-pt.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * 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 +!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){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.min.js b/min/languages/ru.min.js index 6a3762f3..043efbaa 100644 --- a/min/languages/ru.min.js +++ b/min/languages/ru.min.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : russian (ru) * author : Anatoli Papirovski : https://github.com/apapirovski diff --git a/min/languages/sk.min.js b/min/languages/sk.min.js index e68e4dc7..6b75a44e 100644 --- a/min/languages/sk.min.js +++ b/min/languages/sk.min.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : slovak (sk) * author : Ahmed Al Hafoudh : http://www.freevision.sk diff --git a/min/languages/th.min.js b/min/languages/th.min.js index c165048c..cbd6ce5c 100644 --- a/min/languages/th.min.js +++ b/min/languages/th.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * 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 +!function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){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 index 265d16d6..9d9e0cbc 100644 --- a/min/languages/tr.min.js +++ b/min/languages/tr.min.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * 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 diff --git a/min/numeral.min.js b/min/numeral.min.js index e798f2a9..0dd8e8fe 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -1,8 +1,12 @@ -/*! +/*! @preserve * numeral.js * version : 1.5.3 * 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"},m.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=m.languageData(b)}catch(k){i=m.languageData(m.language())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},"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 +<<<<<<< HEAD +(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"},m.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=m.languageData(b)}catch(k){i=m.languageData(m.language())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},"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); +======= +(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));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),f<=1?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(f-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+":"+(c<10?"0"+c:c)+":"+(d<10?"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&&a0&&(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,d,e){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,d,e){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,c,d){var e=l(a,b);return a*e*(b*e)/(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=l(a,b);return a*e/(b*e)}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); +>>>>>>> master diff --git a/numeral.js b/numeral.js index a1b7dfdd..245dd978 100644 --- a/numeral.js +++ b/numeral.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js * version : 1.5.3 * author : Adam Draper @@ -189,7 +189,11 @@ output = formatNumber(value, format, roundingFunction); +<<<<<<< HEAD if (output.indexOf(')') > -1) { +======= + if (output.indexOf(')') > -1 ) { +>>>>>>> master output = output.split(''); output.splice(-1, 0, space + '%'); output = output.join(''); @@ -675,6 +679,7 @@ return numeral(this); }, +<<<<<<< HEAD format: function(inputString, roundingFunction) { return formatNumeral(this, inputString ? inputString : defaultFormat, (roundingFunction !== undefined) ? roundingFunction : Math.round @@ -682,6 +687,16 @@ }, unformat: function(inputString) { +======= + format : function (inputString, roundingFunction) { + return formatNumeral(this, + inputString ? inputString : defaultFormat, + (roundingFunction !== undefined) ? roundingFunction : Math.round + ); + }, + + unformat : function (inputString) { +>>>>>>> master if (Object.prototype.toString.call(inputString) === '[object Number]') { return inputString; } diff --git a/package.json b/package.json index 5e80aef9..ecaa7447 100644 --- a/package.json +++ b/package.json @@ -37,8 +37,8 @@ "grunt": "latest", "grunt-contrib-uglify": "latest", "grunt-contrib-jshint": "latest", - "grunt-contrib-nodeunit": "~0.1.2", - "grunt-contrib-concat": "~0.3.0" + "grunt-contrib-nodeunit": "1.0.0", + "grunt-contrib-concat": "1.0.1" }, "scripts": { "test": "grunt" From 8f11164080aad467309df7aae603c4366a90a241 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 17 Nov 2016 23:39:26 -0800 Subject: [PATCH 030/150] fix merge conflicts --- .travis.yml | 4 -- languages.js | 96 +++++++++++++------------------------------- min/languages.min.js | 53 ++++++++++-------------- min/numeral.min.js | 4 -- numeral.js | 16 +------- 5 files changed, 52 insertions(+), 121 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5f55c505..f22dff0d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,7 @@ language: node_js node_js: -<<<<<<< HEAD - - "0.10" -======= - "6" - "4" ->>>>>>> master before_script: - npm install -g grunt-cli script: grunt travis --verbose diff --git a/languages.js b/languages.js index b69c985c..3cdddc9d 100644 --- a/languages.js +++ b/languages.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! @preserve * numeral.js language configuration * language : belgium-dutch (be-nl) * author : Dieter Luypaert : https://github.com/moeriki @@ -33,7 +33,7 @@ this.numeral.language('be-nl', language); } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : simplified chinese * author : badplum : https://github.com/badplum @@ -103,7 +103,7 @@ } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : danish denmark (dk) * author : Michael Storgaard : https://github.com/mstorgaard @@ -137,11 +137,11 @@ this.numeral.language('da-dk', language); } }()); -/*! @preserve +/*! @preserve * 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: { @@ -171,7 +171,7 @@ this.numeral.language('de-ch', language); } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium * author : Marco Krage : https://github.com/sinky @@ -205,7 +205,7 @@ this.numeral.language('de', language); } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : english united kingdom (uk) * author : Dan Ristic : https://github.com/dristic @@ -243,7 +243,7 @@ this.numeral.language('en-gb', language); } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : spanish Spain * author : Hernan Garcia : https://github.com/hgarcia @@ -283,7 +283,7 @@ } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : spanish * author : Hernan Garcia : https://github.com/hgarcia @@ -304,7 +304,7 @@ var b = number % 10; return (b === 1 || b === 3) ? 'er' : (b === 2) ? 'do' : - (b === 7 || b === 0) ? 'mo' : + (b === 7 || b === 0) ? 'mo' : (b === 8) ? 'vo' : (b === 9) ? 'no' : 'to'; }, @@ -323,7 +323,7 @@ } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : Estonian * author : Illimar Tambek : https://github.com/ragulka @@ -361,7 +361,7 @@ } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : Finnish * author : Sami Saada : https://github.com/samitheberber @@ -430,7 +430,7 @@ this.numeral.language('fr-CA', language); } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : french (fr-ch) * author : Adam Draper : https://github.com/adamwdraper @@ -465,7 +465,7 @@ } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : french (fr) * author : Adam Draper : https://github.com/adamwdraper @@ -533,7 +533,7 @@ this.numeral.language('hu', language); } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : italian Italy (it) * author : Giacomo Trombi : http://cinquepunti.it @@ -567,7 +567,7 @@ this.numeral.language('it', language); } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : japanese * author : teppeis : https://github.com/teppeis @@ -602,45 +602,7 @@ } }()); -<<<<<<< HEAD -/*! - * numeral.js language configuration - * language : Latvian (lv) - * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks - */ -(function () { - var language = { - delimiters: { - thousands: ' ', - decimal: ',' - }, - abbreviations: { - thousand: ' tūkst.', - million: ' milj.', - billion: ' mljrd.', - trillion: ' trilj.' - }, - 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('lv', language); - } -}()); - -/*! -======= -/*! @preserve ->>>>>>> master +/*! @preserve * numeral.js language configuration * language : netherlands-dutch (nl-nl) * author : Dave Clayton : https://github.com/davedx @@ -675,7 +637,7 @@ this.numeral.language('nl-nl', language); } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : polish (pl) * author : Dominik Bulaj : https://github.com/dominikbulaj @@ -709,7 +671,7 @@ this.numeral.language('pl', language); } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : portuguese brazil (pt-br) * author : Ramiro Varandas Jr : https://github.com/ramirovjr @@ -743,7 +705,7 @@ this.numeral.language('pt-br', language); } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : portuguese (pt-pt) * author : Diogo Resende : https://github.com/dresende @@ -794,10 +756,10 @@ trillion: 't' }, ordinal: function () { - // not ideal, but since in Russian it can taken on + // not ideal, but since in Russian it can taken on // different forms (masculine, feminine, neuter) // this is all we can do - return '.'; + return '.'; }, currency: { symbol: '\u20B4' @@ -814,7 +776,7 @@ } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : russian (ru) * author : Anatoli Papirovski : https://github.com/apapirovski @@ -832,10 +794,10 @@ trillion: 't' }, ordinal: function () { - // not ideal, but since in Russian it can taken on + // not ideal, but since in Russian it can taken on // different forms (masculine, feminine, neuter) // this is all we can do - return '.'; + return '.'; }, currency: { symbol: 'руб.' @@ -887,7 +849,7 @@ } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : thai (th) * author : Sathit Jittanupat : https://github.com/jojosati @@ -922,7 +884,7 @@ } }()); -/*! @preserve +/*! @preserve * 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 @@ -1006,10 +968,10 @@ 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' diff --git a/min/languages.min.js b/min/languages.min.js index 2d041f34..32d97531 100644 --- a/min/languages.min.js +++ b/min/languages.min.js @@ -1,9 +1,9 @@ -/*! @preserve +/*! @preserve * 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&&b<=1||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)}(),/*! @preserve +!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&&b<=1||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)}(),/*! @preserve * numeral.js language configuration * language : simplified chinese * author : badplum : https://github.com/badplum @@ -13,37 +13,37 @@ function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand * 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)}(),/*! @preserve +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)}(),/*! @preserve * 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(a){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)}(),/*! @preserve +function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mia",trillion:"b"},ordinal:function(a){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)}(),/*! @preserve * 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(a){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)}(),/*! @preserve +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){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)}(),/*! @preserve * 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(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("de",a)}(),/*! @preserve +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("de",a)}(),/*! @preserve * 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)}(),/*! @preserve +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)}(),/*! @preserve * 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)}(),/*! @preserve +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)}(),/*! @preserve * 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)}(),/*! @preserve +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)}(),/*! @preserve * numeral.js language configuration * language : Estonian * author : Illimar Tambek : https://github.com/ragulka @@ -51,7 +51,7 @@ function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand * 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(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("et",a)}(),/*! @preserve +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("et",a)}(),/*! @preserve * numeral.js language configuration * language : Finnish * author : Sami Saada : https://github.com/samitheberber @@ -61,12 +61,12 @@ function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand * 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)}(),/*! @preserve +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)}(),/*! @preserve * 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)}(),/*! @preserve +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)}(),/*! @preserve * numeral.js language configuration * language : french (fr) * author : Adam Draper : https://github.com/adamwdraper @@ -76,46 +76,37 @@ function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand * 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(a){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)}(),/*! @preserve +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){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)}(),/*! @preserve * 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(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("it",a)}(),/*! @preserve +function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("it",a)}(),/*! @preserve * numeral.js language configuration * language : japanese * author : teppeis : https://github.com/teppeis */ -<<<<<<< HEAD -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 : Latvian (lv) - * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks - */ -function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("lv",a)}(),/*! -======= -function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("ja",a)}(),/*! @preserve ->>>>>>> master +function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("ja",a)}(),/*! @preserve * 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&&b<=1||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)}(),/*! @preserve +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&&b<=1||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)}(),/*! @preserve * 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(a){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)}(),/*! @preserve +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){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)}(),/*! @preserve * 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(a){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)}(),/*! @preserve +function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mil",million:"milhões",billion:"b",trillion:"t"},ordinal:function(a){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)}(),/*! @preserve * 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(a){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)}(),/*! @preserve +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){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)}(),/*! @preserve * numeral.js language configuration * language : russian (ru) * author : Anatoli Papirovski : https://github.com/apapirovski @@ -125,14 +116,14 @@ function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand * 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)}(),/*! @preserve +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)}(),/*! @preserve * 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(a){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("th",a)}(),/*! @preserve +function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("th",a)}(),/*! @preserve * 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 +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)}(); diff --git a/min/numeral.min.js b/min/numeral.min.js index 0dd8e8fe..09b1be94 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,8 +5,4 @@ * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -<<<<<<< HEAD -(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"},m.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=m.languageData(b)}catch(k){i=m.languageData(m.language())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},"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); -======= (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));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),f<=1?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(f-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+":"+(c<10?"0"+c:c)+":"+(d<10?"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&&a0&&(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,d,e){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,d,e){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,c,d){var e=l(a,b);return a*e*(b*e)/(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=l(a,b);return a*e/(b*e)}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); ->>>>>>> master diff --git a/numeral.js b/numeral.js index 245dd978..cfadec82 100644 --- a/numeral.js +++ b/numeral.js @@ -189,11 +189,7 @@ output = formatNumber(value, format, roundingFunction); -<<<<<<< HEAD if (output.indexOf(')') > -1) { -======= - if (output.indexOf(')') > -1 ) { ->>>>>>> master output = output.split(''); output.splice(-1, 0, space + '%'); output = output.join(''); @@ -423,7 +419,7 @@ if (!key) { return currentLanguage; } - + key = key.toLowerCase(); if (key && !values) { @@ -679,15 +675,6 @@ return numeral(this); }, -<<<<<<< HEAD - format: function(inputString, roundingFunction) { - return formatNumeral(this, - inputString ? inputString : defaultFormat, (roundingFunction !== undefined) ? roundingFunction : Math.round - ); - }, - - unformat: function(inputString) { -======= format : function (inputString, roundingFunction) { return formatNumeral(this, inputString ? inputString : defaultFormat, @@ -696,7 +683,6 @@ }, unformat : function (inputString) { ->>>>>>> master if (Object.prototype.toString.call(inputString) === '[object Number]') { return inputString; } From 915d7ccad1df5421eec3206214477e7b6ab3e2ef Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sat, 19 Nov 2016 19:00:14 -0800 Subject: [PATCH 031/150] start moving tests to mocha --- Gruntfile.js | 8 +- package.json | 9 +- tests/numeral/format.js | 386 +++++++++++++++++++--------------------- 3 files changed, 197 insertions(+), 206 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 4e0e1bf1..1316269b 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -21,8 +21,8 @@ module.exports = function(grunt) { }); grunt.initConfig({ - nodeunit : { - all : ['tests/**/*.js'] + mochaTest : { + all : ['tests/numeral/format.js'] }, uglify: { my_target: { @@ -64,10 +64,10 @@ module.exports = function(grunt) { } }); - grunt.loadNpmTasks('grunt-contrib-nodeunit'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-mocha-test'); grunt.registerTask('default', [ 'test' @@ -75,7 +75,7 @@ module.exports = function(grunt) { grunt.registerTask('test', [ 'jshint', - 'nodeunit' + 'mochaTest' ]); // P diff --git a/package.json b/package.json index ecaa7447..b403338a 100644 --- a/package.json +++ b/package.json @@ -33,12 +33,15 @@ } ], "devDependencies": { - "uglify-js": "latest", + "chai": "^3.5.0", "grunt": "latest", - "grunt-contrib-uglify": "latest", + "grunt-contrib-concat": "1.0.1", "grunt-contrib-jshint": "latest", "grunt-contrib-nodeunit": "1.0.0", - "grunt-contrib-concat": "1.0.1" + "grunt-contrib-uglify": "latest", + "grunt-mocha-test": "^0.13.2", + "mocha": "^3.1.2", + "uglify-js": "latest" }, "scripts": { "test": "grunt" diff --git a/tests/numeral/format.js b/tests/numeral/format.js index 53427ad4..246e4193 100644 --- a/tests/numeral/format.js +++ b/tests/numeral/format.js @@ -1,204 +1,192 @@ 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'] +var expect = require('chai').expect; + +describe('Format', function() { + + describe('Default', function() { + it('should set a default format', function() { + numeral.defaultFormat('0,0'); + + expect(numeral(10000).format()).to.equal('10,000'); + }); + }); + + describe('Value', function() { + it('should return a value', function() { + var tests = [ + '0,0.00', + '$0,0.00', + '0b', + '0,0%', + '00:00:00' + ], + value = 12345.6, + n = numeral(value), + format, + test; + + for (i = 0; i < tests.length; i++) { + format = n.format(tests[i]); + + expect(n.value()).to.equal(value); + } + }); + }); + + describe('Numbers', function() { + it('should format to 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[.]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; + + for (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 to currency', function() { + 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; + + for (i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Bytes', function() { + it('should format to bytes', function() { + 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; + + for (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 to percentages', function() { + var tests = [ + [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]); + } + }); + }); + + describe('Times', function() { + it('should format to times', function() { + var tests = [ + [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]); + } + + }); + }); + + 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.974878234,'0.000%','97.487%','97.488%'], + [-0.433,'0 %','-44 %', '-43 %'] ], 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; + for (i = 0; i < tests.length; i++) { + // floor + expect(numeral(tests[i][0]).format(tests[i][1], Math.floor)).to.equal(tests[i][2]); - 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(); - - }, -}; + // ceil + expect(numeral(tests[i][0]).format(tests[i][1], Math.ceil)).to.equal(tests[i][3]); + } + }); + }); +}); From 9c9169dfbf37375111e663caa7e46a136cbf4b3e Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sat, 19 Nov 2016 19:36:26 -0800 Subject: [PATCH 032/150] migrate all numeral tests --- Gruntfile.js | 2 +- tests/numeral/manipulate.js | 200 +++++++++++++++++++----------------- tests/numeral/misc.js | 165 ++++++++++++++--------------- tests/numeral/unformat.js | 103 +++++++++---------- tests/numeral/validate.js | 140 ++++++++++++------------- 5 files changed, 300 insertions(+), 310 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 1316269b..31adab9a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -22,7 +22,7 @@ module.exports = function(grunt) { grunt.initConfig({ mochaTest : { - all : ['tests/numeral/format.js'] + all : ['tests/numeral/*.js'] }, uglify: { my_target: { diff --git a/tests/numeral/manipulate.js b/tests/numeral/manipulate.js index bddd52e8..28bd4517 100644 --- a/tests/numeral/manipulate.js +++ b/tests/numeral/manipulate.js @@ -1,104 +1,110 @@ 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 = [ +var expect = require('chai').expect; + +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] + ], + 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] + ], + 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] + ], + 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] + ], + 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] ], 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 + + for (var i = 0; i < tests.length; i++) { + num = numeral(tests[i][0]); + + expect(num.difference(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); +}); diff --git a/tests/numeral/misc.js b/tests/numeral/misc.js index 0a07a482..84c1fe0d 100644 --- a/tests/numeral/misc.js +++ b/tests/numeral/misc.js @@ -1,65 +1,61 @@ var numeral = require('../../numeral'); +var expect = require('chai').expect; -exports.misc = { - - value: function (test) { - test.expect(5); - - var tests = [ +describe('Misc', function() { + describe('Add', function() { + it('should return a value', function() { + var tests = [ [1000, 1000], [0.5, 0.5], - [, 0], + [null, 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]); - } + for (var i = 0; i < tests.length; i++) { + num = numeral(tests[i][0]); - test.done(); - }, + expect(num.value()).to.equal(tests[i][1]); + } + }); + }); - set: function (test) { - test.expect(2); - - var tests = [ + 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]); - test.strictEqual(num.value(), tests[i][1], tests[i][0]); - } - - test.done(); - }, + for (var i = 0; i < tests.length; i++) { + num = numeral().set(tests[i][0]); - customZero: function (test) { - test.expect(3); + expect(num.value()).to.equal(tests[i][1]); + } + }); + }); - var tests = [ + describe('Custom Zero', function() { + it('should change zero value', function() { + 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]); - } + for (var i = 0; i < tests.length; i++) { + numeral.zeroFormat(tests[i][1]); - test.done(); - }, + expect(numeral(tests[i][0]).format('0')).to.equal(tests[i][2]); + } + }); + }); - clone: function (test) { - test.expect(4); - - var a = numeral(1000), + describe('Clone', function() { + it('should clone', function() { + var a = numeral(1000), b = numeral(a), c = a.clone(), aVal = a.value(), @@ -67,57 +63,54 @@ exports.misc = { 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); + expect(aVal).to.equal(1000); + expect(aSet).to.equal(2000); + expect(bVal).to.equal(1000); + expect(cVal).to.equal(1010); + }); + }); - var tests = [ + describe('isNumeral', function() { + it('should return boolean', function() { + 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 + for (var i = 0; i < tests.length; i++) { + expect(numeral.isNumeral(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); + + describe('Language Data', function() { + it('should use custom language data', function() { + var cOld = '$', + cNew = '!', + formatTestVal = function() { + return numeral('100').format('$0,0'); + }, + oldCurrencyVal = cOld + '100', + newCurrencyVal = cNew + '100'; + + expect(numeral.languageData().currency.symbol).to.equal(cOld); + expect(numeral.languageData('en').currency.symbol).to.equal(cOld); + + numeral.languageData().currency.symbol = cNew; + expect(numeral.languageData().currency.symbol).to.equal(cNew); + expect(formatTestVal()).to.equal(newCurrencyVal); + + numeral.languageData().currency.symbol = cOld; + expect(numeral.languageData().currency.symbol).to.equal('$'); + expect(formatTestVal()).to.equal(oldCurrencyVal); + + numeral.languageData('en').currency.symbol = cNew; + expect(numeral.languageData().currency.symbol).to.equal(cNew); + expect(formatTestVal()).to.equal(newCurrencyVal); + + numeral.languageData('en').currency.symbol = cOld; + expect(numeral.languageData().currency.symbol).to.equal(cOld); + expect(formatTestVal()).to.equal(oldCurrencyVal); + }); + }); +}); diff --git a/tests/numeral/unformat.js b/tests/numeral/unformat.js index f0b059b9..10ebc974 100644 --- a/tests/numeral/unformat.js +++ b/tests/numeral/unformat.js @@ -1,15 +1,14 @@ var numeral = require('../../numeral'); +var expect = require('chai').expect; -exports.unformat = { - setUp: function (callback) { +describe('Unformat', function() { + beforeEach(function() { numeral.zeroFormat('N/A'); - callback(); - }, + }); - numbers: function (test) { - test.expect(15); - - var tests = [ + describe('Numbers', function() { + it('should unformat a number', function() { + var tests = [ ['10,000.123', 10000.123], ['(0.12345)', -0.12345], ['((--0.12345))', 0.12345], @@ -17,9 +16,8 @@ exports.unformat = { ['31st', 31], ['1.23t', 1230000000000], ['N/A', 0], - [, 0], + [null, 0], ['', 0], - // Pass Through for Numbers [0, 0], [1, 1], @@ -29,68 +27,59 @@ exports.unformat = { [-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(); - }, + for (var i = 0; i < tests.length; i++) { + expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); - currency: function (test) { - test.expect(2); - - var tests = [ + describe('Currency', function() { + it('should unformat currency', function() { + 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); + for (var i = 0; i < tests.length; i++) { + expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); - var tests = [ + describe('Bytes', function() { + it('should unformat bytes', function() { + 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]); - } + for (var i = 0; i < tests.length; i++) { + expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); - test.done(); - }, - - percentages: function (test) { - test.expect(1); - - var tests = [ + describe('Percentages', function() { + it('should unformat percentages', function() { + 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(); - }, + for (var i = 0; i < tests.length; i++) { + expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); - time: function (test) { - test.expect(1); - - var tests = [ + describe('Time', function() { + it('should unformat time', function() { + 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 + for (var i = 0; i < tests.length; i++) { + expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/numeral/validate.js b/tests/numeral/validate.js index d36b6dea..3fef63f8 100644 --- a/tests/numeral/validate.js +++ b/tests/numeral/validate.js @@ -1,70 +1,72 @@ -var numeral = require('../../numeral'), - language = 'en'; +var numeral = require('../../numeral'); +var language = 'en'; +var expect = require('chai').expect; -//All the tests are for en or en-US -exports.validate = { - numbers: function(test) { - 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] - ]; - test.expect(tests.length); - for(var i=0; i Date: Sat, 19 Nov 2016 20:36:21 -0800 Subject: [PATCH 033/150] add karma to run in chrome and firefox --- Gruntfile.js | 38 +++++++++++++++++++++++++++++++++++-- package.json | 6 ++++++ tests/numeral/format.js | 9 +++++++-- tests/numeral/manipulate.js | 11 ++++++++--- tests/numeral/misc.js | 9 +++++++-- tests/numeral/unformat.js | 9 +++++++-- tests/numeral/validate.js | 10 ++++++++-- 7 files changed, 79 insertions(+), 13 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 31adab9a..0d42b315 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -22,7 +22,27 @@ module.exports = function(grunt) { grunt.initConfig({ mochaTest : { - all : ['tests/numeral/*.js'] + all: ['tests/numeral/*.js'] + }, + karma: { + ci: { + options: { + files: [ + 'numeral.js', + 'tests/numeral/*.js' + ], + }, + frameworks: [ + 'mocha', + 'chai' + ], + browsers: [ + 'Chrome', + 'Firefox' + ], + singleRun: true, + autoWatch: false + } }, uglify: { my_target: { @@ -68,16 +88,28 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-mocha-test'); + grunt.loadNpmTasks('grunt-karma'); grunt.registerTask('default', [ 'test' ]); grunt.registerTask('test', [ + 'jshint', + 'mochaTest', + 'karma' + ]); + + grunt.registerTask('test:npm', [ 'jshint', 'mochaTest' ]); + grunt.registerTask('test:browser', [ + 'jshint', + 'karma' + ]); + // P grunt.registerTask('build', [ 'jshint', @@ -87,5 +119,7 @@ module.exports = function(grunt) { ]); // Travis CI task. - grunt.registerTask('travis', ['test']); + grunt.registerTask('travis', [ + 'test' + ]); }; diff --git a/package.json b/package.json index b403338a..1fd3fb1f 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,13 @@ "grunt-contrib-jshint": "latest", "grunt-contrib-nodeunit": "1.0.0", "grunt-contrib-uglify": "latest", + "grunt-karma": "^2.0.0", "grunt-mocha-test": "^0.13.2", + "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", "mocha": "^3.1.2", "uglify-js": "latest" }, diff --git a/tests/numeral/format.js b/tests/numeral/format.js index 246e4193..f7f87b56 100644 --- a/tests/numeral/format.js +++ b/tests/numeral/format.js @@ -1,5 +1,10 @@ -var numeral = require('../../numeral'); -var expect = require('chai').expect; +if (!numeral) { + var numeral = require('../../numeral'); +} + +if (!expect) { + var expect = require('chai').expect; +} describe('Format', function() { diff --git a/tests/numeral/manipulate.js b/tests/numeral/manipulate.js index 28bd4517..7580415c 100644 --- a/tests/numeral/manipulate.js +++ b/tests/numeral/manipulate.js @@ -1,5 +1,10 @@ -var numeral = require('../../numeral'); -var expect = require('chai').expect; +if (!numeral) { + var numeral = require('../../numeral'); +} + +if (!expect) { + var expect = require('chai').expect; +} describe('Manipulate', function() { @@ -99,7 +104,7 @@ describe('Manipulate', function() { [0.3,0.2,0.1] ], num; - + for (var i = 0; i < tests.length; i++) { num = numeral(tests[i][0]); diff --git a/tests/numeral/misc.js b/tests/numeral/misc.js index 84c1fe0d..e2343850 100644 --- a/tests/numeral/misc.js +++ b/tests/numeral/misc.js @@ -1,5 +1,10 @@ -var numeral = require('../../numeral'); -var expect = require('chai').expect; +if (!numeral) { + var numeral = require('../../numeral'); +} + +if (!expect) { + var expect = require('chai').expect; +} describe('Misc', function() { describe('Add', function() { diff --git a/tests/numeral/unformat.js b/tests/numeral/unformat.js index 10ebc974..672cb1db 100644 --- a/tests/numeral/unformat.js +++ b/tests/numeral/unformat.js @@ -1,5 +1,10 @@ -var numeral = require('../../numeral'); -var expect = require('chai').expect; +if (!numeral) { + var numeral = require('../../numeral'); +} + +if (!expect) { + var expect = require('chai').expect; +} describe('Unformat', function() { beforeEach(function() { diff --git a/tests/numeral/validate.js b/tests/numeral/validate.js index 3fef63f8..256c71ad 100644 --- a/tests/numeral/validate.js +++ b/tests/numeral/validate.js @@ -1,6 +1,12 @@ -var numeral = require('../../numeral'); +if (!numeral) { + var numeral = require('../../numeral'); +} + +if (!expect) { + var expect = require('chai').expect; +} + var language = 'en'; -var expect = require('chai').expect; describe('Validate', function() { describe('Numbers', function() { From 83f1e3f8a24015acef6423b32bb5c93e4a25bb9a Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sat, 19 Nov 2016 21:57:06 -0800 Subject: [PATCH 034/150] saucelabs for browser tests --- Gruntfile.js | 31 ++++++++++++++++++------------- karma-ci.conf.js | 41 +++++++++++++++++++++++++++++++++++++++++ package.json | 3 +++ 3 files changed, 62 insertions(+), 13 deletions(-) create mode 100644 karma-ci.conf.js diff --git a/Gruntfile.js b/Gruntfile.js index 0d42b315..38ff90ce 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -25,23 +25,26 @@ module.exports = function(grunt) { all: ['tests/numeral/*.js'] }, karma: { - ci: { - options: { - files: [ - 'numeral.js', - 'tests/numeral/*.js' - ], - }, + options: { + files: [ + 'numeral.js', + 'tests/numeral/*.js' + ], frameworks: [ 'mocha', 'chai' ], + singleRun: true, + autoWatch: false + }, + local: { browsers: [ 'Chrome', 'Firefox' - ], - singleRun: true, - autoWatch: false + ] + }, + ci: { + configFile: 'karma-ci.conf.js' } }, uglify: { @@ -97,7 +100,7 @@ module.exports = function(grunt) { grunt.registerTask('test', [ 'jshint', 'mochaTest', - 'karma' + 'karma:local' ]); grunt.registerTask('test:npm', [ @@ -107,7 +110,7 @@ module.exports = function(grunt) { grunt.registerTask('test:browser', [ 'jshint', - 'karma' + 'karma:local' ]); // P @@ -120,6 +123,8 @@ module.exports = function(grunt) { // Travis CI task. grunt.registerTask('travis', [ - 'test' + 'jshint', + 'mochaTest', + 'karma:ci' ]); }; 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/package.json b/package.json index 1fd3fb1f..cfeac2a1 100644 --- a/package.json +++ b/package.json @@ -41,11 +41,14 @@ "grunt-contrib-uglify": "latest", "grunt-karma": "^2.0.0", "grunt-mocha-test": "^0.13.2", + "grunt-saucelabs": "*", "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", "mocha": "^3.1.2", "uglify-js": "latest" }, From 561c58624b9328fd041d52a0cb819d4157cdd84e Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sun, 20 Nov 2016 00:30:59 -0800 Subject: [PATCH 035/150] add reset function so to use especially with tests --- Gruntfile.js | 9 +- numeral.js | 85 ++++++++------- tests/languages/be-nl.js | 203 ++++++++++++++++++------------------ tests/numeral/format.js | 11 +- tests/numeral/manipulate.js | 11 +- tests/numeral/misc.js | 12 ++- tests/numeral/unformat.js | 12 ++- tests/numeral/validate.js | 16 +-- 8 files changed, 190 insertions(+), 169 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 38ff90ce..a6b0178c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -22,13 +22,18 @@ module.exports = function(grunt) { grunt.initConfig({ mochaTest : { - all: ['tests/numeral/*.js'] + all: [ + 'tests/numeral/*.js', + 'tests/languages/be-nl.js' + ] }, karma: { options: { files: [ 'numeral.js', - 'tests/numeral/*.js' + 'languages/**/*.js', + 'tests/numeral/*.js', + 'tests/languages/be-nl.js' ], frameworks: [ 'mocha', diff --git a/numeral.js b/numeral.js index cfadec82..8a2520e2 100644 --- a/numeral.js +++ b/numeral.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js - * version : 1.5.3 + * version : 1.5.4 * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ @@ -9,18 +9,23 @@ (function() { /************************************ - Constants + Variables ************************************/ var numeral, - VERSION = '1.5.3', + VERSION = '1.5.4', // internal storage for language config files languages = {}, - currentLanguage = 'en', - zeroFormat = null, - defaultFormat = '0,0', - // check for nodeJS - hasModule = (typeof module !== 'undefined' && module.exports); + defaults = { + currentLanguage: 'en', + zeroFormat: null, + defaultFormat: '0,0' + }, + options = { + currentLanguage: defaults.currentLanguage, + zeroFormat: defaults.zeroFormat, + defaultFormat: defaults.defaultFormat + }; /************************************ @@ -93,18 +98,18 @@ if (string.indexOf(':') > -1) { n._value = unformatTime(string); } else { - if (string === zeroFormat) { + if (string === options.zeroFormat) { n._value = 0; } else { - if (languages[currentLanguage].delimiters.decimal !== '.') { - string = string.replace(/\./g, '').replace(languages[currentLanguage].delimiters.decimal, '.'); + if (languages[options.currentLanguage].delimiters.decimal !== '.') { + string = string.replace(/\./g, '').replace(languages[options.currentLanguage].delimiters.decimal, '.'); } // 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 + ')?(?:\\))?)?$'); + thousandRegExp = new RegExp('[^a-zA-Z]' + languages[options.currentLanguage].abbreviations.thousand + '(?:\\)|(\\' + languages[options.currentLanguage].currency.symbol + ')?(?:\\))?)?$'); + millionRegExp = new RegExp('[^a-zA-Z]' + languages[options.currentLanguage].abbreviations.million + '(?:\\)|(\\' + languages[options.currentLanguage].currency.symbol + ')?(?:\\))?)?$'); + billionRegExp = new RegExp('[^a-zA-Z]' + languages[options.currentLanguage].abbreviations.billion + '(?:\\)|(\\' + languages[options.currentLanguage].currency.symbol + ')?(?:\\))?)?$'); + trillionRegExp = new RegExp('[^a-zA-Z]' + languages[options.currentLanguage].abbreviations.trillion + '(?:\\)|(\\' + languages[options.currentLanguage].currency.symbol + ')?(?:\\))?)?$'); // see if bytes are there so that we can multiply to the correct number for (power = 0; power <= suffixes.length; power++) { @@ -156,18 +161,18 @@ // the symbol appears before the "(" or "-" spliceIndex = 0; } - output.splice(spliceIndex, 0, languages[currentLanguage].currency.symbol + space); + output.splice(spliceIndex, 0, languages[options.currentLanguage].currency.symbol + space); output = output.join(''); } else { - output = languages[currentLanguage].currency.symbol + space + output; + output = languages[options.currentLanguage].currency.symbol + space + output; } } else { if (output.indexOf(')') > -1) { output = output.split(''); - output.splice(-1, 0, space + languages[currentLanguage].currency.symbol); + output.splice(-1, 0, space + languages[options.currentLanguage].currency.symbol); output = output.join(''); } else { - output = output + space + languages[currentLanguage].currency.symbol; + output = output + space + languages[options.currentLanguage].currency.symbol; } } @@ -251,8 +256,8 @@ neg = false; // check if number is zero and a custom zero format has been set - if (value === 0 && zeroFormat !== null) { - return zeroFormat; + if (value === 0 && options.zeroFormat !== null) { + return options.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 @@ -283,19 +288,19 @@ if (abs >= Math.pow(10, 12) && !abbrForce || abbrT) { // trillion - abbr = abbr + languages[currentLanguage].abbreviations.trillion; + abbr = abbr + languages[options.currentLanguage].abbreviations.trillion; value = value / Math.pow(10, 12); } else if (abs < Math.pow(10, 12) && abs >= Math.pow(10, 9) && !abbrForce || abbrB) { // billion - abbr = abbr + languages[currentLanguage].abbreviations.billion; + abbr = abbr + languages[options.currentLanguage].abbreviations.billion; value = value / Math.pow(10, 9); } else if (abs < Math.pow(10, 9) && abs >= Math.pow(10, 6) && !abbrForce || abbrM) { // million - abbr = abbr + languages[currentLanguage].abbreviations.million; + abbr = abbr + languages[options.currentLanguage].abbreviations.million; value = value / Math.pow(10, 6); } else if (abs < Math.pow(10, 6) && abs >= Math.pow(10, 3) && !abbrForce || abbrK) { // thousand - abbr = abbr + languages[currentLanguage].abbreviations.thousand; + abbr = abbr + languages[options.currentLanguage].abbreviations.thousand; value = value / Math.pow(10, 3); } } @@ -334,7 +339,7 @@ format = format.replace('o', ''); } - ord = ord + languages[currentLanguage].ordinal(value); + ord = ord + languages[options.currentLanguage].ordinal(value); } if (format.indexOf('[.]') > -1) { @@ -358,7 +363,7 @@ w = d.split('.')[0]; if (d.split('.')[1].length) { - d = languages[currentLanguage].delimiters.decimal + d.split('.')[1]; + d = languages[options.currentLanguage].delimiters.decimal + d.split('.')[1]; } else { d = ''; } @@ -377,7 +382,7 @@ } if (thousands > -1) { - w = w.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + languages[currentLanguage].delimiters.thousands); + w = w.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + languages[options.currentLanguage].delimiters.thousands); } if (format.indexOf('.') === 0) { @@ -412,12 +417,13 @@ return obj instanceof Numeral; }; + // 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; + return options.currentLanguage; } key = key.toLowerCase(); @@ -426,7 +432,8 @@ if (!languages[key]) { throw new Error('Unknown language : ' + key); } - currentLanguage = key; + + options.currentLanguage = key; } if (values || !languages[key]) { @@ -436,12 +443,18 @@ return numeral; }; + numeral.reset = function() { + for (var property in defaults) { + options[property] = defaults[property]; + } + }; + // 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]; + return languages[options.currentLanguage]; } if (!languages[key]) { @@ -475,11 +488,11 @@ }); numeral.zeroFormat = function(format) { - zeroFormat = typeof(format) === 'string' ? format : null; + options.zeroFormat = typeof(format) === 'string' ? format : null; }; numeral.defaultFormat = function(format) { - defaultFormat = typeof(format) === 'string' ? format : '0.0'; + options.defaultFormat = typeof(format) === 'string' ? format : '0.0'; }; numeral.validate = function(val, culture) { @@ -677,7 +690,7 @@ format : function (inputString, roundingFunction) { return formatNumeral(this, - inputString ? inputString : defaultFormat, + inputString ? inputString : options.defaultFormat, (roundingFunction !== undefined) ? roundingFunction : Math.round ); }, @@ -686,7 +699,7 @@ if (Object.prototype.toString.call(inputString) === '[object Number]') { return inputString; } - return unformatNumeral(this, inputString ? inputString : defaultFormat); + return unformatNumeral(this, inputString ? inputString : options.defaultFormat); }, value: function() { @@ -752,7 +765,7 @@ ************************************/ // CommonJS module is defined - if (hasModule) { + if (typeof module !== 'undefined' && module.exports) { module.exports = numeral; } diff --git a/tests/languages/be-nl.js b/tests/languages/be-nl.js index 1ac29771..dde49cf8 100644 --- a/tests/languages/be-nl.js +++ b/tests/languages/be-nl.js @@ -1,107 +1,102 @@ -var numeral = require('../../numeral'), - language = require('../../languages/be-nl'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/be-nl'); +} -numeral.language('be-nl', language); +describe('Language: be-nl', function() { -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]); - } + before(function() { + numeral.language('be-nl', language); - 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 + numeral.language('be-nl'); + }); + + after(function() { + numeral.reset(); + }); + + describe('Format', function() { + it('should format be-nl', 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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/numeral/format.js b/tests/numeral/format.js index f7f87b56..7b246381 100644 --- a/tests/numeral/format.js +++ b/tests/numeral/format.js @@ -1,12 +1,13 @@ -if (!numeral) { - var numeral = require('../../numeral'); -} - -if (!expect) { +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); var expect = require('chai').expect; } describe('Format', function() { + after(function() { + numeral.reset(); + }); describe('Default', function() { it('should set a default format', function() { diff --git a/tests/numeral/manipulate.js b/tests/numeral/manipulate.js index 7580415c..da0c522a 100644 --- a/tests/numeral/manipulate.js +++ b/tests/numeral/manipulate.js @@ -1,12 +1,13 @@ -if (!numeral) { - var numeral = require('../../numeral'); -} - -if (!expect) { +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); var expect = require('chai').expect; } describe('Manipulate', function() { + after(function() { + numeral.reset(); + }); describe('Add', function() { it('should add', function() { diff --git a/tests/numeral/misc.js b/tests/numeral/misc.js index e2343850..3110ded9 100644 --- a/tests/numeral/misc.js +++ b/tests/numeral/misc.js @@ -1,12 +1,14 @@ -if (!numeral) { - var numeral = require('../../numeral'); -} - -if (!expect) { +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); var expect = require('chai').expect; } describe('Misc', function() { + after(function() { + numeral.reset(); + }); + describe('Add', function() { it('should return a value', function() { var tests = [ diff --git a/tests/numeral/unformat.js b/tests/numeral/unformat.js index 672cb1db..290d18df 100644 --- a/tests/numeral/unformat.js +++ b/tests/numeral/unformat.js @@ -1,8 +1,6 @@ -if (!numeral) { - var numeral = require('../../numeral'); -} - -if (!expect) { +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); var expect = require('chai').expect; } @@ -11,6 +9,10 @@ describe('Unformat', function() { numeral.zeroFormat('N/A'); }); + after(function() { + numeral.reset(); + }); + describe('Numbers', function() { it('should unformat a number', function() { var tests = [ diff --git a/tests/numeral/validate.js b/tests/numeral/validate.js index 256c71ad..9a16bb6d 100644 --- a/tests/numeral/validate.js +++ b/tests/numeral/validate.js @@ -1,14 +1,16 @@ -if (!numeral) { - var numeral = require('../../numeral'); -} - -if (!expect) { +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); var expect = require('chai').expect; } -var language = 'en'; - describe('Validate', function() { + var language = 'en'; + + after(function() { + numeral.reset(); + }); + describe('Numbers', function() { it('should validate numbers', function() { var tests = [ From ac9942962be982f29ff9a5f2b0dc58c0440afb9f Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sun, 20 Nov 2016 00:34:37 -0800 Subject: [PATCH 036/150] second language test --- Gruntfile.js | 3 +- tests/languages/be-nl.js | 4 +- tests/languages/chs.js | 191 +++++++++++++++++++-------------------- 3 files changed, 97 insertions(+), 101 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index a6b0178c..0fc9ffee 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -24,7 +24,8 @@ module.exports = function(grunt) { mochaTest : { all: [ 'tests/numeral/*.js', - 'tests/languages/be-nl.js' + 'tests/languages/be-nl.js', + 'tests/languages/chs.js' ] }, karma: { diff --git a/tests/languages/be-nl.js b/tests/languages/be-nl.js index dde49cf8..e9816eee 100644 --- a/tests/languages/be-nl.js +++ b/tests/languages/be-nl.js @@ -17,8 +17,8 @@ describe('Language: be-nl', function() { numeral.reset(); }); - describe('Format', function() { - it('should format be-nl', function() { + describe('Number', function() { + it('should format a number', function() { var tests = [ [10000,'0,0.0000','10 000,0000'], [10000.23,'0,0','10 000'], diff --git a/tests/languages/chs.js b/tests/languages/chs.js index c9afe9f2..e5b50ff2 100644 --- a/tests/languages/chs.js +++ b/tests/languages/chs.js @@ -1,101 +1,96 @@ -var numeral = require('../../numeral'); -var language = require('../../languages/chs'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/chs'); +} -numeral.language('chs', language); +describe('Language: chs', function() { -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]); - } + before(function() { + numeral.language('chs', language); - 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 + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); From 5e8831b051c73b97350ff0b39ffe665c897ffe1c Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sun, 20 Nov 2016 12:02:54 -0800 Subject: [PATCH 037/150] update all language tests --- Gruntfile.js | 13 +-- languages.js | 88 +++++++++++----- languages/es-ES.js | 4 +- languages/ja.js | 2 +- languages/lv.js | 2 +- min/languages.min.js | 43 ++++---- min/languages/es-ES.min.js | 4 +- min/languages/ja.min.js | 2 +- min/languages/lv.min.js | 4 +- min/numeral.min.js | 4 +- tests/languages/cs.js | 193 +++++++++++++++++----------------- tests/languages/da-dk.js | 191 +++++++++++++++++----------------- tests/languages/de-ch.js | 191 +++++++++++++++++----------------- tests/languages/de.js | 191 +++++++++++++++++----------------- tests/languages/en-gb.js | 191 +++++++++++++++++----------------- tests/languages/en.js | 183 +++++++++++++++----------------- tests/languages/es-ES.js | 191 +++++++++++++++++----------------- tests/languages/es.js | 191 +++++++++++++++++----------------- tests/languages/et.js | 191 +++++++++++++++++----------------- tests/languages/fi.js | 191 +++++++++++++++++----------------- tests/languages/fr-CA.js | 191 +++++++++++++++++----------------- tests/languages/fr-ch.js | 191 +++++++++++++++++----------------- tests/languages/fr.js | 191 +++++++++++++++++----------------- tests/languages/hu.js | 191 +++++++++++++++++----------------- tests/languages/it.js | 191 +++++++++++++++++----------------- tests/languages/ja.js | 191 +++++++++++++++++----------------- tests/languages/lv.js | 191 +++++++++++++++++----------------- tests/languages/nl-nl.js | 207 ++++++++++++++++++------------------- tests/languages/pl.js | 193 +++++++++++++++++----------------- tests/languages/pt-br.js | 191 +++++++++++++++++----------------- tests/languages/pt-pt.js | 191 +++++++++++++++++----------------- tests/languages/ru-UA.js | 193 +++++++++++++++++----------------- tests/languages/ru.js | 193 +++++++++++++++++----------------- tests/languages/sk.js | 191 +++++++++++++++++----------------- tests/languages/th.js | 191 +++++++++++++++++----------------- tests/languages/tr.js | 191 +++++++++++++++++----------------- tests/languages/uk-UA.js | 193 +++++++++++++++++----------------- 37 files changed, 2617 insertions(+), 2724 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 0fc9ffee..41525e26 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -24,17 +24,16 @@ module.exports = function(grunt) { mochaTest : { all: [ 'tests/numeral/*.js', - 'tests/languages/be-nl.js', - 'tests/languages/chs.js' + 'tests/languages/*.js' ] }, karma: { options: { files: [ 'numeral.js', - 'languages/**/*.js', + 'languages/*.js', 'tests/numeral/*.js', - 'tests/languages/be-nl.js' + 'tests/languages/*.js' ], frameworks: [ 'mocha', @@ -64,7 +63,7 @@ module.exports = function(grunt) { concat: { languages: { src: [ - 'languages/**/*.js' + 'languages/*.js' ], dest: 'languages.js' } @@ -73,7 +72,7 @@ module.exports = function(grunt) { all: [ 'Gruntfile.js', 'numeral.js', - 'languages/**/*.js' + 'languages/*.js' ], options: { 'node': true, @@ -121,8 +120,6 @@ module.exports = function(grunt) { // P grunt.registerTask('build', [ - 'jshint', - 'nodeunit', 'concat', 'uglify' ]); diff --git a/languages.js b/languages.js index 3cdddc9d..f588f659 100644 --- a/languages.js +++ b/languages.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! @preserve * numeral.js language configuration * language : belgium-dutch (be-nl) * author : Dieter Luypaert : https://github.com/moeriki @@ -33,7 +33,7 @@ this.numeral.language('be-nl', language); } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : simplified chinese * author : badplum : https://github.com/badplum @@ -103,7 +103,7 @@ } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : danish denmark (dk) * author : Michael Storgaard : https://github.com/mstorgaard @@ -137,11 +137,11 @@ this.numeral.language('da-dk', language); } }()); -/*! @preserve +/*! @preserve * 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: { @@ -171,7 +171,7 @@ this.numeral.language('de-ch', language); } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium * author : Marco Krage : https://github.com/sinky @@ -205,7 +205,7 @@ this.numeral.language('de', language); } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : english united kingdom (uk) * author : Dan Ristic : https://github.com/dristic @@ -279,11 +279,11 @@ } // Browser if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('es', language); + this.numeral.language('es-ES', language); } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : spanish * author : Hernan Garcia : https://github.com/hgarcia @@ -304,7 +304,7 @@ var b = number % 10; return (b === 1 || b === 3) ? 'er' : (b === 2) ? 'do' : - (b === 7 || b === 0) ? 'mo' : + (b === 7 || b === 0) ? 'mo' : (b === 8) ? 'vo' : (b === 9) ? 'no' : 'to'; }, @@ -323,7 +323,7 @@ } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : Estonian * author : Illimar Tambek : https://github.com/ragulka @@ -361,7 +361,7 @@ } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : Finnish * author : Sami Saada : https://github.com/samitheberber @@ -430,7 +430,7 @@ this.numeral.language('fr-CA', language); } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : french (fr-ch) * author : Adam Draper : https://github.com/adamwdraper @@ -465,7 +465,7 @@ } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : french (fr) * author : Adam Draper : https://github.com/adamwdraper @@ -533,7 +533,7 @@ this.numeral.language('hu', language); } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : italian Italy (it) * author : Giacomo Trombi : http://cinquepunti.it @@ -603,6 +603,40 @@ }()); /*! @preserve + * numeral.js language configuration + * language : Latvian (lv) + * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks + */ +(function () { + var language = { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: ' tūkst.', + million: ' milj.', + billion: ' mljrd.', + trillion: ' trilj.' + }, + 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('lv', language); + } +}()); + +/*! @preserve * numeral.js language configuration * language : netherlands-dutch (nl-nl) * author : Dave Clayton : https://github.com/davedx @@ -637,7 +671,7 @@ this.numeral.language('nl-nl', language); } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : polish (pl) * author : Dominik Bulaj : https://github.com/dominikbulaj @@ -671,7 +705,7 @@ this.numeral.language('pl', language); } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : portuguese brazil (pt-br) * author : Ramiro Varandas Jr : https://github.com/ramirovjr @@ -705,7 +739,7 @@ this.numeral.language('pt-br', language); } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : portuguese (pt-pt) * author : Diogo Resende : https://github.com/dresende @@ -756,10 +790,10 @@ trillion: 't' }, ordinal: function () { - // not ideal, but since in Russian it can taken on + // not ideal, but since in Russian it can taken on // different forms (masculine, feminine, neuter) // this is all we can do - return '.'; + return '.'; }, currency: { symbol: '\u20B4' @@ -776,7 +810,7 @@ } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : russian (ru) * author : Anatoli Papirovski : https://github.com/apapirovski @@ -794,10 +828,10 @@ trillion: 't' }, ordinal: function () { - // not ideal, but since in Russian it can taken on + // not ideal, but since in Russian it can taken on // different forms (masculine, feminine, neuter) // this is all we can do - return '.'; + return '.'; }, currency: { symbol: 'руб.' @@ -849,7 +883,7 @@ } }()); -/*! @preserve +/*! @preserve * numeral.js language configuration * language : thai (th) * author : Sathit Jittanupat : https://github.com/jojosati @@ -884,7 +918,7 @@ } }()); -/*! @preserve +/*! @preserve * 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 @@ -968,10 +1002,10 @@ 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' diff --git a/languages/es-ES.js b/languages/es-ES.js index 7df615e4..f1e61bdd 100644 --- a/languages/es-ES.js +++ b/languages/es-ES.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! @preserve * numeral.js language configuration * language : spanish Spain * author : Hernan Garcia : https://github.com/hgarcia @@ -34,6 +34,6 @@ } // Browser if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('es', language); + this.numeral.language('es-ES', language); } }()); diff --git a/languages/ja.js b/languages/ja.js index d7d41aa9..c1c28e09 100644 --- a/languages/ja.js +++ b/languages/ja.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! @preserve * numeral.js language configuration * language : japanese * author : teppeis : https://github.com/teppeis diff --git a/languages/lv.js b/languages/lv.js index 4abb22e8..9cbf4851 100644 --- a/languages/lv.js +++ b/languages/lv.js @@ -1,4 +1,4 @@ -/*! +/*! @preserve * numeral.js language configuration * language : Latvian (lv) * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks diff --git a/min/languages.min.js b/min/languages.min.js index 32d97531..e1072532 100644 --- a/min/languages.min.js +++ b/min/languages.min.js @@ -1,9 +1,9 @@ -/*! @preserve +/*! @preserve * 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&&b<=1||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)}(),/*! @preserve +!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&&b<=1||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)}(),/*! @preserve * numeral.js language configuration * language : simplified chinese * author : badplum : https://github.com/badplum @@ -13,22 +13,22 @@ function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand * 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)}(),/*! @preserve +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)}(),/*! @preserve * 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(a){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)}(),/*! @preserve +function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mia",trillion:"b"},ordinal:function(a){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)}(),/*! @preserve * 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(a){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)}(),/*! @preserve +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){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)}(),/*! @preserve * 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(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("de",a)}(),/*! @preserve +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("de",a)}(),/*! @preserve * numeral.js language configuration * language : english united kingdom (uk) * author : Dan Ristic : https://github.com/dristic @@ -38,12 +38,12 @@ function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand * 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)}(),/*! @preserve +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-ES",a)}(),/*! @preserve * 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)}(),/*! @preserve +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)}(),/*! @preserve * numeral.js language configuration * language : Estonian * author : Illimar Tambek : https://github.com/ragulka @@ -51,7 +51,7 @@ function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand * 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(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("et",a)}(),/*! @preserve +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("et",a)}(),/*! @preserve * numeral.js language configuration * language : Finnish * author : Sami Saada : https://github.com/samitheberber @@ -61,12 +61,12 @@ function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand * 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)}(),/*! @preserve +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)}(),/*! @preserve * 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)}(),/*! @preserve +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)}(),/*! @preserve * numeral.js language configuration * language : french (fr) * author : Adam Draper : https://github.com/adamwdraper @@ -76,7 +76,7 @@ function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand * 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(a){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)}(),/*! @preserve +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){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)}(),/*! @preserve * numeral.js language configuration * language : italian Italy (it) * author : Giacomo Trombi : http://cinquepunti.it @@ -87,26 +87,31 @@ function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand * author : teppeis : https://github.com/teppeis */ function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("ja",a)}(),/*! @preserve + * numeral.js language configuration + * language : Latvian (lv) + * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks + */ +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("lv",a)}(),/*! @preserve * 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&&b<=1||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)}(),/*! @preserve +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&&b<=1||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)}(),/*! @preserve * 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(a){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)}(),/*! @preserve +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){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)}(),/*! @preserve * 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(a){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)}(),/*! @preserve +function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mil",million:"milhões",billion:"b",trillion:"t"},ordinal:function(a){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)}(),/*! @preserve * 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(a){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)}(),/*! @preserve +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){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)}(),/*! @preserve * numeral.js language configuration * language : russian (ru) * author : Anatoli Papirovski : https://github.com/apapirovski @@ -116,14 +121,14 @@ function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand * 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)}(),/*! @preserve +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)}(),/*! @preserve * 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(a){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("th",a)}(),/*! @preserve +function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("th",a)}(),/*! @preserve * 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)}(); +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/es-ES.min.js b/min/languages/es-ES.min.js index 16b80447..16f2fd45 100644 --- a/min/languages/es-ES.min.js +++ b/min/languages/es-ES.min.js @@ -1,6 +1,6 @@ -/*! @preserve +/*! @preserve * 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 +!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-ES",a)}(); \ No newline at end of file diff --git a/min/languages/ja.min.js b/min/languages/ja.min.js index a4a77164..908b028c 100644 --- a/min/languages/ja.min.js +++ b/min/languages/ja.min.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! @preserve * numeral.js language configuration * language : japanese * author : teppeis : https://github.com/teppeis diff --git a/min/languages/lv.min.js b/min/languages/lv.min.js index db627a86..31237ccd 100644 --- a/min/languages/lv.min.js +++ b/min/languages/lv.min.js @@ -1,6 +1,6 @@ -/*! +/*! @preserve * numeral.js language configuration * language : Latvian (lv) * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks */ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("lv",a)}(); \ No newline at end of file +!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("lv",a)}(); \ No newline at end of file diff --git a/min/numeral.min.js b/min/numeral.min.js index 09b1be94..d2a06a4a 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -1,8 +1,8 @@ /*! @preserve * numeral.js - * version : 1.5.3 + * version : 1.5.4 * 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));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),f<=1?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(f-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+":"+(c<10?"0"+c:c)+":"+(d<10?"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&&a0&&(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,d,e){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,d,e){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,c,d){var e=l(a,b);return a*e*(b*e)/(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=l(a,b);return a*e/(b*e)}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); +(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.zeroFormat)a._value=0;else{for("."!==o[q.currentLanguage].delimiters.decimal&&(b=b.replace(/\./g,"").replace(o[q.currentLanguage].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.thousand+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.million+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.billion+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.trillion+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),g=0;g<=j.length&&!(k=b.indexOf(j[g])>-1&&Math.pow(1024,g+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),f<=1?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(f-1?(e=e.split(""),e.splice(-1,0,j+o[q.currentLanguage].currency.symbol),e=e.join("")):e=e+j+o[q.currentLanguage].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+":"+(c<10?"0"+c:c)+":"+(d<10?"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="",p=!1,r=!1,s=!1,t=!1,u=!1,v="",w="",x=Math.abs(a),y=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],z="",A=!1;if(0===a&&null!==q.zeroFormat)return q.zeroFormat;if(c.indexOf("(")>-1?(k=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(l=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(p=c.indexOf("aK")>=0,r=c.indexOf("aM")>=0,s=c.indexOf("aB")>=0,t=c.indexOf("aT")>=0,u=p||r||s||t,c.indexOf(" a")>-1?(n=" ",c=c.replace(" a","")):c=c.replace("a",""),x>=Math.pow(10,12)&&!u||t?(n+=o[q.currentLanguage].abbreviations.trillion,a/=Math.pow(10,12)):x=Math.pow(10,9)&&!u||s?(n+=o[q.currentLanguage].abbreviations.billion,a/=Math.pow(10,9)):x=Math.pow(10,6)&&!u||r?(n+=o[q.currentLanguage].abbreviations.million,a/=Math.pow(10,6)):(x=Math.pow(10,3)&&!u||p)&&(n+=o[q.currentLanguage].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("b")>-1)for(c.indexOf(" b")>-1?(v=" ",c=c.replace(" b","")):c=c.replace("b",""),g=0;g<=y.length;g++)if(e=Math.pow(1024,g),f=Math.pow(1024,g+1),a>=e&&a0&&(a/=e);break}return c.indexOf("o")>-1&&(c.indexOf(" o")>-1?(w=" ",c=c.replace(" o","")):c=c.replace("o",""),w+=o[q.currentLanguage].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("["),z=b(a,i[0].length+i[1].length,d,i[1].length)):z=b(a,i.length,d),h=z.split(".")[0],z=z.split(".")[1].length?o[q.currentLanguage].delimiters.decimal+z.split(".")[1]:"",m&&0===Number(z.slice(1))&&(z="")):h=b(a,null,d),h.indexOf("-")>-1&&(h=h.slice(1),A=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+o[q.currentLanguage].delimiters.thousands)),0===c.indexOf(".")&&(h=""),(k&&A?"(":"")+(!k&&A?"-":"")+(!A&&l?"+":"")+h+z+(w?w:"")+(n?n:"")+(v?v:"")+(k&&A?")":"")}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.4",o={},p={currentLanguage:"en",zeroFormat:null,defaultFormat:"0,0"},q={currentLanguage:p.currentLanguage,zeroFormat:p.zeroFormat,defaultFormat:p.defaultFormat};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 q.currentLanguage;if(a=a.toLowerCase(),a&&!b){if(!o[a])throw new Error("Unknown language : "+a);q.currentLanguage=a}return!b&&o[a]||j(a,b),m},m.reset=function(){for(var a in p)q[a]=p[a]},m.languageData=function(a){if(!a)return o[q.currentLanguage];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.zeroFormat="string"==typeof a?a:null},m.defaultFormat=function(a){q.defaultFormat="string"==typeof a?a:"0.0"},m.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=m.languageData(b)}catch(a){i=m.languageData(m.language())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),(null===j||(a=a.substr(1),j[0]===e))&&(j=a.match(/[^\d]+$/),(null===j||(a=a.slice(0,-1),j[0]===g.thousand||j[0]===g.million||j[0]===g.billion||j[0]===g.trillion))&&(h=new RegExp(d+"{2}"),!a.match(/[^\d.,]/g)&&(f=a.split(c),!(f.length>2)&&(f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/)))))},"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:q.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:d(this,a?a:q.defaultFormat)},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,d,e){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,d,e){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,c,d){var e=l(a,b);return a*e*(b*e)/(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=l(a,b);return a*e/(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(m(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(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 diff --git a/tests/languages/cs.js b/tests/languages/cs.js index 7be84aa1..af797538 100644 --- a/tests/languages/cs.js +++ b/tests/languages/cs.js @@ -1,102 +1,97 @@ -var numeral = require('../../numeral'), - language = require('../../languages/cs'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/cs'); +} -numeral.language('cs', language); +describe('Language: cs', function() { -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]); - } + before(function() { + numeral.language('cs', language); - 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 + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/languages/da-dk.js b/tests/languages/da-dk.js index 2393eb1c..17f5798f 100644 --- a/tests/languages/da-dk.js +++ b/tests/languages/da-dk.js @@ -1,101 +1,96 @@ -var numeral = require('../../numeral'), - language = require('../../languages/da-dk'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/da-dk'); +} -numeral.language('da-dk', language); +describe('Language: da-dk', function() { -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]); - } + before(function() { + numeral.language('da-dk', language); - 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 + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/languages/de-ch.js b/tests/languages/de-ch.js index bb989359..9cae4b1d 100644 --- a/tests/languages/de-ch.js +++ b/tests/languages/de-ch.js @@ -1,101 +1,96 @@ -var numeral = require('../../numeral'), - language = require('../../languages/de-ch'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/de-ch'); +} -numeral.language('de-ch', language); +describe('Language: de-ch', function() { -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]); - } + before(function() { + numeral.language('de-ch', language); - 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 + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/languages/de.js b/tests/languages/de.js index 3860d66a..8daae61a 100644 --- a/tests/languages/de.js +++ b/tests/languages/de.js @@ -1,101 +1,96 @@ -var numeral = require('../../numeral'), - language = require('../../languages/de'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/de'); +} -numeral.language('de', language); +describe('Language: de', function() { -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]); - } + before(function() { + numeral.language('de', language); - 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 + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/languages/en-gb.js b/tests/languages/en-gb.js index 45fb975b..cd4d05f7 100644 --- a/tests/languages/en-gb.js +++ b/tests/languages/en-gb.js @@ -1,101 +1,96 @@ -var numeral = require('../../numeral'), - language = require('../../languages/en-gb'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/en-gb'); +} -numeral.language('en-gb', language); +describe('Language: en-gb', function() { -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]); - } + before(function() { + numeral.language('en-gb', language); - 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 + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/languages/en.js b/tests/languages/en.js index 48a34f37..97e76650 100644 --- a/tests/languages/en.js +++ b/tests/languages/en.js @@ -1,98 +1,85 @@ -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 +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; +} + +describe('Language: en', function() { + + 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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/languages/es-ES.js b/tests/languages/es-ES.js index a0db5368..08311618 100644 --- a/tests/languages/es-ES.js +++ b/tests/languages/es-ES.js @@ -1,101 +1,96 @@ -var numeral = require('../../numeral'), - language = require('../../languages/es-ES'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/es-ES'); +} -numeral.language('es-ES', language); +describe('Language: es-ES', function() { -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]); - } + before(function() { + numeral.language('es-ES', language); - 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 + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/languages/es.js b/tests/languages/es.js index 06843184..04a2b271 100644 --- a/tests/languages/es.js +++ b/tests/languages/es.js @@ -1,101 +1,96 @@ -var numeral = require('../../numeral'), - language = require('../../languages/es'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/es'); +} -numeral.language('es', language); +describe('Language: es', function() { -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]); - } + before(function() { + numeral.language('es', language); - 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 + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/languages/et.js b/tests/languages/et.js index 1f1e54a3..3ec74a4c 100644 --- a/tests/languages/et.js +++ b/tests/languages/et.js @@ -1,101 +1,96 @@ -var numeral = require('../../numeral'), - language = require('../../languages/et'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/et'); +} -numeral.language('et', language); +describe('Language: et', function() { -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]); - } + before(function() { + numeral.language('et', language); - 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 + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/languages/fi.js b/tests/languages/fi.js index 2637f074..dfd22a1d 100644 --- a/tests/languages/fi.js +++ b/tests/languages/fi.js @@ -1,101 +1,96 @@ -var numeral = require('../../numeral'), - language = require('../../languages/fi'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/fi'); +} -numeral.language('fi', language); +describe('Language: fi', function() { -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]); - } + before(function() { + numeral.language('fi', language); - 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 + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/languages/fr-CA.js b/tests/languages/fr-CA.js index 8ad94bc3..24da89c5 100644 --- a/tests/languages/fr-CA.js +++ b/tests/languages/fr-CA.js @@ -1,101 +1,96 @@ -var numeral = require('../../numeral'), - language = require('../../languages/fr-CA'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/fr-CA'); +} -numeral.language('fr-CA', language); +describe('Language: fr-CA', function() { -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]); - } + before(function() { + numeral.language('fr-CA', language); - 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 + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/languages/fr-ch.js b/tests/languages/fr-ch.js index 14a9a22d..aeb96800 100644 --- a/tests/languages/fr-ch.js +++ b/tests/languages/fr-ch.js @@ -1,101 +1,96 @@ -var numeral = require('../../numeral'), - language = require('../../languages/fr-ch'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/fr-ch'); +} -numeral.language('fr-ch', language); +describe('Language: fr-ch', function() { -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]); - } + before(function() { + numeral.language('fr-ch', language); - 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 + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/languages/fr.js b/tests/languages/fr.js index 3a461538..b03627eb 100644 --- a/tests/languages/fr.js +++ b/tests/languages/fr.js @@ -1,101 +1,96 @@ -var numeral = require('../../numeral'), - language = require('../../languages/fr'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/fr'); +} -numeral.language('fr', language); +describe('Language: fr', function() { -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]); - } + before(function() { + numeral.language('fr', language); - 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 + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/languages/hu.js b/tests/languages/hu.js index 407baaae..6a50ef8a 100644 --- a/tests/languages/hu.js +++ b/tests/languages/hu.js @@ -1,101 +1,96 @@ -var numeral = require('../../numeral'), - language = require('../../languages/hu'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/hu'); +} -numeral.language('hu', language); +describe('Language: hu', function() { -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]); - } + before(function() { + numeral.language('hu', language); - 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 + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/languages/it.js b/tests/languages/it.js index 0d610793..7e7b3dc3 100644 --- a/tests/languages/it.js +++ b/tests/languages/it.js @@ -1,101 +1,96 @@ -var numeral = require('../../numeral'), - language = require('../../languages/it'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/it'); +} -numeral.language('it', language); +describe('Language: it', function() { -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]); - } + before(function() { + numeral.language('it', language); - 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 + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/languages/ja.js b/tests/languages/ja.js index 6e58bd82..26d89627 100644 --- a/tests/languages/ja.js +++ b/tests/languages/ja.js @@ -1,101 +1,96 @@ -var numeral = require('../../numeral'), - language = require('../../languages/ja'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/ja'); +} -numeral.language('ja', language); +describe('Language: ja', function() { -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]); - } + before(function() { + numeral.language('ja', language); - 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 + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/languages/lv.js b/tests/languages/lv.js index 31109853..e6581d8c 100644 --- a/tests/languages/lv.js +++ b/tests/languages/lv.js @@ -1,101 +1,96 @@ -var numeral = require('../../numeral'), - language = require('../../languages/lv'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/lv'); +} -numeral.language('lv', language); +describe('Language: lv', function() { -exports['language:lv'] = { - setUp: function (callback) { - numeral.language('lv'); - 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 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++) { - 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 milj.'] - ]; - - for (var i = 0; i < tests.length; i++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } + before(function() { + numeral.language('lv', language); - 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 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++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/languages/nl-nl.js b/tests/languages/nl-nl.js index ce49b07e..32c93085 100644 --- a/tests/languages/nl-nl.js +++ b/tests/languages/nl-nl.js @@ -1,109 +1,104 @@ -var numeral = require('../../numeral'), - language = require('../../languages/nl-nl'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/nl-nl'); +} -numeral.language('nl-nl', language); +describe('Language: nl-nl', function() { -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]); - } + before(function() { + numeral.language('nl-nl', language); - 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 + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/languages/pl.js b/tests/languages/pl.js index 51e5e2d4..a7c086bc 100644 --- a/tests/languages/pl.js +++ b/tests/languages/pl.js @@ -1,102 +1,97 @@ -var numeral = require('../../numeral'), - language = require('../../languages/pl'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/pl'); +} -numeral.language('pl', language); +describe('Language: pl', function() { -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]); - } + before(function() { + numeral.language('pl', language); - 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 + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/languages/pt-br.js b/tests/languages/pt-br.js index 965965a1..99d95b15 100644 --- a/tests/languages/pt-br.js +++ b/tests/languages/pt-br.js @@ -1,101 +1,96 @@ -var numeral = require('../../numeral'), - language = require('../../languages/pt-br'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/pt-br'); +} -numeral.language('pt-br', language); +describe('Language: pt-br', function() { -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]); - } + before(function() { + numeral.language('pt-br', language); - 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 + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/languages/pt-pt.js b/tests/languages/pt-pt.js index d6d1221e..7cf49103 100644 --- a/tests/languages/pt-pt.js +++ b/tests/languages/pt-pt.js @@ -1,101 +1,96 @@ -var numeral = require('../../numeral'), - language = require('../../languages/pt-pt'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/pt-pt'); +} -numeral.language('pt-pt', language); +describe('Language: pt-pt', function() { -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]); - } + before(function() { + numeral.language('pt-pt', language); - 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 + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/languages/ru-UA.js b/tests/languages/ru-UA.js index 36651dce..f533cc48 100644 --- a/tests/languages/ru-UA.js +++ b/tests/languages/ru-UA.js @@ -1,102 +1,97 @@ -var numeral = require('../../numeral'), - language = require('../../languages/ru-UA'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/ru-UA'); +} -numeral.language('ru-UA', language); +describe('Language: ru-UA', function() { -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]); - } + before(function() { + numeral.language('ru-UA', language); - 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 + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/languages/ru.js b/tests/languages/ru.js index 90ec7723..aff12614 100644 --- a/tests/languages/ru.js +++ b/tests/languages/ru.js @@ -1,102 +1,97 @@ -var numeral = require('../../numeral'), - language = require('../../languages/ru'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/ru'); +} -numeral.language('ru', language); +describe('Language: ru', function() { -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]); - } + before(function() { + numeral.language('ru', language); - 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 + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/languages/sk.js b/tests/languages/sk.js index 6e40ba0f..28a63713 100644 --- a/tests/languages/sk.js +++ b/tests/languages/sk.js @@ -1,101 +1,96 @@ -var numeral = require('../../numeral'), - language = require('../../languages/sk'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/sk'); +} -numeral.language('sk', language); +describe('Language: sk', function() { -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]); - } + before(function() { + numeral.language('sk', language); - 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 + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/languages/th.js b/tests/languages/th.js index e0209aa6..31538981 100644 --- a/tests/languages/th.js +++ b/tests/languages/th.js @@ -1,101 +1,96 @@ -var numeral = require('../../numeral'), - language = require('../../languages/th'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/th'); +} -numeral.language('th', language); +describe('Language: th', function() { -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]); - } + before(function() { + numeral.language('th', language); - 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(); - } -}; + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/languages/tr.js b/tests/languages/tr.js index 3a34d348..30dffe9a 100644 --- a/tests/languages/tr.js +++ b/tests/languages/tr.js @@ -1,101 +1,96 @@ -var numeral = require('../../numeral'), - language = require('../../languages/tr'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/tr'); +} -numeral.language('tr', language); +describe('Language: tr', function() { -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]); - } + before(function() { + numeral.language('tr', language); - 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 + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); diff --git a/tests/languages/uk-UA.js b/tests/languages/uk-UA.js index 38e0e0b0..ed8ce934 100644 --- a/tests/languages/uk-UA.js +++ b/tests/languages/uk-UA.js @@ -1,102 +1,97 @@ -var numeral = require('../../numeral'), - language = require('../../languages/uk-UA'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/uk-UA'); +} -numeral.language('uk-UA', language); +describe('Language: uk-UA', function() { -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]); - } + before(function() { + numeral.language('uk-UA', language); - 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 + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); From 39d8b515b1ef25f0fc3eb47587e92536f3abd346 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sun, 20 Nov 2016 12:10:22 -0800 Subject: [PATCH 038/150] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b6c45c64..9899f965 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Develop [![Build Status](https://travis-ci.org/adamwdraper/Numeral-js.svg?branch # Contributing -Please submit all pull requests to the `develop` branch. +#### Please submit all pull requests to the `develop` branch. 1. Fork the library From 4165d51c6d6aaf4e5e88041766424bcce088ef9d Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sun, 20 Nov 2016 12:28:19 -0800 Subject: [PATCH 039/150] Update README.md --- README.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9899f965..bfef6ef4 100644 --- a/README.md +++ b/README.md @@ -25,13 +25,15 @@ Develop [![Build Status](https://travis-ci.org/adamwdraper/Numeral-js.svg?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. To test your tests, run `grunt` +5. Add your tests to the files in `/tests` -6. When all your tests are passing, run `grunt build` to minify all files +6. To test your tests, run `grunt` -7. Submit a pull request to the `develop` branch. +7. When all your tests are passing, run `grunt build` to minify all files + +8. Submit a pull request to the `develop` branch. ### Languages @@ -45,6 +47,10 @@ See [the english unit tests](https://github.com/adamwdraper/Numeral-js/blob/mast # Changelog +### 1.5.4 + +Added reset function to reset numeral to default options + ### 1.5.3 Added currency symbol to optionally appear before negative sign / open paren From ccb0c161115df97bf88b5477b8c923121335b330 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sun, 20 Nov 2016 12:36:46 -0800 Subject: [PATCH 040/150] russian update --- languages/ru.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/languages/ru.js b/languages/ru.js index 2a9ea0ec..ff22c83a 100644 --- a/languages/ru.js +++ b/languages/ru.js @@ -1,4 +1,4 @@ -/*! @preserve +/*! @preserve * numeral.js language configuration * language : russian (ru) * author : Anatoli Papirovski : https://github.com/apapirovski @@ -11,15 +11,15 @@ }, abbreviations: { thousand: 'тыс.', - million: 'млн', - billion: 'b', - trillion: 't' + million: 'млн.', + billion: 'млрд.', + trillion: 'трлн.' }, ordinal: function () { - // not ideal, but since in Russian it can taken on + // not ideal, but since in Russian it can taken on // different forms (masculine, feminine, neuter) // this is all we can do - return '.'; + return '.'; }, currency: { symbol: 'руб.' From 790701cedd252697b3a2070acfdb1b3611396283 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sun, 20 Nov 2016 12:51:20 -0800 Subject: [PATCH 041/150] fix ru test --- tests/languages/ru.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/languages/ru.js b/tests/languages/ru.js index aff12614..52b00a69 100644 --- a/tests/languages/ru.js +++ b/tests/languages/ru.js @@ -28,7 +28,7 @@ describe('Language: ru', function() { [-0.23,'.00','-,23'], [-0.23,'(.00)','(,23)'], [0.23,'0.00000','0,23000'], - [1230974,'0.0a','1,2млн'], + [1230974,'0.0a','1,2млн.'], [1460,'0a','1тыс.'], [-104000,'0a','-104тыс.'], [1,'0o','1.'], @@ -50,7 +50,7 @@ describe('Language: ru', function() { [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млнруб.'] + [1230974,'(0.00a$)','1,23млн.руб.'] ]; for (var i = 0; i < tests.length; i++) { @@ -79,8 +79,8 @@ describe('Language: ru', function() { var tests = [ ['10 000,123',10000.123], ['(0,12345)',-0.12345], - ['(1,23млнруб.)',-1230000], - ['1,23млнруб.',1230000], + ['(1,23млн.руб.)',-1230000], + ['1,23млн.руб.',1230000], ['10тыс.',10000], ['-10тыс.',-10000], ['23.',23], From 59a739fd1e508d690d60a302e2770ec0ccc13394 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sun, 20 Nov 2016 13:03:34 -0800 Subject: [PATCH 042/150] update tests for en-za --- tests/languages/en-za.js | 191 +++++++++++++++++++-------------------- 1 file changed, 93 insertions(+), 98 deletions(-) diff --git a/tests/languages/en-za.js b/tests/languages/en-za.js index 66dcd1b4..93baadf4 100644 --- a/tests/languages/en-za.js +++ b/tests/languages/en-za.js @@ -1,101 +1,96 @@ -var numeral = require('../../numeral'), - language = require('../../languages/en-za'); +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/en-za'); +} -numeral.language('en-za', language); +describe('Language: en-za', function() { -exports['language:en-za'] = { - setUp: function (callback) { - numeral.language('en-za'); - 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','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++) { - test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); - } + before(function() { + numeral.language('en-za', language); - 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], - ['(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++) { - test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); - } - - test.done(); - } -}; \ No newline at end of file + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); From a0c549c50fa4ec4812c0b31f56d880334bd0760f Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sun, 20 Nov 2016 14:11:46 -0800 Subject: [PATCH 043/150] custom null --- Gruntfile.js | 2 +- README.md | 2 ++ numeral.js | 14 ++++++++++++-- tests/numeral/misc.js | 18 ++++++++++++++++-- tests/numeral/unformat.js | 2 ++ 5 files changed, 33 insertions(+), 5 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 41525e26..98566dd9 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -24,7 +24,7 @@ module.exports = function(grunt) { mochaTest : { all: [ 'tests/numeral/*.js', - 'tests/languages/*.js' + // 'tests/languages/*.js' ] }, karma: { diff --git a/README.md b/README.md index bfef6ef4..5e371e66 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,8 @@ See [the english unit tests](https://github.com/adamwdraper/Numeral-js/blob/mast Added reset function to reset numeral to default options +Added nullFormat option + ### 1.5.3 Added currency symbol to optionally appear before negative sign / open paren diff --git a/numeral.js b/numeral.js index 8a2520e2..e4c0f60c 100644 --- a/numeral.js +++ b/numeral.js @@ -19,11 +19,13 @@ defaults = { currentLanguage: 'en', zeroFormat: null, + nullFormat: null, defaultFormat: '0,0' }, options = { currentLanguage: defaults.currentLanguage, zeroFormat: defaults.zeroFormat, + nullFormat: defaults.nullFormat, defaultFormat: defaults.defaultFormat }; @@ -98,7 +100,7 @@ if (string.indexOf(':') > -1) { n._value = unformatTime(string); } else { - if (string === options.zeroFormat) { + if (string === options.zeroFormat || string === options.nullFormat) { n._value = 0; } else { if (languages[options.currentLanguage].delimiters.decimal !== '.') { @@ -258,6 +260,8 @@ // check if number is zero and a custom zero format has been set if (value === 0 && options.zeroFormat !== null) { return options.zeroFormat; + } else if (value === null && options.nullFormat !== null) { + return options.nullFormat; } 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 @@ -402,11 +406,13 @@ input = input.value(); } else if (input === 0 || typeof input === 'undefined') { input = 0; + } else if (input === null) { + input = null; } else if (!Number(input)) { input = numeral.fn.unformat(input); } - return new Numeral(Number(input)); + return new Numeral(input); }; // version number @@ -491,6 +497,10 @@ 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'; }; diff --git a/tests/numeral/misc.js b/tests/numeral/misc.js index 3110ded9..a7ceaf37 100644 --- a/tests/numeral/misc.js +++ b/tests/numeral/misc.js @@ -14,7 +14,7 @@ describe('Misc', function() { var tests = [ [1000, 1000], [0.5, 0.5], - [null, 0], + [null, null], ['1,000', 1000], ['not a number', 0] ], @@ -47,7 +47,6 @@ describe('Misc', function() { describe('Custom Zero', function() { it('should change zero value', function() { var tests = [ - [0,null,'0'], [0,'N/A','N/A'], [0,'',''] ]; @@ -60,6 +59,21 @@ describe('Misc', function() { }); }); + describe('Custom Null', function() { + it('should change null value', function() { + var tests = [ + [null,'N/A','N/A'], + [null,'',''] + ]; + + for (var i = 0; i < tests.length; i++) { + numeral.nullFormat(tests[i][1]); + + expect(numeral(tests[i][0]).format('0')).to.equal(tests[i][2]); + } + }); + }); + describe('Clone', function() { it('should clone', function() { var a = numeral(1000), diff --git a/tests/numeral/unformat.js b/tests/numeral/unformat.js index 290d18df..83483b0e 100644 --- a/tests/numeral/unformat.js +++ b/tests/numeral/unformat.js @@ -7,6 +7,8 @@ if (typeof module !== 'undefined' && module.exports) { describe('Unformat', function() { beforeEach(function() { numeral.zeroFormat('N/A'); + + numeral.nullFormat('N/A'); }); after(function() { From 26ad39d5b69d5298f80c46ab7652086ddefd7766 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sun, 20 Nov 2016 15:36:48 -0800 Subject: [PATCH 044/150] update git ignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 9843db63..23aa3505 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,5 @@ Icon # -------------------- # App Files # -------------------- -node_modules/ \ No newline at end of file +node_modules/ +.sass-cache From bf1fb53aa010db87a73a30cafbcf68011bccb26a Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sun, 20 Nov 2016 19:19:45 -0800 Subject: [PATCH 045/150] reduce polypill --- min/numeral.min.js | 2 +- numeral.js | 54 ++++++++++++++++++---------------------------- 2 files changed, 22 insertions(+), 34 deletions(-) diff --git a/min/numeral.min.js b/min/numeral.min.js index 0a31daaa..a84352b9 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * 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=["KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],k=["KB","MB","GB","TB","PB","EB","ZB","YB"],l=!1;if(b.indexOf(":")>-1)a._value=h(b);else if(b===q.zeroFormat||b===q.nullFormat)a._value=0;else{for("."!==o[q.currentLanguage].delimiters.decimal&&(b=b.replace(/\./g,"").replace(o[q.currentLanguage].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.thousand+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.million+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.billion+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.trillion+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),g=0;g<=j.length&&!l;g++)l=b.indexOf(j[g])>-1?Math.pow(1024,g+1):b.indexOf(k[g])>-1?Math.pow(1e3,g+1):!1;a._value=(l?l: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=l?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[q.currentLanguage].currency.symbol+j),e=e.join("")):e=o[q.currentLanguage].currency.symbol+j+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,j+o[q.currentLanguage].currency.symbol),e=e.join("")):e=e+j+o[q.currentLanguage].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="",p=!1,r=!1,s=!1,t=!1,u=!1,v="",w="",x=Math.abs(a),y=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],z=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],A="",B=!1;if(0===a&&null!==q.zeroFormat)return q.zeroFormat;if(null===a&&null!==q.nullFormat)return q.nullFormat;if(c.indexOf("(")>-1?(k=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(l=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(p=c.indexOf("aK")>=0,r=c.indexOf("aM")>=0,s=c.indexOf("aB")>=0,t=c.indexOf("aT")>=0,u=p||r||s||t,c.indexOf(" a")>-1?(n=" ",c=c.replace(" a","")):c=c.replace("a",""),x>=Math.pow(10,12)&&!u||t?(n+=o[q.currentLanguage].abbreviations.trillion,a/=Math.pow(10,12)):x=Math.pow(10,9)&&!u||s?(n+=o[q.currentLanguage].abbreviations.billion,a/=Math.pow(10,9)):x=Math.pow(10,6)&&!u||r?(n+=o[q.currentLanguage].abbreviations.million,a/=Math.pow(10,6)):(x=Math.pow(10,3)&&!u||p)&&(n+=o[q.currentLanguage].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("b")>-1)for(c.indexOf(" b")>-1?(v=" ",c=c.replace(" b","")):c=c.replace("b",""),g=0;g<=y.length;g++)if(e=Math.pow(1024,g),f=Math.pow(1024,g+1),a>=e&&f>a){v+=y[g],e>0&&(a/=e);break}if(c.indexOf("d")>-1)for(c.indexOf(" d")>-1?(v=" ",c=c.replace(" d","")):c=c.replace("d",""),g=0;g<=z.length;g++)if(e=Math.pow(1e3,g),f=Math.pow(1e3,g+1),a>=e&&f>a){v+=z[g],e>0&&(a/=e);break}return c.indexOf("o")>-1&&(c.indexOf(" o")>-1?(w=" ",c=c.replace(" o","")):c=c.replace("o",""),w+=o[q.currentLanguage].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[q.currentLanguage].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[q.currentLanguage].delimiters.thousands)),0===c.indexOf(".")&&(h=""),(k&&B?"(":"")+(!k&&B?"-":"")+(!B&&l?"+":"")+h+A+(w?w:"")+(n?n:"")+(v?v:"")+(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.4",o={},p={currentLanguage:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},q={currentLanguage:p.currentLanguage,zeroFormat:p.zeroFormat,nullFormat:p.nullFormat,defaultFormat:p.defaultFormat};m=function(b){return m.isNumeral(b)?b=b.value():0===b||"undefined"==typeof b?b=0:null===b?b=null:Number(b)||(b=m.fn.unformat(b)),new a(b)},m.version=n,m.isNumeral=function(b){return b instanceof a},m.language=function(a,b){if(!a)return q.currentLanguage;if(a=a.toLowerCase(),a&&!b){if(!o[a])throw new Error("Unknown language : "+a);q.currentLanguage=a}return(b||!o[a])&&j(a,b),m},m.reset=function(){for(var a in p)q[a]=p[a]},m.languageData=function(a){if(!a)return o[q.currentLanguage];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.zeroFormat="string"==typeof a?a:null},m.nullFormat=function(a){q.nullFormat="string"==typeof a?a:null},m.defaultFormat=function(a){q.defaultFormat="string"==typeof a?a:"0.0"},m.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=m.languageData(b)}catch(k){i=m.languageData(m.language())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},"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:q.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:d(this,a?a:q.defaultFormat)},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,d,e){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,d,e){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,c,d){var e=l(a,b);return a*e*(b*e)/(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=l(a,b);return a*e/(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(m(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(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(){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=["KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],k=["KB","MB","GB","TB","PB","EB","ZB","YB"],l=!1;if(b.indexOf(":")>-1)a._value=h(b);else if(b===q.zeroFormat||b===q.nullFormat)a._value=0;else{for("."!==o[q.currentLanguage].delimiters.decimal&&(b=b.replace(/\./g,"").replace(o[q.currentLanguage].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.thousand+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.million+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.billion+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.trillion+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),g=0;g<=j.length&&!l;g++)l=b.indexOf(j[g])>-1?Math.pow(1024,g+1):b.indexOf(k[g])>-1?Math.pow(1e3,g+1):!1;a._value=(l?l: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=l?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[q.currentLanguage].currency.symbol+j),e=e.join("")):e=o[q.currentLanguage].currency.symbol+j+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,j+o[q.currentLanguage].currency.symbol),e=e.join("")):e=e+j+o[q.currentLanguage].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="",p=!1,r=!1,s=!1,t=!1,u=!1,v="",w="",x=Math.abs(a),y=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],z=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],A="",B=!1;if(0===a&&null!==q.zeroFormat)return q.zeroFormat;if(null===a&&null!==q.nullFormat)return q.nullFormat;if(c.indexOf("(")>-1?(k=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(l=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(p=c.indexOf("aK")>=0,r=c.indexOf("aM")>=0,s=c.indexOf("aB")>=0,t=c.indexOf("aT")>=0,u=p||r||s||t,c.indexOf(" a")>-1?(n=" ",c=c.replace(" a","")):c=c.replace("a",""),x>=Math.pow(10,12)&&!u||t?(n+=o[q.currentLanguage].abbreviations.trillion,a/=Math.pow(10,12)):x=Math.pow(10,9)&&!u||s?(n+=o[q.currentLanguage].abbreviations.billion,a/=Math.pow(10,9)):x=Math.pow(10,6)&&!u||r?(n+=o[q.currentLanguage].abbreviations.million,a/=Math.pow(10,6)):(x=Math.pow(10,3)&&!u||p)&&(n+=o[q.currentLanguage].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("b")>-1)for(c.indexOf(" b")>-1?(v=" ",c=c.replace(" b","")):c=c.replace("b",""),g=0;g<=y.length;g++)if(e=Math.pow(1024,g),f=Math.pow(1024,g+1),a>=e&&f>a){v+=y[g],e>0&&(a/=e);break}if(c.indexOf("d")>-1)for(c.indexOf(" d")>-1?(v=" ",c=c.replace(" d","")):c=c.replace("d",""),g=0;g<=z.length;g++)if(e=Math.pow(1e3,g),f=Math.pow(1e3,g+1),a>=e&&f>a){v+=z[g],e>0&&(a/=e);break}return c.indexOf("o")>-1&&(c.indexOf(" o")>-1?(w=" ",c=c.replace(" o","")):c=c.replace("o",""),w+=o[q.currentLanguage].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[q.currentLanguage].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[q.currentLanguage].delimiters.thousands)),0===c.indexOf(".")&&(h=""),(k&&B?"(":"")+(!k&&B?"-":"")+(!B&&l?"+":"")+h+A+(w?w:"")+(n?n:"")+(v?v:"")+(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.4",o={},p={currentLanguage:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},q={currentLanguage:p.currentLanguage,zeroFormat:p.zeroFormat,nullFormat:p.nullFormat,defaultFormat:p.defaultFormat};m=function(b){return m.isNumeral(b)?b=b.value():0===b||"undefined"==typeof b?b=0:null===b?b=null:Number(b)||(b=m.fn.unformat(b)),new a(b)},m.version=n,m.isNumeral=function(b){return b instanceof a},m.language=function(a,b){if(!a)return q.currentLanguage;if(a=a.toLowerCase(),a&&!b){if(!o[a])throw new Error("Unknown language : "+a);q.currentLanguage=a}return(b||!o[a])&&j(a,b),m},m.reset=function(){for(var a in p)q[a]=p[a]},m.languageData=function(a){if(!a)return o[q.currentLanguage];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.zeroFormat="string"==typeof a?a:null},m.nullFormat=function(a){q.nullFormat="string"==typeof a?a:null},m.defaultFormat=function(a){q.defaultFormat="string"==typeof a?a:"0.0"},m.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=m.languageData(b)}catch(k){i=m.languageData(m.language())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2==arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),m.fn=a.prototype={clone:function(){return m(this)},format:function(a,b){return c(this,a?a:q.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:d(this,a?a:q.defaultFormat)},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,d,e){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,d,e){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,c,d){var e=l(a,b);return a*e*(b*e)/(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=l(a,b);return a*e/(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(m(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(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 diff --git a/numeral.js b/numeral.js index 27620527..b031f09d 100644 --- a/numeral.js +++ b/numeral.js @@ -634,55 +634,43 @@ // 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) { + // Production steps of ECMA-262, Edition 5, 15.4.4.21 + // Reference: http://es5.github.io/#x15.4.4.21 + if (!Array.prototype.reduce) { + Array.prototype.reduce = function(callback /*, 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. + if (this === null) { throw new TypeError('Array.prototype.reduce called on null or undefined'); } - if ('function' !== typeof callback) { + if (typeof callback !== 'function') { throw new TypeError(callback + ' is not a function'); } - var index, - value, - length = this.length >>> 0, - isValueSet = false; + var t = Object(this), len = t.length >>> 0, k = 0, value; - if (1 < arguments.length) { - value = opt_initialValue; - isValueSet = true; - } + if (arguments.length === 2) { + value = arguments[1]; + } else { + while (k < len && !(k in t)) { + k++; + } - 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; - } + if (k >= len) { + throw new TypeError('Reduce of empty array with no initial value'); } - } - if (!isValueSet) { - 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 From d135ae35546fd25ee5a6770f17c8b92b695343dc Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sun, 20 Nov 2016 19:52:11 -0800 Subject: [PATCH 046/150] update version --- README.md | 10 ++++++++++ bower.json | 4 ++-- component.json | 2 +- package.json | 5 ++--- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5e371e66..70f5c9f0 100644 --- a/README.md +++ b/README.md @@ -49,10 +49,20 @@ See [the english unit tests](https://github.com/adamwdraper/Numeral-js/blob/mast ### 1.5.4 +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..aeb0c9e8 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "numeral", "repo": "adamwdraper/Numeral-js", - "version": "1.5.3", + "version": "1.5.4", "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..aeb0c9e8 100644 --- a/component.json +++ b/component.json @@ -1,7 +1,7 @@ { "name": "numeral", "repo": "adamwdraper/Numeral-js", - "version": "1.5.3", + "version": "1.5.4", "description": "Format and manipulate numbers.", "keywords": [ "numeral", diff --git a/package.json b/package.json index 3cd10006..d422cd41 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "numeral", - "version": "1.5.3", + "version": "1.5.4", "description": "Format and manipulate numbers.", "homepage": "http://numeraljs.com/", "author": { @@ -52,7 +52,6 @@ "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" } From 63ecec9caee6d99cf26d42c01065b86c1515c742 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Mon, 21 Nov 2016 09:40:34 -0800 Subject: [PATCH 047/150] keep decimal bytes as b and binary bytes as ib --- README.md | 6 +++- bower.json | 2 +- component.json | 2 +- min/numeral.min.js | 4 +-- numeral.js | 71 +++++++++++++++++---------------------- package.json | 2 +- tests/numeral/format.js | 20 +++++------ tests/numeral/unformat.js | 2 +- 8 files changed, 52 insertions(+), 57 deletions(-) diff --git a/README.md b/README.md index 70f5c9f0..5e572b98 100644 --- a/README.md +++ b/README.md @@ -47,11 +47,15 @@ See [the english unit tests](https://github.com/adamwdraper/Numeral-js/blob/mast # Changelog +### 1.5.5 + +Bug fix: Switch bytes back to `b` and change iecBinary to `ib`, and calculate both using 1024 for backwards compatibility + ### 1.5.4 Tests: Changed all tests to use Mocha and Chai -Tests: Added browser tests for Chrome, Firefox, and IE using saucelabs +Tests: Added browser tests for Chrome, Firefox, and IE using saucelabs Added reset function to reset numeral to default options diff --git a/bower.json b/bower.json index aeb0c9e8..8a5ddf00 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "numeral", "repo": "adamwdraper/Numeral-js", - "version": "1.5.4", + "version": "1.5.5", "description": "Format and manipulate numbers.", "keywords": [ "numeral", diff --git a/component.json b/component.json index aeb0c9e8..8a5ddf00 100644 --- a/component.json +++ b/component.json @@ -1,7 +1,7 @@ { "name": "numeral", "repo": "adamwdraper/Numeral-js", - "version": "1.5.4", + "version": "1.5.5", "description": "Format and manipulate numbers.", "keywords": [ "numeral", diff --git a/min/numeral.min.js b/min/numeral.min.js index 7dabc87e..8050c10b 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -1,8 +1,8 @@ /*! @preserve * numeral.js - * version : 1.5.4 + * version : 1.5.5 * 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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}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=["KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],k=["KB","MB","GB","TB","PB","EB","ZB","YB"],l=!1;if(b.indexOf(":")>-1)a._value=h(b);else if(b===q.zeroFormat||b===q.nullFormat)a._value=0;else{for("."!==o[q.currentLanguage].delimiters.decimal&&(b=b.replace(/\./g,"").replace(o[q.currentLanguage].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.thousand+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.million+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.billion+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.trillion+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),g=0;g<=j.length&&!l;g++)l=b.indexOf(j[g])>-1?Math.pow(1024,g+1):b.indexOf(k[g])>-1?Math.pow(1e3,g+1):!1;a._value=(l?l: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=l?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[q.currentLanguage].currency.symbol+j),e=e.join("")):e=o[q.currentLanguage].currency.symbol+j+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,j+o[q.currentLanguage].currency.symbol),e=e.join("")):e=e+j+o[q.currentLanguage].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="",p=!1,r=!1,s=!1,t=!1,u=!1,v="",w="",x=Math.abs(a),y=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],z=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],A="",B=!1;if(0===a&&null!==q.zeroFormat)return q.zeroFormat;if(null===a&&null!==q.nullFormat)return q.nullFormat;if(c.indexOf("(")>-1?(k=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(l=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(p=c.indexOf("aK")>=0,r=c.indexOf("aM")>=0,s=c.indexOf("aB")>=0,t=c.indexOf("aT")>=0,u=p||r||s||t,c.indexOf(" a")>-1&&(n=" "),c=c.replace(new RegExp(n+"a[KMBT]?"),""),x>=Math.pow(10,12)&&!u||t?(n+=o[q.currentLanguage].abbreviations.trillion,a/=Math.pow(10,12)):x=Math.pow(10,9)&&!u||s?(n+=o[q.currentLanguage].abbreviations.billion,a/=Math.pow(10,9)):x=Math.pow(10,6)&&!u||r?(n+=o[q.currentLanguage].abbreviations.million,a/=Math.pow(10,6)):(x=Math.pow(10,3)&&!u||p)&&(n+=o[q.currentLanguage].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("b")>-1)for(c.indexOf(" b")>-1?(v=" ",c=c.replace(" b","")):c=c.replace("b",""),g=0;g<=y.length;g++)if(e=Math.pow(1024,g),f=Math.pow(1024,g+1),a>=e&&f>a){v+=y[g],e>0&&(a/=e);break}if(c.indexOf("d")>-1)for(c.indexOf(" d")>-1?(v=" ",c=c.replace(" d","")):c=c.replace("d",""),g=0;g<=z.length;g++)if(e=Math.pow(1e3,g),f=Math.pow(1e3,g+1),a>=e&&f>a){v+=z[g],e>0&&(a/=e);break}return c.indexOf("o")>-1&&(c.indexOf(" o")>-1?(w=" ",c=c.replace(" o","")):c=c.replace("o",""),w+=o[q.currentLanguage].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.indexOf(".")>-1?o[q.currentLanguage].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[q.currentLanguage].delimiters.thousands)),0===c.indexOf(".")&&(h=""),(k&&B?"(":"")+(!k&&B?"-":"")+(!B&&l?"+":"")+h+A+(w?w:"")+(n?n:"")+(v?v:"")+(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.4",o={},p={currentLanguage:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},q={currentLanguage:p.currentLanguage,zeroFormat:p.zeroFormat,nullFormat:p.nullFormat,defaultFormat:p.defaultFormat};m=function(b){return m.isNumeral(b)?b=b.value():0===b||"undefined"==typeof b?b=0:null===b?b=null:Number(b)||(b=m.fn.unformat(b)),new a(b)},m.version=n,m.isNumeral=function(b){return b instanceof a},m.language=function(a,b){if(!a)return q.currentLanguage;if(a=a.toLowerCase(),a&&!b){if(!o[a])throw new Error("Unknown language : "+a);q.currentLanguage=a}return(b||!o[a])&&j(a,b),m},m.reset=function(){for(var a in p)q[a]=p[a]},m.languageData=function(a){if(!a)return o[q.currentLanguage];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.zeroFormat="string"==typeof a?a:null},m.nullFormat=function(a){q.nullFormat="string"==typeof a?a:null},m.defaultFormat=function(a){q.defaultFormat="string"==typeof a?a:"0.0"},m.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=m.languageData(b)}catch(k){i=m.languageData(m.language())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),m.fn=a.prototype={clone:function(){return m(this)},format:function(a,b){return c(this,a?a:q.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:d(this,a?a:q.defaultFormat)},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,d,e){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,d,e){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,c,d){var e=l(a,b);return a*e*(b*e)/(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=l(a,b);return a*e/(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(m(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(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(){function a(a){this._value=a}function b(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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}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=["KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],l=!1;if(b.indexOf(":")>-1)a._value=h(b);else if(b===q.zeroFormat||b===q.nullFormat)a._value=0;else{for("."!==o[q.currentLanguage].delimiters.decimal&&(b=b.replace(/\./g,"").replace(o[q.currentLanguage].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.thousand+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.million+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.billion+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.trillion+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),g=0;g<=j.length&&!(l=b.indexOf(j[g])>-1||b.indexOf(k[g])>-1?Math.pow(1024,g+1):!1);g++);a._value=(l?l: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=l?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[q.currentLanguage].currency.symbol+j),e=e.join("")):e=o[q.currentLanguage].currency.symbol+j+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,j+o[q.currentLanguage].currency.symbol),e=e.join("")):e=e+j+o[q.currentLanguage].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="",p=!1,r=!1,s=!1,t=!1,u=!1,v="",w="",x=Math.abs(a),y=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],z=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],A="",B=!1,C=!1;if(0===a&&null!==q.zeroFormat)return q.zeroFormat;if(null===a&&null!==q.nullFormat)return q.nullFormat;if(c.indexOf("(")>-1?(k=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(l=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(p=c.indexOf("aK")>=0,r=c.indexOf("aM")>=0,s=c.indexOf("aB")>=0,t=c.indexOf("aT")>=0,u=p||r||s||t,c.indexOf(" a")>-1&&(n=" "),c=c.replace(new RegExp(n+"a[KMBT]?"),""),x>=Math.pow(10,12)&&!u||t?(n+=o[q.currentLanguage].abbreviations.trillion,a/=Math.pow(10,12)):x=Math.pow(10,9)&&!u||s?(n+=o[q.currentLanguage].abbreviations.billion,a/=Math.pow(10,9)):x=Math.pow(10,6)&&!u||r?(n+=o[q.currentLanguage].abbreviations.million,a/=Math.pow(10,6)):(x=Math.pow(10,3)&&!u||p)&&(n+=o[q.currentLanguage].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("b")>-1)for(c.indexOf("ib")>-1&&(C=!0),c.indexOf(" b")>-1||c.indexOf(" ib")>-1?(v=" ",c=c.replace(" ib","").replace(" b","")):c=c.replace("ib","").replace("b",""),g=0;g<=z.length;g++)if(e=Math.pow(1024,g),f=Math.pow(1024,g+1),a>=e&&f>a){v+=C?y[g]:z[g],e>0&&(a/=e);break}return c.indexOf("o")>-1&&(c.indexOf(" o")>-1?(w=" ",c=c.replace(" o","")):c=c.replace("o",""),w+=o[q.currentLanguage].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.indexOf(".")>-1?o[q.currentLanguage].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[q.currentLanguage].delimiters.thousands)),0===c.indexOf(".")&&(h=""),(k&&B?"(":"")+(!k&&B?"-":"")+(!B&&l?"+":"")+h+A+(w?w:"")+(n?n:"")+(v?v:"")+(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.5",o={},p={currentLanguage:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},q={currentLanguage:p.currentLanguage,zeroFormat:p.zeroFormat,nullFormat:p.nullFormat,defaultFormat:p.defaultFormat};m=function(b){return m.isNumeral(b)?b=b.value():0===b||"undefined"==typeof b?b=0:null===b?b=null:Number(b)||(b=m.fn.unformat(b)),new a(b)},m.version=n,m.isNumeral=function(b){return b instanceof a},m.language=function(a,b){if(!a)return q.currentLanguage;if(a=a.toLowerCase(),a&&!b){if(!o[a])throw new Error("Unknown language : "+a);q.currentLanguage=a}return(b||!o[a])&&j(a,b),m},m.reset=function(){for(var a in p)q[a]=p[a]},m.languageData=function(a){if(!a)return o[q.currentLanguage];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.zeroFormat="string"==typeof a?a:null},m.nullFormat=function(a){q.nullFormat="string"==typeof a?a:null},m.defaultFormat=function(a){q.defaultFormat="string"==typeof a?a:"0.0"},m.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=m.languageData(b)}catch(k){i=m.languageData(m.language())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),m.fn=a.prototype={clone:function(){return m(this)},format:function(a,b){return c(this,a?a:q.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:d(this,a?a:q.defaultFormat)},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,d,e){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,d,e){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,c,d){var e=l(a,b);return a*e*(b*e)/(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=l(a,b);return a*e/(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(m(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(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 diff --git a/numeral.js b/numeral.js index cb142b0c..1df71de8 100644 --- a/numeral.js +++ b/numeral.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js - * version : 1.5.4 + * version : 1.5.5 * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ @@ -13,7 +13,7 @@ ************************************/ var numeral, - VERSION = '1.5.4', + VERSION = '1.5.5', // internal storage for language config files languages = {}, defaults = { @@ -105,8 +105,8 @@ millionRegExp, billionRegExp, trillionRegExp, - binarySuffixes = ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'], - decimalSuffixes = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], + suffixes = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], + iecSuffixes = ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'], bytesMultiplier = false, power; @@ -127,10 +127,12 @@ trillionRegExp = new RegExp('[^a-zA-Z]' + languages[options.currentLanguage].abbreviations.trillion + '(?:\\)|(\\' + languages[options.currentLanguage].currency.symbol + ')?(?:\\))?)?$'); // see if bytes are there so that we can multiply to the correct number - for (power = 0; power <= binarySuffixes.length && !bytesMultiplier; power++) { - if (string.indexOf(binarySuffixes[power]) > -1) { bytesMultiplier = Math.pow(1024, power + 1); } - else if (string.indexOf(decimalSuffixes[power]) > -1) { bytesMultiplier = Math.pow(1000, power + 1); } - else { bytesMultiplier = false; } + for (power = 0; power <= suffixes.length; power++) { + bytesMultiplier = ((string.indexOf(suffixes[power]) > -1) || (string.indexOf(iecSuffixes[power]) > -1))? Math.pow(1024, power + 1) : false; + + if (bytesMultiplier) { + break; + } } // do some math to create our number @@ -245,6 +247,12 @@ return Number(seconds); } + /* format keys: + * a - abbreviation + * ib - binary bytes + * b - decimal bytes + * o - ordinal + */ function formatNumber(value, format, roundingFunction) { var negP = false, signed = false, @@ -258,8 +266,8 @@ bytes = '', ord = '', abs = Math.abs(value), - binarySuffixes = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'], - decimalSuffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], + iecSuffixes = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'], + suffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], min, max, power, @@ -267,7 +275,8 @@ precision, thousands, d = '', - neg = false; + neg = false, + iecBinary = false; // check if number is zero and a custom zero format has been set if (value === 0 && options.zeroFormat !== null) { @@ -320,46 +329,28 @@ } } - // see if we are formatting binary bytes + // 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 <= binarySuffixes.length; power++) { - min = Math.pow(1024, power); - max = Math.pow(1024, power + 1); - if (value >= min && value < max) { - bytes = bytes + binarySuffixes[power]; - if (min > 0) { - value = value / min; - } - break; - } + // check for IEC Binary byte notation + if (format.indexOf('ib') > -1) { + iecBinary = true; } - } - // see if we are formatting decimal bytes - if (format.indexOf('d') > -1) { // check for space before - if (format.indexOf(' d') > -1) { + if (format.indexOf(' b') > -1 || format.indexOf(' ib') > -1) { bytes = ' '; - format = format.replace(' d', ''); + format = format.replace(' ib', '').replace(' b', ''); } else { - format = format.replace('d', ''); + format = format.replace('ib', '').replace('b', ''); } - for (power = 0; power <= decimalSuffixes.length; power++) { - min = Math.pow(1000, power); - max = Math.pow(1000, power+1); + 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 + decimalSuffixes[power]; + bytes = bytes + (iecBinary ? iecSuffixes[power] : suffixes[power]); if (min > 0) { value = value / min; } diff --git a/package.json b/package.json index d422cd41..d1333276 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "numeral", - "version": "1.5.4", + "version": "1.5.5", "description": "Format and manipulate numbers.", "homepage": "http://numeraljs.com/", "author": { diff --git a/tests/numeral/format.js b/tests/numeral/format.js index 76f19ac4..67651d7d 100644 --- a/tests/numeral/format.js +++ b/tests/numeral/format.js @@ -133,16 +133,16 @@ describe('Format', function() { it('should format to bytes', function() { var tests = [ [100,'0b','100B'], - [1024*2,'0 b','2 KiB'], - [1024*1024*5,'0b','5MiB'], - [1024*1024*1024*7.343,'0.[0] b','7.3 GiB'], - [1024*1024*1024*1024*3.1536544,'0.000b','3.154TiB'], - [1024*1024*1024*1024*1024*2.953454534534,'0b','3PiB'], - [1000*2,'0 d','2 KB'], - [1000*1000*5,'0d','5MB'], - [1000*1000*1000*7.343,'0.[0] d','7.3 GB'], - [1000*1000*1000*1000*3.1536544,'0.000d','3.154TB'], - [1000*1000*1000*1000*1000*2.953454534534,'0d','3PB'] + [1024*2,'0 ib','2 KiB'], + [1024*1024*5,'0ib','5MiB'], + [1024*1024*1024*7.343,'0.[0] ib','7.3 GiB'], + [1024*1024*1024*1024*3.1536544,'0.000ib','3.154TiB'], + [1024*1024*1024*1024*1024*2.953454534534,'0ib','3PiB'], + [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; diff --git a/tests/numeral/unformat.js b/tests/numeral/unformat.js index 232dc96f..c4b69ea9 100644 --- a/tests/numeral/unformat.js +++ b/tests/numeral/unformat.js @@ -60,7 +60,7 @@ describe('Unformat', function() { var tests = [ ['100B', 100], ['3.154 TiB', 3467859674006], - ['3.154 TB', 3154000000000] + ['3.154 TB', 3467859674006] ]; for (var i = 0; i < tests.length; i++) { From 381220b49edcd4aaa8e47dbf9b0dec40db0d4ab5 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Tue, 22 Nov 2016 22:16:58 -0800 Subject: [PATCH 048/150] value returns a number unless null --- Gruntfile.js | 2 +- numeral.js | 144 +++++++++++++++++++++++++--------------- tests/numeral/format.js | 60 ++++++++++------- 3 files changed, 127 insertions(+), 79 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 41525e26..98566dd9 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -24,7 +24,7 @@ module.exports = function(grunt) { mochaTest : { all: [ 'tests/numeral/*.js', - 'tests/languages/*.js' + // 'tests/languages/*.js' ] }, karma: { diff --git a/numeral.js b/numeral.js index 1df71de8..20c75051 100644 --- a/numeral.js +++ b/numeral.js @@ -19,7 +19,7 @@ defaults = { currentLanguage: 'en', zeroFormat: null, - nullFormat: null, + nullFormat: '0', defaultFormat: '0,0' }, options = { @@ -27,6 +27,11 @@ zeroFormat: defaults.zeroFormat, nullFormat: defaults.nullFormat, defaultFormat: defaults.defaultFormat + }, + byteSuffixes = { + regexp: /(B|KB|MB|GB|TB|PB|EB|ZB|YB|KiB|MiB|GiB|TiB|PiB|EiB|ZiB|YiB)/, + bytes: ['B','KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], + iec: ['B','KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'] }; @@ -83,18 +88,25 @@ function formatNumeral(n, format, roundingFunction) { var output; + // figure out what kind of format we are dealing with - if (format.indexOf('$') > -1) { // currency!!!!! + if (format.indexOf('$') > -1) { + // currency!!!!! output = formatCurrency(n, format, roundingFunction); - } else if (format.indexOf('%') > -1) { // percentage + } else if (format.indexOf('%') > -1) { + // percentage output = formatPercentage(n, format, roundingFunction); - } else if (format.indexOf(':') > -1) { // time + } else if (format.indexOf(':') > -1) { + // time output = formatTime(n, format); - } else { // plain ol' numbers or bytes + } else if (format.indexOf('b') > -1 || format.indexOf('ib') > -1) { + // bytes + output = formatBytes(n, format, roundingFunction); + } else { + // plain ol' numbers output = formatNumber(n._value, format, roundingFunction); } - // return string return output; } @@ -108,13 +120,14 @@ suffixes = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], iecSuffixes = ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'], bytesMultiplier = false, - power; + power, + value; if (string.indexOf(':') > -1) { - n._value = unformatTime(string); + value = unformatTime(string); } else { if (string === options.zeroFormat || string === options.nullFormat) { - n._value = 0; + value = 0; } else { if (languages[options.currentLanguage].delimiters.decimal !== '.') { string = string.replace(/\./g, '').replace(languages[options.currentLanguage].delimiters.decimal, '.'); @@ -136,12 +149,24 @@ } // 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, '')); - + value = bytesMultiplier ? bytesMultiplier : 1; + value *= stringOriginal.match(thousandRegExp) ? Math.pow(10, 3) : 1; + value *= stringOriginal.match(millionRegExp) ? Math.pow(10, 6) : 1; + value *= stringOriginal.match(billionRegExp) ? Math.pow(10, 9) : 1; + value *= stringOriginal.match(trillionRegExp) ? Math.pow(10, 12) : 1; + // check for percentage + value *= string.indexOf('%') > -1 ? 0.01 : 1; + // check for negative number + value *= (string.split('-').length + Math.min(string.split('(').length - 1, string.split(')').length - 1)) % 2 ? 1 : -1; + // remove non numbers + value *= Number(string.replace(/[^0-9\.]+/g, '')); // round if we are talking about bytes - n._value = (bytesMultiplier) ? Math.ceil(n._value) : n._value; + value = bytesMultiplier ? Math.ceil(value) : value; } } + + n._value = value; + return n._value; } @@ -165,7 +190,7 @@ } // format the number - output = formatNumber(n._value, format, roundingFunction); + output = formatNumber(n._value, format, roundingFunction, false); // position the symbol if (symbolIndex <= 1) { @@ -220,6 +245,41 @@ return output; } + function formatBytes(n, format, roundingFunction) { + var output, + bytes = '', + value = n._value, + suffixes = format.indexOf('ib') > -1 ? byteSuffixes.iec : byteSuffixes.bytes; + + // check for space before + if (format.indexOf(' b') > -1 || format.indexOf(' ib') > -1) { + bytes = ' '; + format = format.replace(' ib', '').replace(' b', ''); + } else { + format = format.replace('ib', '').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; + } + } + + output = formatNumber(value, format, roundingFunction); + + return output + bytes; + } + function formatTime(n) { var hours = Math.floor(n._value / 60 / 60), minutes = Math.floor((n._value - (hours * 60 * 60)) / 60), @@ -253,7 +313,7 @@ * b - decimal bytes * o - ordinal */ - function formatNumber(value, format, roundingFunction) { + function formatNumber(value, format, roundingFunction, useZeroDefault) { var negP = false, signed = false, optDec = false, @@ -266,8 +326,6 @@ bytes = '', ord = '', abs = Math.abs(value), - iecSuffixes = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'], - suffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], min, max, power, @@ -275,11 +333,15 @@ precision, thousands, d = '', - neg = false, - iecBinary = false; + neg = false; + + + if (useZeroDefault === undefined) { + useZeroDefault = true; + } // check if number is zero and a custom zero format has been set - if (value === 0 && options.zeroFormat !== null) { + if (value === 0 && useZeroDefault && options.zeroFormat !== null) { return options.zeroFormat; } else if (value === null && options.nullFormat !== null) { return options.nullFormat; @@ -329,36 +391,6 @@ } } - // see if we are formatting bytes - if (format.indexOf('b') > -1) { - - // check for IEC Binary byte notation - if (format.indexOf('ib') > -1) { - iecBinary = true; - } - - // check for space before - if (format.indexOf(' b') > -1 || format.indexOf(' ib') > -1) { - bytes = ' '; - format = format.replace(' ib', '').replace(' b', ''); - } else { - format = format.replace('ib', '').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 + (iecBinary ? iecSuffixes[power] : suffixes[power]); - if (min > 0) { - value = value / min; - } - break; - } - } - } - // see if ordinal is wanted if (format.indexOf('o') > -1) { // check for space before @@ -436,6 +468,8 @@ input = null; } else if (!Number(input)) { input = numeral.fn.unformat(input); + } else { + input = Number(input); } return new Numeral(input); @@ -532,7 +566,6 @@ }; numeral.validate = function(val, culture) { - var _decimalSep, _thousandSep, _currSymbol, @@ -712,17 +745,18 @@ return numeral(this); }, - format : function (inputString, roundingFunction) { + format: function (inputString, roundingFunction) { return formatNumeral(this, - inputString ? inputString : options.defaultFormat, - (roundingFunction !== undefined) ? roundingFunction : Math.round - ); + inputString ? inputString : options.defaultFormat, + roundingFunction !== undefined ? roundingFunction : Math.round + ); }, - unformat : function (inputString) { + unformat: function (inputString) { if (Object.prototype.toString.call(inputString) === '[object Number]') { return inputString; } + return unformatNumeral(this, inputString ? inputString : options.defaultFormat); }, diff --git a/tests/numeral/format.js b/tests/numeral/format.js index 67651d7d..5ce89eaf 100644 --- a/tests/numeral/format.js +++ b/tests/numeral/format.js @@ -19,23 +19,17 @@ describe('Format', function() { }); describe('Value', function() { - it('should return a value', function() { + it('should return a value as correct type', function() { var tests = [ - '0,0.00', - '$0,0.00', - '0b', - '0,0%', - '00:00:00' + [1234.56,'number'], + ['1234.56','number'], + [0,'number'], + [null,'object'] ], - value = 12345.6, - n = numeral(value), - format, - test; + i; for (i = 0; i < tests.length; i++) { - format = n.format(tests[i]); - - expect(n.value()).to.equal(value); + expect(typeof numeral(tests[i][0]).value()).to.equal(tests[i][1]); } }); }); @@ -43,6 +37,9 @@ describe('Format', function() { describe('Numbers', function() { it('should format to a number', function() { var tests = [ + [0, null, '0'], + [0, '0.00', '0.00'], + [null, null, '0'], [10000,'0,0.0000','10,000.0000'], [10000.23,'0,0','10,000'], [-10000,'0,0.0','-10,000.0'], @@ -85,10 +82,17 @@ describe('Format', function() { [-5444333222111, '0,0 aT', '-5 t'], [123456, '0.0[0] aK', '123.46 k'] ], - i; + i, + n, + output; for (i = 0; i < tests.length; i++) { - expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + n = numeral(tests[i][0]); + output = n.format(tests[i][1]); + + expect(output).to.equal(tests[i][2]); + + expect(typeof output).to.equal('string'); } }); }); @@ -96,6 +100,9 @@ describe('Format', function() { describe('Currency', function() { 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 $'], @@ -124,6 +131,7 @@ describe('Format', function() { i; for (i = 0; i < tests.length; i++) { + console.log() expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); } }); @@ -132,6 +140,8 @@ describe('Format', function() { describe('Bytes', function() { it('should format to bytes', function() { var tests = [ + [0,'0b','0B'], + [null,'0 b','0 B'], [100,'0b','100B'], [1024*2,'0 ib','2 KiB'], [1024*1024*5,'0ib','5MiB'], @@ -155,6 +165,8 @@ describe('Format', function() { describe('Percentages', function() { it('should format to percentages', function() { var tests = [ + [0,'0%','0%'], + [null,'0 %','0 %'], [1,'0%','100%'], [0.974878234,'0.000%','97.488%'], [-0.43,'0 %','-43 %'], @@ -171,6 +183,8 @@ describe('Format', function() { describe('Times', function() { it('should format to times', 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'] @@ -187,14 +201,14 @@ describe('Format', function() { 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.974878234,'0.000%','97.487%','97.488%'], - [-0.433,'0 %','-44 %', '-43 %'] - ], - i; + // 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; for (i = 0; i < tests.length; i++) { // floor From 9f10816132e4b1307a799befde92f3e5edc81e26 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Tue, 22 Nov 2016 22:29:19 -0800 Subject: [PATCH 049/150] move ordinal to own function --- numeral.js | 44 ++++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/numeral.js b/numeral.js index 20c75051..db9899e4 100644 --- a/numeral.js +++ b/numeral.js @@ -91,19 +91,16 @@ // 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 if (format.indexOf('b') > -1 || format.indexOf('ib') > -1) { - // bytes output = formatBytes(n, format, roundingFunction); + } else if (format.indexOf('o') > -1) { + output = formatOrdinal(n, format, roundingFunction); } else { - // plain ol' numbers output = formatNumber(n._value, format, roundingFunction); } @@ -280,6 +277,21 @@ return output + bytes; } + function formatOrdinal(n, format, roundingFunction) { + var output, + space = ''; + + // check for space before + if (format.indexOf(' o') > -1) { + space = ' '; + format = format.replace(' o', ''); + } else { + format = format.replace('o', ''); + } + + return n._value + space + languages[options.currentLanguage].ordinal(n._value); + } + function formatTime(n) { var hours = Math.floor(n._value / 60 / 60), minutes = Math.floor((n._value - (hours * 60 * 60)) / 60), @@ -307,12 +319,6 @@ return Number(seconds); } - /* format keys: - * a - abbreviation - * ib - binary bytes - * b - decimal bytes - * o - ordinal - */ function formatNumber(value, format, roundingFunction, useZeroDefault) { var negP = false, signed = false, @@ -323,8 +329,6 @@ abbrB = false, // force abbreviation to billions abbrT = false, // force abbreviation to trillions abbrForce = false, // force abbreviation - bytes = '', - ord = '', abs = Math.abs(value), min, max, @@ -391,18 +395,6 @@ } } - // 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[options.currentLanguage].ordinal(value); - } if (format.indexOf('[.]') > -1) { optDec = true; @@ -451,7 +443,7 @@ w = ''; } - return ((negP && neg) ? '(' : '') + ((!negP && neg) ? '-' : '') + ((!neg && signed) ? '+' : '') + w + d + ((ord) ? ord : '') + ((abbr) ? abbr : '') + ((bytes) ? bytes : '') + ((negP && neg) ? ')' : ''); + return ((negP && neg) ? '(' : '') + ((!negP && neg) ? '-' : '') + ((!neg && signed) ? '+' : '') + w + d + ((abbr) ? abbr : '') + ((negP && neg) ? ')' : ''); } } From a14e0fe6eda035a3bd82fe8aa93988502361cd01 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Tue, 22 Nov 2016 22:34:34 -0800 Subject: [PATCH 050/150] unformat to use bytesSuffixes --- numeral.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/numeral.js b/numeral.js index db9899e4..b6f8995e 100644 --- a/numeral.js +++ b/numeral.js @@ -29,7 +29,6 @@ defaultFormat: defaults.defaultFormat }, byteSuffixes = { - regexp: /(B|KB|MB|GB|TB|PB|EB|ZB|YB|KiB|MiB|GiB|TiB|PiB|EiB|ZiB|YiB)/, bytes: ['B','KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], iec: ['B','KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'] }; @@ -114,8 +113,6 @@ millionRegExp, billionRegExp, trillionRegExp, - suffixes = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], - iecSuffixes = ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'], bytesMultiplier = false, power, value; @@ -137,8 +134,8 @@ trillionRegExp = new RegExp('[^a-zA-Z]' + languages[options.currentLanguage].abbreviations.trillion + '(?:\\)|(\\' + languages[options.currentLanguage].currency.symbol + ')?(?:\\))?)?$'); // 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) || (string.indexOf(iecSuffixes[power]) > -1))? Math.pow(1024, power + 1) : false; + for (power = 1; power <= byteSuffixes.bytes.length; power++) { + bytesMultiplier = ((string.indexOf(byteSuffixes.bytes[power]) > -1) || (string.indexOf(byteSuffixes.iec[power]) > -1))? Math.pow(1024, power) : false; if (bytesMultiplier) { break; From 9609a6c43975c336a4155767346a4263e5f610e8 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Tue, 22 Nov 2016 23:02:32 -0800 Subject: [PATCH 051/150] make sure zero and null bytes gets suffix --- numeral.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/numeral.js b/numeral.js index b6f8995e..3cef83d4 100644 --- a/numeral.js +++ b/numeral.js @@ -241,25 +241,24 @@ function formatBytes(n, format, roundingFunction) { var output, - bytes = '', + suffixes = format.indexOf('ib') > -1 ? byteSuffixes.iec : byteSuffixes.bytes, value = n._value, - suffixes = format.indexOf('ib') > -1 ? byteSuffixes.iec : byteSuffixes.bytes; + suffix = ''; // check for space before if (format.indexOf(' b') > -1 || format.indexOf(' ib') > -1) { - bytes = ' '; + suffix = ' '; format = format.replace(' ib', '').replace(' b', ''); } else { format = format.replace('ib', '').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 (value === null || value === 0 || value >= min && value < max) { + suffix += suffixes[power]; if (min > 0) { value = value / min; @@ -271,7 +270,7 @@ output = formatNumber(value, format, roundingFunction); - return output + bytes; + return output + suffix; } function formatOrdinal(n, format, roundingFunction) { From 01d661f064e961b00322834f4afdf7b75573949c Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Tue, 22 Nov 2016 23:04:21 -0800 Subject: [PATCH 052/150] fix lint --- Gruntfile.js | 2 +- numeral.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 98566dd9..41525e26 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -24,7 +24,7 @@ module.exports = function(grunt) { mochaTest : { all: [ 'tests/numeral/*.js', - // 'tests/languages/*.js' + 'tests/languages/*.js' ] }, karma: { diff --git a/numeral.js b/numeral.js index 3cef83d4..363ee38f 100644 --- a/numeral.js +++ b/numeral.js @@ -243,7 +243,10 @@ var output, suffixes = format.indexOf('ib') > -1 ? byteSuffixes.iec : byteSuffixes.bytes, value = n._value, - suffix = ''; + suffix = '', + power, + min, + max; // check for space before if (format.indexOf(' b') > -1 || format.indexOf(' ib') > -1) { From 8c432e4fff820aaa268577db8be55fb8814ca0d4 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Tue, 22 Nov 2016 23:50:04 -0800 Subject: [PATCH 053/150] null tests --- numeral.js | 369 ++++++++++++++++++++-------------------- tests/numeral/format.js | 17 +- tests/numeral/misc.js | 26 ++- 3 files changed, 218 insertions(+), 194 deletions(-) diff --git a/numeral.js b/numeral.js index 363ee38f..a80f30d8 100644 --- a/numeral.js +++ b/numeral.js @@ -19,7 +19,7 @@ defaults = { currentLanguage: 'en', zeroFormat: null, - nullFormat: '0', + nullFormat: null, defaultFormat: '0,0' }, options = { @@ -87,81 +87,28 @@ function formatNumeral(n, format, roundingFunction) { var output; - - // figure out what kind of format we are dealing with - if (format.indexOf('$') > -1) { - output = formatCurrency(n, format, roundingFunction); - } else if (format.indexOf('%') > -1) { - output = formatPercentage(n, format, roundingFunction); - } else if (format.indexOf(':') > -1) { - output = formatTime(n, format); - } else if (format.indexOf('b') > -1 || format.indexOf('ib') > -1) { - output = formatBytes(n, format, roundingFunction); - } else if (format.indexOf('o') > -1) { - output = formatOrdinal(n, format, roundingFunction); - } else { - output = formatNumber(n._value, format, roundingFunction); - } - - return output; - } - - // revert to number - function unformatNumeral(n, string) { - var stringOriginal = string, - thousandRegExp, - millionRegExp, - billionRegExp, - trillionRegExp, - bytesMultiplier = false, - power, - value; - - if (string.indexOf(':') > -1) { - value = unformatTime(string); + if (n._value === 0 && options.zeroFormat !== null) { + output = options.zeroFormat; + } else if (n._value === null && options.nullFormat !== null) { + output = options.nullFormat; } else { - if (string === options.zeroFormat || string === options.nullFormat) { - value = 0; + // figure out what kind of format we are dealing with + if (format.indexOf('$') > -1) { + output = formatCurrency(n, format, roundingFunction); + } else if (format.indexOf('%') > -1) { + output = formatPercentage(n, format, roundingFunction); + } else if (format.indexOf(':') > -1) { + output = formatTime(n, format); + } else if (format.indexOf('b') > -1 || format.indexOf('ib') > -1) { + output = formatBytes(n, format, roundingFunction); + } else if (format.indexOf('o') > -1) { + output = formatOrdinal(n, format, roundingFunction); } else { - if (languages[options.currentLanguage].delimiters.decimal !== '.') { - string = string.replace(/\./g, '').replace(languages[options.currentLanguage].delimiters.decimal, '.'); - } - - // see if abbreviations are there so that we can multiply to the correct number - thousandRegExp = new RegExp('[^a-zA-Z]' + languages[options.currentLanguage].abbreviations.thousand + '(?:\\)|(\\' + languages[options.currentLanguage].currency.symbol + ')?(?:\\))?)?$'); - millionRegExp = new RegExp('[^a-zA-Z]' + languages[options.currentLanguage].abbreviations.million + '(?:\\)|(\\' + languages[options.currentLanguage].currency.symbol + ')?(?:\\))?)?$'); - billionRegExp = new RegExp('[^a-zA-Z]' + languages[options.currentLanguage].abbreviations.billion + '(?:\\)|(\\' + languages[options.currentLanguage].currency.symbol + ')?(?:\\))?)?$'); - trillionRegExp = new RegExp('[^a-zA-Z]' + languages[options.currentLanguage].abbreviations.trillion + '(?:\\)|(\\' + languages[options.currentLanguage].currency.symbol + ')?(?:\\))?)?$'); - - // see if bytes are there so that we can multiply to the correct number - for (power = 1; power <= byteSuffixes.bytes.length; power++) { - bytesMultiplier = ((string.indexOf(byteSuffixes.bytes[power]) > -1) || (string.indexOf(byteSuffixes.iec[power]) > -1))? Math.pow(1024, power) : false; - - if (bytesMultiplier) { - break; - } - } - - // do some math to create our number - value = bytesMultiplier ? bytesMultiplier : 1; - value *= stringOriginal.match(thousandRegExp) ? Math.pow(10, 3) : 1; - value *= stringOriginal.match(millionRegExp) ? Math.pow(10, 6) : 1; - value *= stringOriginal.match(billionRegExp) ? Math.pow(10, 9) : 1; - value *= stringOriginal.match(trillionRegExp) ? Math.pow(10, 12) : 1; - // check for percentage - value *= string.indexOf('%') > -1 ? 0.01 : 1; - // check for negative number - value *= (string.split('-').length + Math.min(string.split('(').length - 1, string.split(')').length - 1)) % 2 ? 1 : -1; - // remove non numbers - value *= Number(string.replace(/[^0-9\.]+/g, '')); - // round if we are talking about bytes - value = bytesMultiplier ? Math.ceil(value) : value; + output = formatNumber(n._value, format, roundingFunction); } } - n._value = value; - - return n._value; + return output; } function formatCurrency(n, format, roundingFunction) { @@ -278,47 +225,32 @@ function formatOrdinal(n, format, roundingFunction) { var output, - space = ''; + ordinal = ''; // check for space before if (format.indexOf(' o') > -1) { - space = ' '; + ordinal = ' '; format = format.replace(' o', ''); } else { format = format.replace('o', ''); } - return n._value + space + languages[options.currentLanguage].ordinal(n._value); + ordinal += languages[options.currentLanguage].ordinal(n._value); + + output = formatNumber(n._value, format, roundingFunction); + + return output + ordinal; } 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); } - 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); - } - - function formatNumber(value, format, roundingFunction, useZeroDefault) { + function formatNumber(value, format, roundingFunction) { var negP = false, signed = false, optDec = false, @@ -328,7 +260,7 @@ abbrB = false, // force abbreviation to billions abbrT = false, // force abbreviation to trillions abbrForce = false, // force abbreviation - abs = Math.abs(value), + abs, min, max, power, @@ -338,114 +270,191 @@ d = '', neg = false; + if (value === null) { + value = 0; + } + + abs = Math.abs(value); - if (useZeroDefault === undefined) { - useZeroDefault = true; + // 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) { + negP = true; + format = format.slice(1, -1); + } else if (format.indexOf('+') > -1) { + signed = true; + format = format.replace(/\+/g, ''); } - // check if number is zero and a custom zero format has been set - if (value === 0 && useZeroDefault && options.zeroFormat !== null) { - return options.zeroFormat; - } else if (value === null && options.nullFormat !== null) { - return options.nullFormat; - } 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) { - negP = true; - format = format.slice(1, -1); - } else if (format.indexOf('+') > -1) { - signed = true; - 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; + + // check for space before abbreviation + if (format.indexOf(' a') > -1) { + abbr = ' '; } - // 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; - - // check for space before abbreviation - if (format.indexOf(' a') > -1) { - abbr = ' '; - } + format = format.replace(new RegExp(abbr + 'a[KMBT]?'), ''); + + if (abs >= Math.pow(10, 12) && !abbrForce || abbrT) { + // trillion + abbr = abbr + languages[options.currentLanguage].abbreviations.trillion; + value = value / Math.pow(10, 12); + } else if (abs < Math.pow(10, 12) && abs >= Math.pow(10, 9) && !abbrForce || abbrB) { + // billion + abbr = abbr + languages[options.currentLanguage].abbreviations.billion; + value = value / Math.pow(10, 9); + } else if (abs < Math.pow(10, 9) && abs >= Math.pow(10, 6) && !abbrForce || abbrM) { + // million + abbr = abbr + languages[options.currentLanguage].abbreviations.million; + value = value / Math.pow(10, 6); + } else if (abs < Math.pow(10, 6) && abs >= Math.pow(10, 3) && !abbrForce || abbrK) { + // thousand + abbr = abbr + languages[options.currentLanguage].abbreviations.thousand; + value = value / Math.pow(10, 3); + } + } - format = format.replace(new RegExp(abbr + 'a[KMBT]?'), ''); - - if (abs >= Math.pow(10, 12) && !abbrForce || abbrT) { - // trillion - abbr = abbr + languages[options.currentLanguage].abbreviations.trillion; - value = value / Math.pow(10, 12); - } else if (abs < Math.pow(10, 12) && abs >= Math.pow(10, 9) && !abbrForce || abbrB) { - // billion - abbr = abbr + languages[options.currentLanguage].abbreviations.billion; - value = value / Math.pow(10, 9); - } else if (abs < Math.pow(10, 9) && abs >= Math.pow(10, 6) && !abbrForce || abbrM) { - // million - abbr = abbr + languages[options.currentLanguage].abbreviations.million; - value = value / Math.pow(10, 6); - } else if (abs < Math.pow(10, 6) && abs >= Math.pow(10, 3) && !abbrForce || abbrK) { - // thousand - abbr = abbr + languages[options.currentLanguage].abbreviations.thousand; - value = value / Math.pow(10, 3); - } + + if (format.indexOf('[.]') > -1) { + optDec = true; + format = format.replace('[.]', '.'); + } + + w = value.toString().split('.')[0]; + precision = format.split('.')[1]; + thousands = format.indexOf(','); + + if (precision) { + if (precision.indexOf('[') > -1) { + precision = precision.replace(']', ''); + precision = precision.split('['); + d = toFixed(value, (precision[0].length + precision[1].length), roundingFunction, precision[1].length); + } else { + d = toFixed(value, precision.length, roundingFunction); } + w = d.split('.')[0]; - if (format.indexOf('[.]') > -1) { - optDec = true; - format = format.replace('[.]', '.'); + if (d.indexOf('.') > -1) { + d = languages[options.currentLanguage].delimiters.decimal + d.split('.')[1]; + } else { + d = ''; } - w = value.toString().split('.')[0]; - precision = format.split('.')[1]; - thousands = format.indexOf(','); + if (optDec && Number(d.slice(1)) === 0) { + d = ''; + } + } else { + w = toFixed(value, null, roundingFunction); + } - if (precision) { - if (precision.indexOf('[') > -1) { - precision = precision.replace(']', ''); - precision = precision.split('['); - d = toFixed(value, (precision[0].length + precision[1].length), roundingFunction, precision[1].length); - } else { - d = toFixed(value, precision.length, roundingFunction); - } + // format number + if (w.indexOf('-') > -1) { + w = w.slice(1); + neg = true; + } - w = d.split('.')[0]; + if (thousands > -1) { + w = w.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + languages[options.currentLanguage].delimiters.thousands); + } - if (d.indexOf('.') > -1) { - d = languages[options.currentLanguage].delimiters.decimal + d.split('.')[1]; - } else { - d = ''; - } + if (format.indexOf('.') === 0) { + w = ''; + } - if (optDec && Number(d.slice(1)) === 0) { - d = ''; - } + return ((negP && neg) ? '(' : '') + ((!negP && neg) ? '-' : '') + ((!neg && signed) ? '+' : '') + w + d + ((abbr) ? abbr : '') + ((negP && neg) ? ')' : ''); + } + + + /************************************ + Unformatting + ************************************/ + + // revert to number + function unformatNumeral(n, string) { + var stringOriginal = string, + thousandRegExp, + millionRegExp, + billionRegExp, + trillionRegExp, + bytesMultiplier = false, + power, + value; + + if (string.indexOf(':') > -1) { + value = unformatTime(string); + } else { + if (string === options.zeroFormat || string === options.nullFormat) { + value = 0; } else { - w = toFixed(value, null, roundingFunction); - } + if (languages[options.currentLanguage].delimiters.decimal !== '.') { + string = string.replace(/\./g, '').replace(languages[options.currentLanguage].delimiters.decimal, '.'); + } - // format number - if (w.indexOf('-') > -1) { - w = w.slice(1); - neg = true; - } + // see if abbreviations are there so that we can multiply to the correct number + thousandRegExp = new RegExp('[^a-zA-Z]' + languages[options.currentLanguage].abbreviations.thousand + '(?:\\)|(\\' + languages[options.currentLanguage].currency.symbol + ')?(?:\\))?)?$'); + millionRegExp = new RegExp('[^a-zA-Z]' + languages[options.currentLanguage].abbreviations.million + '(?:\\)|(\\' + languages[options.currentLanguage].currency.symbol + ')?(?:\\))?)?$'); + billionRegExp = new RegExp('[^a-zA-Z]' + languages[options.currentLanguage].abbreviations.billion + '(?:\\)|(\\' + languages[options.currentLanguage].currency.symbol + ')?(?:\\))?)?$'); + trillionRegExp = new RegExp('[^a-zA-Z]' + languages[options.currentLanguage].abbreviations.trillion + '(?:\\)|(\\' + languages[options.currentLanguage].currency.symbol + ')?(?:\\))?)?$'); - if (thousands > -1) { - w = w.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + languages[options.currentLanguage].delimiters.thousands); - } + // see if bytes are there so that we can multiply to the correct number + for (power = 1; power <= byteSuffixes.bytes.length; power++) { + bytesMultiplier = ((string.indexOf(byteSuffixes.bytes[power]) > -1) || (string.indexOf(byteSuffixes.iec[power]) > -1))? Math.pow(1024, power) : false; + + if (bytesMultiplier) { + break; + } + } - if (format.indexOf('.') === 0) { - w = ''; + // do some math to create our number + value = bytesMultiplier ? bytesMultiplier : 1; + value *= stringOriginal.match(thousandRegExp) ? Math.pow(10, 3) : 1; + value *= stringOriginal.match(millionRegExp) ? Math.pow(10, 6) : 1; + value *= stringOriginal.match(billionRegExp) ? Math.pow(10, 9) : 1; + value *= stringOriginal.match(trillionRegExp) ? Math.pow(10, 12) : 1; + // check for percentage + value *= string.indexOf('%') > -1 ? 0.01 : 1; + // check for negative number + value *= (string.split('-').length + Math.min(string.split('(').length - 1, string.split(')').length - 1)) % 2 ? 1 : -1; + // remove non numbers + value *= Number(string.replace(/[^0-9\.]+/g, '')); + // round if we are talking about bytes + value = bytesMultiplier ? Math.ceil(value) : value; } + } + + n._value = value; - return ((negP && neg) ? '(' : '') + ((!negP && neg) ? '-' : '') + ((!neg && signed) ? '+' : '') + w + d + ((abbr) ? abbr : '') + ((negP && neg) ? ')' : ''); + return n._value; + } + 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); } + /************************************ Top Level Functions ************************************/ diff --git a/tests/numeral/format.js b/tests/numeral/format.js index 5ce89eaf..56107f02 100644 --- a/tests/numeral/format.js +++ b/tests/numeral/format.js @@ -66,18 +66,20 @@ describe('Format', function() { [3162.63,'0.0[00000000000000]','3162.63'], [1.99,'0.[0]','2'], [1.0501,'0.00[0]','1.05'], - [2000000000,'0.0a','2.0b'], - [1230974,'0.0a','1.2m'], - [1460,'0a','1k'], - [-104000,'0 a','-104 k'], + // ordinals [1,'0o','1st'], [52,'0 o','52 nd'], [23,'0o','23rd'], [100,'0o','100th'], - - // specified abbreviations + [1234,'0,0o','1,234th'], + // abbreviations + [2000000000,'0.0a','2.0b'], + [1230974,'0.0a','1.2m'], + [1460,'0a','1k'], + [-104000,'0 a','-104 k'], + // forced abbreviations [-5444333222111, '0,0 aK', '-5,444,333,222 k'], - [-5444333222111, '0,0 aM', '-5,444,333 m'], + [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'] @@ -131,7 +133,6 @@ describe('Format', function() { i; for (i = 0; i < tests.length; i++) { - console.log() expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); } }); diff --git a/tests/numeral/misc.js b/tests/numeral/misc.js index a7ceaf37..c8d4cade 100644 --- a/tests/numeral/misc.js +++ b/tests/numeral/misc.js @@ -47,14 +47,21 @@ describe('Misc', function() { describe('Custom Zero', function() { it('should change zero value', function() { var tests = [ - [0,'N/A','N/A'], - [0,'',''] + [0,null,'0','0'], + [0,null,'$0.00','$0.00'], + [0,null,'0 b','0 B'], + [0,null,'0:00','0:00:00'], + [0,'N/A','0','N/A'], + [0,'N/A','$0.00','N/A'], + [0,'N/A','0 b','N/A'], + [0,'N/A','0:00','N/A'], + [0,'','',''] ]; for (var i = 0; i < tests.length; i++) { numeral.zeroFormat(tests[i][1]); - expect(numeral(tests[i][0]).format('0')).to.equal(tests[i][2]); + expect(numeral(tests[i][0]).format(tests[i][2])).to.equal(tests[i][3]); } }); }); @@ -62,14 +69,21 @@ describe('Misc', function() { describe('Custom Null', function() { it('should change null value', function() { var tests = [ - [null,'N/A','N/A'], - [null,'',''] + [null,null,'0','0'], + [null,null,'$0.00','$0.00'], + [null,null,'0 b','0 B'], + [null,null,'0:00','0:00:00'], + [null,'N/A','0','N/A'], + [null,'N/A','$0.00','N/A'], + [null,'N/A','0 b','N/A'], + [null,'N/A','0:00','N/A'], + [null,'','',''] ]; for (var i = 0; i < tests.length; i++) { numeral.nullFormat(tests[i][1]); - expect(numeral(tests[i][0]).format('0')).to.equal(tests[i][2]); + expect(numeral(tests[i][0]).format(tests[i][2])).to.equal(tests[i][3]); } }); }); From f2d4ea88f4168247ab164407a0fe92196010fe16 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Tue, 22 Nov 2016 23:51:19 -0800 Subject: [PATCH 054/150] build 1.5.6 --- min/numeral.min.js | 4 ++-- numeral.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/min/numeral.min.js b/min/numeral.min.js index 8050c10b..d5e00efd 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -1,8 +1,8 @@ /*! @preserve * numeral.js - * version : 1.5.5 + * version : 1.5.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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}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=["KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],l=!1;if(b.indexOf(":")>-1)a._value=h(b);else if(b===q.zeroFormat||b===q.nullFormat)a._value=0;else{for("."!==o[q.currentLanguage].delimiters.decimal&&(b=b.replace(/\./g,"").replace(o[q.currentLanguage].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.thousand+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.million+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.billion+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.trillion+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),g=0;g<=j.length&&!(l=b.indexOf(j[g])>-1||b.indexOf(k[g])>-1?Math.pow(1024,g+1):!1);g++);a._value=(l?l: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=l?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[q.currentLanguage].currency.symbol+j),e=e.join("")):e=o[q.currentLanguage].currency.symbol+j+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,j+o[q.currentLanguage].currency.symbol),e=e.join("")):e=e+j+o[q.currentLanguage].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="",p=!1,r=!1,s=!1,t=!1,u=!1,v="",w="",x=Math.abs(a),y=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],z=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],A="",B=!1,C=!1;if(0===a&&null!==q.zeroFormat)return q.zeroFormat;if(null===a&&null!==q.nullFormat)return q.nullFormat;if(c.indexOf("(")>-1?(k=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(l=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(p=c.indexOf("aK")>=0,r=c.indexOf("aM")>=0,s=c.indexOf("aB")>=0,t=c.indexOf("aT")>=0,u=p||r||s||t,c.indexOf(" a")>-1&&(n=" "),c=c.replace(new RegExp(n+"a[KMBT]?"),""),x>=Math.pow(10,12)&&!u||t?(n+=o[q.currentLanguage].abbreviations.trillion,a/=Math.pow(10,12)):x=Math.pow(10,9)&&!u||s?(n+=o[q.currentLanguage].abbreviations.billion,a/=Math.pow(10,9)):x=Math.pow(10,6)&&!u||r?(n+=o[q.currentLanguage].abbreviations.million,a/=Math.pow(10,6)):(x=Math.pow(10,3)&&!u||p)&&(n+=o[q.currentLanguage].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("b")>-1)for(c.indexOf("ib")>-1&&(C=!0),c.indexOf(" b")>-1||c.indexOf(" ib")>-1?(v=" ",c=c.replace(" ib","").replace(" b","")):c=c.replace("ib","").replace("b",""),g=0;g<=z.length;g++)if(e=Math.pow(1024,g),f=Math.pow(1024,g+1),a>=e&&f>a){v+=C?y[g]:z[g],e>0&&(a/=e);break}return c.indexOf("o")>-1&&(c.indexOf(" o")>-1?(w=" ",c=c.replace(" o","")):c=c.replace("o",""),w+=o[q.currentLanguage].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.indexOf(".")>-1?o[q.currentLanguage].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[q.currentLanguage].delimiters.thousands)),0===c.indexOf(".")&&(h=""),(k&&B?"(":"")+(!k&&B?"-":"")+(!B&&l?"+":"")+h+A+(w?w:"")+(n?n:"")+(v?v:"")+(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.5",o={},p={currentLanguage:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},q={currentLanguage:p.currentLanguage,zeroFormat:p.zeroFormat,nullFormat:p.nullFormat,defaultFormat:p.defaultFormat};m=function(b){return m.isNumeral(b)?b=b.value():0===b||"undefined"==typeof b?b=0:null===b?b=null:Number(b)||(b=m.fn.unformat(b)),new a(b)},m.version=n,m.isNumeral=function(b){return b instanceof a},m.language=function(a,b){if(!a)return q.currentLanguage;if(a=a.toLowerCase(),a&&!b){if(!o[a])throw new Error("Unknown language : "+a);q.currentLanguage=a}return(b||!o[a])&&j(a,b),m},m.reset=function(){for(var a in p)q[a]=p[a]},m.languageData=function(a){if(!a)return o[q.currentLanguage];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.zeroFormat="string"==typeof a?a:null},m.nullFormat=function(a){q.nullFormat="string"==typeof a?a:null},m.defaultFormat=function(a){q.defaultFormat="string"==typeof a?a:"0.0"},m.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=m.languageData(b)}catch(k){i=m.languageData(m.language())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),m.fn=a.prototype={clone:function(){return m(this)},format:function(a,b){return c(this,a?a:q.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:d(this,a?a:q.defaultFormat)},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,d,e){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,d,e){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,c,d){var e=l(a,b);return a*e*(b*e)/(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=l(a,b);return a*e/(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(m(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(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(){function a(a){this._value=a}function b(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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var j;return j=0===a._value&&null!==s.zeroFormat?s.zeroFormat:null===a._value&&null!==s.nullFormat?s.nullFormat:b.indexOf("$")>-1?d(a,b,c):b.indexOf("%")>-1?e(a,b,c):b.indexOf(":")>-1?h(a,b):b.indexOf("b")>-1||b.indexOf("ib")>-1?f(a,b,c):b.indexOf("o")>-1?g(a,b,c):i(a._value,b,c)}function d(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),1>=f?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,q[s.currentLanguage].currency.symbol+j),e=e.join("")):e=q[s.currentLanguage].currency.symbol+j+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,j+q[s.currentLanguage].currency.symbol),e=e.join("")):e=e+j+q[s.currentLanguage].currency.symbol,e}function e(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 f(a,b,c){var d,e,f,g,h=b.indexOf("ib")>-1?t.iec:t.bytes,j=a._value,k="";for(b.indexOf(" b")>-1||b.indexOf(" ib")>-1?(k=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.length;e++)if(f=Math.pow(1024,e),g=Math.pow(1024,e+1),null===j||0===j||j>=f&&g>j){k+=h[e],f>0&&(j/=f);break}return d=i(j,b,c),d+k}function g(a,b,c){var d,e="";return b.indexOf(" o")>-1?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=q[s.currentLanguage].ordinal(a._value),d=i(a._value,b,c),d+e}function h(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 i(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,r=!1,t="",u=!1;return null===a&&(a=0),e=Math.abs(a),c.indexOf("(")>-1?(i=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(j=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(m=c.indexOf("aK")>=0,n=c.indexOf("aM")>=0,o=c.indexOf("aB")>=0,p=c.indexOf("aT")>=0,r=m||n||o||p,c.indexOf(" a")>-1&&(l=" "),c=c.replace(new RegExp(l+"a[KMBT]?"),""),e>=Math.pow(10,12)&&!r||p?(l+=q[s.currentLanguage].abbreviations.trillion,a/=Math.pow(10,12)):e=Math.pow(10,9)&&!r||o?(l+=q[s.currentLanguage].abbreviations.billion,a/=Math.pow(10,9)):e=Math.pow(10,6)&&!r||n?(l+=q[s.currentLanguage].abbreviations.million,a/=Math.pow(10,6)):(e=Math.pow(10,3)&&!r||m)&&(l+=q[s.currentLanguage].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("[.]")>-1&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.indexOf("[")>-1?(g=g.replace("]",""),g=g.split("["),t=b(a,g[0].length+g[1].length,d,g[1].length)):t=b(a,g.length,d),f=t.split(".")[0],t=t.indexOf(".")>-1?q[s.currentLanguage].delimiters.decimal+t.split(".")[1]:"",k&&0===Number(t.slice(1))&&(t="")):f=b(a,null,d),f.indexOf("-")>-1&&(f=f.slice(1),u=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+q[s.currentLanguage].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&u?"(":"")+(!i&&u?"-":"")+(!u&&j?"+":"")+f+t+(l?l:"")+(i&&u?")":"")}function j(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.indexOf(":")>-1)h=k(b);else if(b===s.zeroFormat||b===s.nullFormat)h=0;else{for("."!==q[s.currentLanguage].delimiters.decimal&&(b=b.replace(/\./g,"").replace(q[s.currentLanguage].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+q[s.currentLanguage].abbreviations.thousand+"(?:\\)|(\\"+q[s.currentLanguage].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+q[s.currentLanguage].abbreviations.million+"(?:\\)|(\\"+q[s.currentLanguage].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+q[s.currentLanguage].abbreviations.billion+"(?:\\)|(\\"+q[s.currentLanguage].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+q[s.currentLanguage].abbreviations.trillion+"(?:\\)|(\\"+q[s.currentLanguage].currency.symbol+")?(?:\\))?)?$"),g=1;g<=t.bytes.length&&!(j=b.indexOf(t.bytes[g])>-1||b.indexOf(t.iec[g])>-1?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.indexOf("%")>-1?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function k(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 l(a,b){q[a]=b}function m(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function n(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=m(a),d=m(b);return c>d?c:d},-(1/0))}var o,p="1.5.5",q={},r={currentLanguage:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},s={currentLanguage:r.currentLanguage,zeroFormat:r.zeroFormat,nullFormat:r.nullFormat,defaultFormat:r.defaultFormat},t={bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"],iec:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]};o=function(b){return b=o.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b?null:Number(b)?Number(b):o.fn.unformat(b),new a(b)},o.version=p,o.isNumeral=function(b){return b instanceof a},o.language=function(a,b){if(!a)return s.currentLanguage;if(a=a.toLowerCase(),a&&!b){if(!q[a])throw new Error("Unknown language : "+a);s.currentLanguage=a}return(b||!q[a])&&l(a,b),o},o.reset=function(){for(var a in r)s[a]=r[a]},o.languageData=function(a){if(!a)return q[s.currentLanguage];if(!q[a])throw new Error("Unknown language : "+a);return q[a]},o.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:"$"}}),o.zeroFormat=function(a){s.zeroFormat="string"==typeof a?a:null},o.nullFormat=function(a){s.nullFormat="string"==typeof a?a:null},o.defaultFormat=function(a){s.defaultFormat="string"==typeof a?a:"0.0"},o.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=o.languageData(b)}catch(k){i=o.languageData(o.language())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),o.fn=a.prototype={clone:function(){return o(this)},format:function(a,b){return c(this,a?a:s.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:j(this,a?a:s.defaultFormat)},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,d,e){return a+c*b}var c=n.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-c*b}var c=n.call(null,this._value,a);return this._value=[a].reduce(b,this._value*c)/c,this},multiply:function(a){function b(a,b,c,d){var e=n(a,b);return a*e*(b*e)/(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=n(a,b);return a*e/(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(o(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=o),"undefined"==typeof ender&&(this.numeral=o),"function"==typeof define&&define.amd&&define([],function(){return o})}).call(this); \ No newline at end of file diff --git a/numeral.js b/numeral.js index a80f30d8..1c946132 100644 --- a/numeral.js +++ b/numeral.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js - * version : 1.5.5 + * version : 1.5.6 * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ @@ -246,7 +246,7 @@ 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); } From 7920d72d13e246ddb439c2504506f9fb9eb22394 Mon Sep 17 00:00:00 2001 From: Nicola Sanitate Date: Wed, 23 Nov 2016 15:44:00 +0100 Subject: [PATCH 055/150] Bugfix in manipulation of floating-point --- min/languages.min.js | 22 ++++++---------------- min/languages/be-nl.min.js | 2 +- min/languages/chs.min.js | 8 ++++---- min/languages/en-za.min.js | 5 ----- min/languages/nl-nl.min.js | 2 +- min/languages/no.min.js | 5 ----- min/numeral.min.js | 2 +- numeral.js | 23 +++++++++++------------ tests/numeral/manipulate.js | 20 +++++++++++++++----- 9 files changed, 39 insertions(+), 50 deletions(-) diff --git a/min/languages.min.js b/min/languages.min.js index 4f1fda68..82bcd132 100644 --- a/min/languages.min.js +++ b/min/languages.min.js @@ -3,10 +3,10 @@ * 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)}(),/*! @preserve - * numeral.js language configuration - * language : simplified chinese - * author : badplum : https://github.com/badplum +!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&&b<=1||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)}(),/*! @preserve + * 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(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("chs",a)}(),/*! @preserve * numeral.js language configuration @@ -33,12 +33,7 @@ function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand * 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 : english south africa (uk) - * author : Etienne Boshoff : etienne@zailab.com - */ -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:"R"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("en-za",a)}(),/*! @preserve +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)}(),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:"R"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("en-za",a)}(),/*! @preserve * numeral.js language configuration * language : spanish Spain * author : Hernan Garcia : https://github.com/hgarcia @@ -101,12 +96,7 @@ function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand * 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 : norwegian (bokmål) - * author : Ove Andersen : https://github.com/azzlack - */ -function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&(this.numeral.language("nb-no",a),this.numeral.language("nn-no",a),this.numeral.language("no",a),this.numeral.language("nb",a),this.numeral.language("nn",a))}(),/*! @preserve +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&&b<=1||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)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&(this.numeral.language("nb-no",a),this.numeral.language("nn-no",a),this.numeral.language("no",a),this.numeral.language("nb",a),this.numeral.language("nn",a))}(),/*! @preserve * numeral.js language configuration * language : polish (pl) * author : Dominik Bulaj : https://github.com/dominikbulaj diff --git a/min/languages/be-nl.min.js b/min/languages/be-nl.min.js index 8450d92d..a4cb5c36 100644 --- a/min/languages/be-nl.min.js +++ b/min/languages/be-nl.min.js @@ -3,4 +3,4 @@ * 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 +!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&&b<=1||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 index 77aa10a7..18840388 100644 --- a/min/languages/chs.min.js +++ b/min/languages/chs.min.js @@ -1,6 +1,6 @@ -/*! @preserve - * numeral.js language configuration - * language : simplified chinese - * author : badplum : https://github.com/badplum +/*! @preserve + * 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(a){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/en-za.min.js b/min/languages/en-za.min.js index 516c0a50..aa20ae0d 100644 --- a/min/languages/en-za.min.js +++ b/min/languages/en-za.min.js @@ -1,6 +1 @@ -/*! - * numeral.js language configuration - * language : english south africa (uk) - * author : Etienne Boshoff : etienne@zailab.com - */ !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:"R"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("en-za",a)}(); \ No newline at end of file diff --git a/min/languages/nl-nl.min.js b/min/languages/nl-nl.min.js index ed20694f..1c22e84b 100644 --- a/min/languages/nl-nl.min.js +++ b/min/languages/nl-nl.min.js @@ -3,4 +3,4 @@ * 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 +!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&&b<=1||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/no.min.js b/min/languages/no.min.js index 71c8277a..fb720497 100644 --- a/min/languages/no.min.js +++ b/min/languages/no.min.js @@ -1,6 +1 @@ -/*! - * numeral.js language configuration - * language : norwegian (bokmål) - * author : Ove Andersen : https://github.com/azzlack - */ !function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&(this.numeral.language("nb-no",a),this.numeral.language("nn-no",a),this.numeral.language("no",a),this.numeral.language("nb",a),this.numeral.language("nn",a))}(); \ No newline at end of file diff --git a/min/numeral.min.js b/min/numeral.min.js index d5e00efd..ecdfa1d2 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * 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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var j;return j=0===a._value&&null!==s.zeroFormat?s.zeroFormat:null===a._value&&null!==s.nullFormat?s.nullFormat:b.indexOf("$")>-1?d(a,b,c):b.indexOf("%")>-1?e(a,b,c):b.indexOf(":")>-1?h(a,b):b.indexOf("b")>-1||b.indexOf("ib")>-1?f(a,b,c):b.indexOf("o")>-1?g(a,b,c):i(a._value,b,c)}function d(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),1>=f?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,q[s.currentLanguage].currency.symbol+j),e=e.join("")):e=q[s.currentLanguage].currency.symbol+j+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,j+q[s.currentLanguage].currency.symbol),e=e.join("")):e=e+j+q[s.currentLanguage].currency.symbol,e}function e(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 f(a,b,c){var d,e,f,g,h=b.indexOf("ib")>-1?t.iec:t.bytes,j=a._value,k="";for(b.indexOf(" b")>-1||b.indexOf(" ib")>-1?(k=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.length;e++)if(f=Math.pow(1024,e),g=Math.pow(1024,e+1),null===j||0===j||j>=f&&g>j){k+=h[e],f>0&&(j/=f);break}return d=i(j,b,c),d+k}function g(a,b,c){var d,e="";return b.indexOf(" o")>-1?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=q[s.currentLanguage].ordinal(a._value),d=i(a._value,b,c),d+e}function h(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 i(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,r=!1,t="",u=!1;return null===a&&(a=0),e=Math.abs(a),c.indexOf("(")>-1?(i=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(j=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(m=c.indexOf("aK")>=0,n=c.indexOf("aM")>=0,o=c.indexOf("aB")>=0,p=c.indexOf("aT")>=0,r=m||n||o||p,c.indexOf(" a")>-1&&(l=" "),c=c.replace(new RegExp(l+"a[KMBT]?"),""),e>=Math.pow(10,12)&&!r||p?(l+=q[s.currentLanguage].abbreviations.trillion,a/=Math.pow(10,12)):e=Math.pow(10,9)&&!r||o?(l+=q[s.currentLanguage].abbreviations.billion,a/=Math.pow(10,9)):e=Math.pow(10,6)&&!r||n?(l+=q[s.currentLanguage].abbreviations.million,a/=Math.pow(10,6)):(e=Math.pow(10,3)&&!r||m)&&(l+=q[s.currentLanguage].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("[.]")>-1&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.indexOf("[")>-1?(g=g.replace("]",""),g=g.split("["),t=b(a,g[0].length+g[1].length,d,g[1].length)):t=b(a,g.length,d),f=t.split(".")[0],t=t.indexOf(".")>-1?q[s.currentLanguage].delimiters.decimal+t.split(".")[1]:"",k&&0===Number(t.slice(1))&&(t="")):f=b(a,null,d),f.indexOf("-")>-1&&(f=f.slice(1),u=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+q[s.currentLanguage].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&u?"(":"")+(!i&&u?"-":"")+(!u&&j?"+":"")+f+t+(l?l:"")+(i&&u?")":"")}function j(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.indexOf(":")>-1)h=k(b);else if(b===s.zeroFormat||b===s.nullFormat)h=0;else{for("."!==q[s.currentLanguage].delimiters.decimal&&(b=b.replace(/\./g,"").replace(q[s.currentLanguage].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+q[s.currentLanguage].abbreviations.thousand+"(?:\\)|(\\"+q[s.currentLanguage].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+q[s.currentLanguage].abbreviations.million+"(?:\\)|(\\"+q[s.currentLanguage].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+q[s.currentLanguage].abbreviations.billion+"(?:\\)|(\\"+q[s.currentLanguage].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+q[s.currentLanguage].abbreviations.trillion+"(?:\\)|(\\"+q[s.currentLanguage].currency.symbol+")?(?:\\))?)?$"),g=1;g<=t.bytes.length&&!(j=b.indexOf(t.bytes[g])>-1||b.indexOf(t.iec[g])>-1?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.indexOf("%")>-1?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function k(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 l(a,b){q[a]=b}function m(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function n(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=m(a),d=m(b);return c>d?c:d},-(1/0))}var o,p="1.5.5",q={},r={currentLanguage:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},s={currentLanguage:r.currentLanguage,zeroFormat:r.zeroFormat,nullFormat:r.nullFormat,defaultFormat:r.defaultFormat},t={bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"],iec:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]};o=function(b){return b=o.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b?null:Number(b)?Number(b):o.fn.unformat(b),new a(b)},o.version=p,o.isNumeral=function(b){return b instanceof a},o.language=function(a,b){if(!a)return s.currentLanguage;if(a=a.toLowerCase(),a&&!b){if(!q[a])throw new Error("Unknown language : "+a);s.currentLanguage=a}return(b||!q[a])&&l(a,b),o},o.reset=function(){for(var a in r)s[a]=r[a]},o.languageData=function(a){if(!a)return q[s.currentLanguage];if(!q[a])throw new Error("Unknown language : "+a);return q[a]},o.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:"$"}}),o.zeroFormat=function(a){s.zeroFormat="string"==typeof a?a:null},o.nullFormat=function(a){s.nullFormat="string"==typeof a?a:null},o.defaultFormat=function(a){s.defaultFormat="string"==typeof a?a:"0.0"},o.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=o.languageData(b)}catch(k){i=o.languageData(o.language())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),o.fn=a.prototype={clone:function(){return o(this)},format:function(a,b){return c(this,a?a:s.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:j(this,a?a:s.defaultFormat)},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,d,e){return a+c*b}var c=n.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-c*b}var c=n.call(null,this._value,a);return this._value=[a].reduce(b,this._value*c)/c,this},multiply:function(a){function b(a,b,c,d){var e=n(a,b);return a*e*(b*e)/(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=n(a,b);return a*e/(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(o(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=o),"undefined"==typeof ender&&(this.numeral=o),"function"==typeof define&&define.amd&&define([],function(){return o})}).call(this); \ No newline at end of file +(function(){function a(a){this._value=a}function b(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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var j;return j=0===a._value&&null!==s.zeroFormat?s.zeroFormat:null===a._value&&null!==s.nullFormat?s.nullFormat:b.indexOf("$")>-1?d(a,b,c):b.indexOf("%")>-1?e(a,b,c):b.indexOf(":")>-1?h(a,b):b.indexOf("b")>-1||b.indexOf("ib")>-1?f(a,b,c):b.indexOf("o")>-1?g(a,b,c):i(a._value,b,c)}function d(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<=1?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(f-1?(e=e.split(""),e.splice(-1,0,j+q[s.currentLanguage].currency.symbol),e=e.join("")):e=e+j+q[s.currentLanguage].currency.symbol,e}function e(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 f(a,b,c){var d,e,f,g,h=b.indexOf("ib")>-1?t.iec:t.bytes,j=a._value,k="";for(b.indexOf(" b")>-1||b.indexOf(" ib")>-1?(k=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.length;e++)if(f=Math.pow(1024,e),g=Math.pow(1024,e+1),null===j||0===j||j>=f&&j0&&(j/=f);break}return d=i(j,b,c),d+k}function g(a,b,c){var d,e="";return b.indexOf(" o")>-1?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=q[s.currentLanguage].ordinal(a._value),d=i(a._value,b,c),d+e}function h(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+":"+(c<10?"0"+c:c)+":"+(d<10?"0"+d:d)}function i(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,r=!1,t="",u=!1;return null===a&&(a=0),e=Math.abs(a),c.indexOf("(")>-1?(i=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(j=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(m=c.indexOf("aK")>=0,n=c.indexOf("aM")>=0,o=c.indexOf("aB")>=0,p=c.indexOf("aT")>=0,r=m||n||o||p,c.indexOf(" a")>-1&&(l=" "),c=c.replace(new RegExp(l+"a[KMBT]?"),""),e>=Math.pow(10,12)&&!r||p?(l+=q[s.currentLanguage].abbreviations.trillion,a/=Math.pow(10,12)):e=Math.pow(10,9)&&!r||o?(l+=q[s.currentLanguage].abbreviations.billion,a/=Math.pow(10,9)):e=Math.pow(10,6)&&!r||n?(l+=q[s.currentLanguage].abbreviations.million,a/=Math.pow(10,6)):(e=Math.pow(10,3)&&!r||m)&&(l+=q[s.currentLanguage].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("[.]")>-1&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.indexOf("[")>-1?(g=g.replace("]",""),g=g.split("["),t=b(a,g[0].length+g[1].length,d,g[1].length)):t=b(a,g.length,d),f=t.split(".")[0],t=t.indexOf(".")>-1?q[s.currentLanguage].delimiters.decimal+t.split(".")[1]:"",k&&0===Number(t.slice(1))&&(t="")):f=b(a,null,d),f.indexOf("-")>-1&&(f=f.slice(1),u=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+q[s.currentLanguage].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&u?"(":"")+(!i&&u?"-":"")+(!u&&j?"+":"")+f+t+(l?l:"")+(i&&u?")":"")}function j(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.indexOf(":")>-1)h=k(b);else if(b===s.zeroFormat||b===s.nullFormat)h=0;else{for("."!==q[s.currentLanguage].delimiters.decimal&&(b=b.replace(/\./g,"").replace(q[s.currentLanguage].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+q[s.currentLanguage].abbreviations.thousand+"(?:\\)|(\\"+q[s.currentLanguage].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+q[s.currentLanguage].abbreviations.million+"(?:\\)|(\\"+q[s.currentLanguage].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+q[s.currentLanguage].abbreviations.billion+"(?:\\)|(\\"+q[s.currentLanguage].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+q[s.currentLanguage].abbreviations.trillion+"(?:\\)|(\\"+q[s.currentLanguage].currency.symbol+")?(?:\\))?)?$"),g=1;g<=t.bytes.length&&!(j=(b.indexOf(t.bytes[g])>-1||b.indexOf(t.iec[g])>-1)&&Math.pow(1024,g));g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.indexOf("%")>-1?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function k(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 l(a,b){q[a]=b}function m(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function n(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=m(b);return a>c?a:c},1)}var o,p="1.5.5",q={},r={currentLanguage:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},s={currentLanguage:r.currentLanguage,zeroFormat:r.zeroFormat,nullFormat:r.nullFormat,defaultFormat:r.defaultFormat},t={bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"],iec:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]};o=function(b){return b=o.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b?null:Number(b)?Number(b):o.fn.unformat(b),new a(b)},o.version=p,o.isNumeral=function(b){return b instanceof a},o.language=function(a,b){if(!a)return s.currentLanguage;if(a=a.toLowerCase(),a&&!b){if(!q[a])throw new Error("Unknown language : "+a);s.currentLanguage=a}return!b&&q[a]||l(a,b),o},o.reset=function(){for(var a in r)s[a]=r[a]},o.languageData=function(a){if(!a)return q[s.currentLanguage];if(!q[a])throw new Error("Unknown language : "+a);return q[a]},o.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:"$"}}),o.zeroFormat=function(a){s.zeroFormat="string"==typeof a?a:null},o.nullFormat=function(a){s.nullFormat="string"==typeof a?a:null},o.defaultFormat=function(a){s.defaultFormat="string"==typeof a?a:"0.0"},o.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=o.languageData(b)}catch(a){i=o.languageData(o.language())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),(null===j||(a=a.substr(1),j[0]===e))&&(j=a.match(/[^\d]+$/),(null===j||(a=a.slice(0,-1),j[0]===g.thousand||j[0]===g.million||j[0]===g.billion||j[0]===g.trillion))&&(h=new RegExp(d+"{2}"),!a.match(/[^\d.,]/g)&&(f=a.split(c),!(f.length>2)&&(f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/)))))},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;e=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;e mn ? mp : mn; - }, -Infinity); + return args.reduce(function(accum, next) { + var mn = multiplier(next); + return accum > mn ? accum : mn; + }, 1); } @@ -775,9 +774,9 @@ add: function(value) { var corrFactor = correctionFactor.call(null, this._value, value); - + function cback(accum, curr, currI, O) { - return accum + corrFactor * curr; + return accum + Math.round(corrFactor * curr); } this._value = [this._value, value].reduce(cback, 0) / corrFactor; return this; @@ -787,17 +786,17 @@ var corrFactor = correctionFactor.call(null, this._value, value); function cback(accum, curr, currI, O) { - return accum - corrFactor * curr; + return accum - Math.round(corrFactor * curr); } - this._value = [value].reduce(cback, this._value * corrFactor) / corrFactor; + this._value = [value].reduce(cback, Math.round(this._value * corrFactor)) / corrFactor; return this; }, multiply: function(value) { function cback(accum, curr, currI, O) { var corrFactor = correctionFactor(accum, curr); - return (accum * corrFactor) * (curr * corrFactor) / - (corrFactor * corrFactor); + return Math.round(accum * corrFactor) * Math.round(curr * corrFactor) / + Math.round(corrFactor * corrFactor); } this._value = [this._value, value].reduce(cback, 1); return this; @@ -806,7 +805,7 @@ divide: function(value) { function cback(accum, curr, currI, O) { var corrFactor = correctionFactor(accum, curr); - return (accum * corrFactor) / (curr * corrFactor); + return Math.round(accum * corrFactor) / Math.round(curr * corrFactor); } this._value = [this._value, value].reduce(cback); return this; diff --git a/tests/numeral/manipulate.js b/tests/numeral/manipulate.js index da0c522a..f20744a9 100644 --- a/tests/numeral/manipulate.js +++ b/tests/numeral/manipulate.js @@ -15,7 +15,9 @@ describe('Manipulate', function() { [1000,10,1010], [0.5,3,3.5], [-100,200,100], - [0.1,0.2,0.3] + [0.1,0.2,0.3], + [0.28,0.01,0.29], + [0.29,0.01,0.3] ], num; @@ -35,7 +37,9 @@ describe('Manipulate', function() { [1000,10,990], [0.5,3,-2.5], [-100,200,-300], - [0.3,0.1,0.2] + [0.3,0.1,0.2], + [0.28,0.01,0.27], + [0.29,0.01,0.28] ], num; @@ -62,7 +66,9 @@ describe('Manipulate', function() { [1000,10,10000], [0.5,3,1.5], [-100,200,-20000], - [0.1,0.2,0.02] + [0.1,0.2,0.02], + [0.28,0.01,0.0028], + [0.29,0.01,0.0029] ], num; @@ -82,7 +88,9 @@ describe('Manipulate', function() { [1000,10,100], [0.5,3,0.16666666666666666], [-100,200,-0.5], - [5.3,0.1,53] + [5.3,0.1,53], + [0.28,0.01,28], + [0.29,0.01,29] ], num; @@ -102,7 +110,9 @@ describe('Manipulate', function() { [1000,10,990], [0.5,3,2.5], [-100,200,300], - [0.3,0.2,0.1] + [0.3,0.2,0.1], + [0.28,0.01,0.27], + [0.29,0.01,0.28] ], num; From 9368be81dc8e0e8977770a1214d7808634e48d79 Mon Sep 17 00:00:00 2001 From: Don Vince Date: Wed, 23 Nov 2016 17:40:54 +0000 Subject: [PATCH 056/150] Added Australian English --- languages/en-au.js | 38 ++++++++++++++++ tests/languages/en-au.js | 96 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 languages/en-au.js create mode 100644 tests/languages/en-au.js diff --git a/languages/en-au.js b/languages/en-au.js new file mode 100644 index 00000000..83cd5eea --- /dev/null +++ b/languages/en-au.js @@ -0,0 +1,38 @@ +/*! @preserve + * numeral.js language configuration + * language : English Australia + * author : Don Vince : https://github.com/donvince/ + */ +(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-au', language); + } +}()); \ No newline at end of file diff --git a/tests/languages/en-au.js b/tests/languages/en-au.js new file mode 100644 index 00000000..70c4f5a4 --- /dev/null +++ b/tests/languages/en-au.js @@ -0,0 +1,96 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/en-au'); +} + +describe('Language: en-au', function() { + + before(function() { + numeral.language('en-au', language); + + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); From 2b16727dcca8f6963fb3d11236fca6a49391f9fd Mon Sep 17 00:00:00 2001 From: Don Vince Date: Wed, 23 Nov 2016 17:41:21 +0000 Subject: [PATCH 057/150] Added Bulgarian --- languages/bg.js | 42 +++++++++++++++++++ tests/languages/bg.js | 96 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+) create mode 100644 languages/bg.js create mode 100644 tests/languages/bg.js diff --git a/languages/bg.js b/languages/bg.js new file mode 100644 index 00000000..8de90d57 --- /dev/null +++ b/languages/bg.js @@ -0,0 +1,42 @@ +/*! @preserve + * numeral.js language configuration + * language : Bulgarian + * author : Don Vince : https://github.com/donvince/ + */ +(function () { + var language = { + 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: 'лв' + } + }; + + // Node + if (typeof module !== 'undefined' && module.exports) { + module.exports = language; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { + this.numeral.language('bg', language); + } +}()); \ No newline at end of file diff --git a/tests/languages/bg.js b/tests/languages/bg.js new file mode 100644 index 00000000..abc1567c --- /dev/null +++ b/tests/languages/bg.js @@ -0,0 +1,96 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../numeral'); + var expect = require('chai').expect; + var language = require('../../languages/bg'); +} + +describe('Language: bg', function() { + + before(function() { + numeral.language('bg', language); + + numeral.language('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().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); +}); From 84d9caf5b3a98045d6847cb0056ac174dfe2cc74 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Wed, 23 Nov 2016 10:49:25 -0800 Subject: [PATCH 058/150] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e572b98..9d810ae4 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Develop [![Build Status](https://travis-ci.org/adamwdraper/Numeral-js.svg?branch # Contributing -#### Please submit all pull requests to the `develop` branch. +#### Important: Please create your branch from and submit pull requests to the `develop` branch. 1. Fork the library From 8af3253c31d3021426d06212ee35d81b760b8fb4 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Wed, 23 Nov 2016 21:31:17 -0800 Subject: [PATCH 059/150] update version --- README.md | 10 ++++++++++ bower.json | 2 +- component.json | 2 +- numeral.js | 2 +- package.json | 2 +- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9d810ae4..2673013d 100644 --- a/README.md +++ b/README.md @@ -47,12 +47,22 @@ See [the english unit tests](https://github.com/adamwdraper/Numeral-js/blob/mast # Changelog +### 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 diff --git a/bower.json b/bower.json index 8a5ddf00..15b0498c 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "numeral", "repo": "adamwdraper/Numeral-js", - "version": "1.5.5", + "version": "1.5.6", "description": "Format and manipulate numbers.", "keywords": [ "numeral", diff --git a/component.json b/component.json index 8a5ddf00..15b0498c 100644 --- a/component.json +++ b/component.json @@ -1,7 +1,7 @@ { "name": "numeral", "repo": "adamwdraper/Numeral-js", - "version": "1.5.5", + "version": "1.5.6", "description": "Format and manipulate numbers.", "keywords": [ "numeral", diff --git a/numeral.js b/numeral.js index 1c946132..6717c0be 100644 --- a/numeral.js +++ b/numeral.js @@ -13,7 +13,7 @@ ************************************/ var numeral, - VERSION = '1.5.5', + VERSION = '1.5.6', // internal storage for language config files languages = {}, defaults = { diff --git a/package.json b/package.json index d1333276..079c21a1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "numeral", - "version": "1.5.5", + "version": "1.5.6", "description": "Format and manipulate numbers.", "homepage": "http://numeraljs.com/", "author": { From a2600d4e795eacd5917da206ee03a5d72ca7f876 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 24 Nov 2016 20:08:03 -0800 Subject: [PATCH 060/150] decimal and binary calculated with different base --- README.md | 4 ++++ numeral.js | 28 ++++++++++++++++++---------- tests/numeral/format.js | 22 ++++++++++++---------- 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 2673013d..af52aa15 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,10 @@ See [the english unit tests](https://github.com/adamwdraper/Numeral-js/blob/mast # Changelog +### 2.0.0 + +Breaking change: Bytes are now formatted as: `b` (base 1000) and `ib` (base 1024) + ### 1.5.6 Bug fix: numeral converts strings to numbers diff --git a/numeral.js b/numeral.js index 6717c0be..53dd5843 100644 --- a/numeral.js +++ b/numeral.js @@ -28,9 +28,17 @@ nullFormat: defaults.nullFormat, defaultFormat: defaults.defaultFormat }, - byteSuffixes = { - bytes: ['B','KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], - iec: ['B','KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'] + config = { + bytes: { + 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'] + } + } }; @@ -188,7 +196,7 @@ function formatBytes(n, format, roundingFunction) { var output, - suffixes = format.indexOf('ib') > -1 ? byteSuffixes.iec : byteSuffixes.bytes, + bytes = format.indexOf('ib') > -1 ? config.bytes.binary : config.bytes.decimal, value = n._value, suffix = '', power, @@ -203,12 +211,12 @@ format = format.replace('ib', '').replace('b', ''); } - for (power = 0; power <= suffixes.length; power++) { - min = Math.pow(1024, power); - max = Math.pow(1024, power + 1); + 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 += suffixes[power]; + suffix += bytes.suffixes[power]; if (min > 0) { value = value / min; @@ -405,8 +413,8 @@ trillionRegExp = new RegExp('[^a-zA-Z]' + languages[options.currentLanguage].abbreviations.trillion + '(?:\\)|(\\' + languages[options.currentLanguage].currency.symbol + ')?(?:\\))?)?$'); // see if bytes are there so that we can multiply to the correct number - for (power = 1; power <= byteSuffixes.bytes.length; power++) { - bytesMultiplier = ((string.indexOf(byteSuffixes.bytes[power]) > -1) || (string.indexOf(byteSuffixes.iec[power]) > -1))? Math.pow(1024, power) : false; + for (power = 1; power <= config.bytes.decimal.suffixes.length; power++) { + bytesMultiplier = ((string.indexOf(config.bytes.decimal.suffixes[power]) > -1) || (string.indexOf(config.bytes.binary.suffixes[power]) > -1))? Math.pow(1024, power) : false; if (bytesMultiplier) { break; diff --git a/tests/numeral/format.js b/tests/numeral/format.js index 56107f02..5aa5d0ce 100644 --- a/tests/numeral/format.js +++ b/tests/numeral/format.js @@ -140,20 +140,22 @@ describe('Format', function() { describe('Bytes', function() { 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'], - [1024*2,'0 ib','2 KiB'], - [1024*1024*5,'0ib','5MiB'], - [1024*1024*1024*7.343,'0.[0] ib','7.3 GiB'], - [1024*1024*1024*1024*3.1536544,'0.000ib','3.154TiB'], - [1024*1024*1024*1024*1024*2.953454534534,'0ib','3PiB'], - [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'] + [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; From eb909870223313f7a9ab28ed6bae4f3002502e9b Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 24 Nov 2016 21:21:50 -0800 Subject: [PATCH 061/150] treat NaN as null to prevent error --- numeral.js | 2 +- tests/numeral/format.js | 17 +------ tests/numeral/misc.js | 99 ++++++++++++++++++++++++----------------- 3 files changed, 60 insertions(+), 58 deletions(-) diff --git a/numeral.js b/numeral.js index 6717c0be..89a5e69e 100644 --- a/numeral.js +++ b/numeral.js @@ -464,7 +464,7 @@ input = input.value(); } else if (input === 0 || typeof input === 'undefined') { input = 0; - } else if (input === null) { + } else if (input === null || Number.isNaN(input)) { input = null; } else if (!Number(input)) { input = numeral.fn.unformat(input); diff --git a/tests/numeral/format.js b/tests/numeral/format.js index 56107f02..087b1b8a 100644 --- a/tests/numeral/format.js +++ b/tests/numeral/format.js @@ -18,28 +18,13 @@ describe('Format', function() { }); }); - describe('Value', function() { - it('should return a value as correct type', function() { - var tests = [ - [1234.56,'number'], - ['1234.56','number'], - [0,'number'], - [null,'object'] - ], - i; - - for (i = 0; i < tests.length; i++) { - expect(typeof numeral(tests[i][0]).value()).to.equal(tests[i][1]); - } - }); - }); - describe('Numbers', 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'], [10000,'0,0.0000','10,000.0000'], [10000.23,'0,0','10,000'], [-10000,'0,0.0','-10,000.0'], diff --git a/tests/numeral/misc.js b/tests/numeral/misc.js index c8d4cade..56018836 100644 --- a/tests/numeral/misc.js +++ b/tests/numeral/misc.js @@ -9,16 +9,33 @@ describe('Misc', function() { numeral.reset(); }); - describe('Add', function() { + 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', 0] - ], - num; + [1000, 1000], + [0.5, 0.5], + [null, null], + ['1,000', 1000], + ['not a number', 0] + ], + num; for (var i = 0; i < tests.length; i++) { num = numeral(tests[i][0]); @@ -31,10 +48,10 @@ describe('Misc', function() { describe('Set', function() { it('should set a value', function() { var tests = [ - [1000,1000], - [-0.25,-0.25] - ], - num; + [1000,1000], + [-0.25,-0.25] + ], + num; for (var i = 0; i < tests.length; i++) { num = numeral().set(tests[i][0]); @@ -47,16 +64,16 @@ describe('Misc', function() { describe('Custom Zero', function() { it('should change zero value', function() { var tests = [ - [0,null,'0','0'], - [0,null,'$0.00','$0.00'], - [0,null,'0 b','0 B'], - [0,null,'0:00','0:00:00'], - [0,'N/A','0','N/A'], - [0,'N/A','$0.00','N/A'], - [0,'N/A','0 b','N/A'], - [0,'N/A','0:00','N/A'], - [0,'','',''] - ]; + [0,null,'0','0'], + [0,null,'$0.00','$0.00'], + [0,null,'0 b','0 B'], + [0,null,'0:00','0:00:00'], + [0,'N/A','0','N/A'], + [0,'N/A','$0.00','N/A'], + [0,'N/A','0 b','N/A'], + [0,'N/A','0:00','N/A'], + [0,'','',''] + ]; for (var i = 0; i < tests.length; i++) { numeral.zeroFormat(tests[i][1]); @@ -69,16 +86,16 @@ describe('Misc', function() { describe('Custom Null', function() { it('should change null value', function() { var tests = [ - [null,null,'0','0'], - [null,null,'$0.00','$0.00'], - [null,null,'0 b','0 B'], - [null,null,'0:00','0:00:00'], - [null,'N/A','0','N/A'], - [null,'N/A','$0.00','N/A'], - [null,'N/A','0 b','N/A'], - [null,'N/A','0:00','N/A'], - [null,'','',''] - ]; + [null,null,'0','0'], + [null,null,'$0.00','$0.00'], + [null,null,'0 b','0 B'], + [null,null,'0:00','0:00:00'], + [null,'N/A','0','N/A'], + [null,'N/A','$0.00','N/A'], + [null,'N/A','0 b','N/A'], + [null,'N/A','0:00','N/A'], + [null,'','',''] + ]; for (var i = 0; i < tests.length; i++) { numeral.nullFormat(tests[i][1]); @@ -91,12 +108,12 @@ describe('Misc', function() { 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(); + 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); @@ -108,9 +125,9 @@ describe('Misc', function() { describe('isNumeral', function() { it('should return boolean', function() { var tests = [ - [numeral(),true], - [1,false] - ]; + [numeral(),true], + [1,false] + ]; for (var i = 0; i < tests.length; i++) { expect(numeral.isNumeral(tests[i][0])).to.equal(tests[i][1]); From d38b7a4733f0714ed8bf5f9d3b761fca5a9e1ae8 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 24 Nov 2016 21:23:35 -0800 Subject: [PATCH 062/150] document NaN change --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index af52aa15..86367110 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,8 @@ See [the english unit tests](https://github.com/adamwdraper/Numeral-js/blob/mast Breaking change: 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 + ### 1.5.6 Bug fix: numeral converts strings to numbers From 046ae7a095417bdd696622e5f8d6fd480707b96a Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 24 Nov 2016 21:32:11 -0800 Subject: [PATCH 063/150] add Number.isNan polyfill --- numeral.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/numeral.js b/numeral.js index b6abfa3f..d7b20f7c 100644 --- a/numeral.js +++ b/numeral.js @@ -677,6 +677,11 @@ // The floating-point helper functions and implementation // borrows heavily from sinful.js: http://guipn.github.io/sinful.js/ + Number.isNaN = Number.isNaN || function(value) { + return typeof value === "number" && isNaN(value); + } + + // Production steps of ECMA-262, Edition 5, 15.4.4.21 // Reference: http://es5.github.io/#x15.4.4.21 if (!Array.prototype.reduce) { From 198aacc084f2f3fa9464b4e80d907abea28616e2 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 24 Nov 2016 21:36:58 -0800 Subject: [PATCH 064/150] fix jshint --- numeral.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/numeral.js b/numeral.js index d7b20f7c..5e69f4b3 100644 --- a/numeral.js +++ b/numeral.js @@ -678,8 +678,8 @@ // borrows heavily from sinful.js: http://guipn.github.io/sinful.js/ Number.isNaN = Number.isNaN || function(value) { - return typeof value === "number" && isNaN(value); - } + return typeof value === 'number' && isNaN(value); + }; // Production steps of ECMA-262, Edition 5, 15.4.4.21 From d511000ebd4990b803dd56cbb484588927756c88 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 24 Nov 2016 23:05:48 -0800 Subject: [PATCH 065/150] rename language to locale --- Gruntfile.js | 24 +- README.md | 2 + languages.js => locales.js | 369 ++++++++++++----------- {languages => locales}/be-nl.js | 14 +- {languages => locales}/chs.js | 12 +- {languages => locales}/cs.js | 12 +- {languages => locales}/da-dk.js | 12 +- {languages => locales}/de-ch.js | 12 +- {languages => locales}/de.js | 12 +- {languages => locales}/en-gb.js | 12 +- {languages => locales}/en-za.js | 12 +- {languages => locales}/es-ES.js | 12 +- {languages => locales}/es.js | 12 +- {languages => locales}/et.js | 12 +- {languages => locales}/fi.js | 12 +- {languages => locales}/fr-CA.js | 12 +- {languages => locales}/fr-ch.js | 12 +- {languages => locales}/fr.js | 12 +- {languages => locales}/hu.js | 12 +- {languages => locales}/it.js | 12 +- {languages => locales}/ja.js | 12 +- {languages => locales}/lv.js | 12 +- {languages => locales}/nl-nl.js | 12 +- {languages => locales}/no.js | 20 +- {languages => locales}/pl.js | 12 +- {languages => locales}/pt-br.js | 12 +- {languages => locales}/pt-pt.js | 12 +- {languages => locales}/ru-UA.js | 12 +- {languages => locales}/ru.js | 12 +- {languages => locales}/sk.js | 12 +- {languages => locales}/th.js | 12 +- {languages => locales}/tr.js | 12 +- {languages => locales}/uk-UA.js | 12 +- min/{languages.min.js => locales.min.js} | 168 +++++------ min/{languages => locales}/be-nl.min.js | 6 +- min/{languages => locales}/chs.min.js | 6 +- min/{languages => locales}/cs.min.js | 6 +- min/{languages => locales}/da-dk.min.js | 6 +- min/{languages => locales}/de-ch.min.js | 6 +- min/{languages => locales}/de.min.js | 6 +- min/{languages => locales}/en-gb.min.js | 6 +- min/{languages => locales}/en-za.min.js | 6 +- min/{languages => locales}/es-ES.min.js | 6 +- min/{languages => locales}/es.min.js | 6 +- min/{languages => locales}/et.min.js | 6 +- min/{languages => locales}/fi.min.js | 6 +- min/{languages => locales}/fr-CA.min.js | 6 +- min/{languages => locales}/fr-ch.min.js | 6 +- min/{languages => locales}/fr.min.js | 6 +- min/{languages => locales}/hu.min.js | 6 +- min/{languages => locales}/it.min.js | 6 +- min/{languages => locales}/ja.min.js | 6 +- min/{languages => locales}/lv.min.js | 6 +- min/{languages => locales}/nl-nl.min.js | 6 +- min/{languages => locales}/no.min.js | 6 +- min/{languages => locales}/pl.min.js | 6 +- min/{languages => locales}/pt-br.min.js | 6 +- min/{languages => locales}/pt-pt.min.js | 6 +- min/{languages => locales}/ru-UA.min.js | 2 +- min/{languages => locales}/ru.min.js | 6 +- min/{languages => locales}/sk.min.js | 6 +- min/{languages => locales}/th.min.js | 6 +- min/{languages => locales}/tr.min.js | 6 +- min/{languages => locales}/uk-UA.min.js | 2 +- min/numeral.min.js | 2 +- numeral.js | 102 +++---- tests/{languages => locales}/be-nl.js | 8 +- tests/{languages => locales}/chs.js | 8 +- tests/{languages => locales}/cs.js | 8 +- tests/{languages => locales}/da-dk.js | 8 +- tests/{languages => locales}/de-ch.js | 8 +- tests/{languages => locales}/de.js | 8 +- tests/{languages => locales}/en-gb.js | 8 +- tests/{languages => locales}/en-za.js | 8 +- tests/{languages => locales}/en.js | 2 +- tests/{languages => locales}/es-ES.js | 8 +- tests/{languages => locales}/es.js | 8 +- tests/{languages => locales}/et.js | 8 +- tests/{languages => locales}/fi.js | 8 +- tests/{languages => locales}/fr-CA.js | 8 +- tests/{languages => locales}/fr-ch.js | 8 +- tests/{languages => locales}/fr.js | 8 +- tests/{languages => locales}/hu.js | 8 +- tests/{languages => locales}/it.js | 8 +- tests/{languages => locales}/ja.js | 8 +- tests/{languages => locales}/lv.js | 8 +- tests/{languages => locales}/nl-nl.js | 8 +- tests/{languages => locales}/no.js | 8 +- tests/{languages => locales}/pl.js | 8 +- tests/{languages => locales}/pt-br.js | 8 +- tests/{languages => locales}/pt-pt.js | 8 +- tests/{languages => locales}/ru-UA.js | 8 +- tests/{languages => locales}/ru.js | 8 +- tests/{languages => locales}/sk.js | 8 +- tests/{languages => locales}/th.js | 8 +- tests/{languages => locales}/tr.js | 8 +- tests/{languages => locales}/uk-UA.js | 8 +- tests/numeral/misc.js | 24 +- tests/numeral/validate.js | 6 +- 99 files changed, 742 insertions(+), 739 deletions(-) rename languages.js => locales.js (78%) rename {languages => locales}/be-nl.js (78%) rename {languages => locales}/chs.js (73%) rename {languages => locales}/cs.js (77%) rename {languages => locales}/da-dk.js (76%) rename {languages => locales}/de-ch.js (76%) rename {languages => locales}/de.js (71%) rename {languages => locales}/en-gb.js (79%) rename {languages => locales}/en-za.js (79%) rename {languages => locales}/es-ES.js (81%) rename {languages => locales}/es.js (81%) rename {languages => locales}/et.js (79%) rename {languages => locales}/fi.js (77%) rename {languages => locales}/fr-CA.js (76%) rename {languages => locales}/fr-ch.js (77%) rename {languages => locales}/fr.js (77%) rename {languages => locales}/hu.js (78%) rename {languages => locales}/it.js (76%) rename {languages => locales}/ja.js (77%) rename {languages => locales}/lv.js (77%) rename {languages => locales}/nl-nl.js (79%) rename {languages => locales}/no.js (61%) rename {languages => locales}/pl.js (77%) rename {languages => locales}/pt-br.js (75%) rename {languages => locales}/pt-pt.js (76%) rename {languages => locales}/ru-UA.js (79%) rename {languages => locales}/ru.js (81%) rename {languages => locales}/sk.js (77%) rename {languages => locales}/th.js (79%) rename {languages => locales}/tr.js (89%) rename {languages => locales}/uk-UA.js (79%) rename min/{languages.min.js => locales.min.js} (64%) rename min/{languages => locales}/be-nl.min.js (72%) rename min/{languages => locales}/chs.min.js (65%) rename min/{languages => locales}/cs.min.js (68%) rename min/{languages => locales}/da-dk.min.js (67%) rename min/{languages => locales}/de-ch.min.js (69%) rename min/{languages => locales}/de.min.js (60%) rename min/{languages => locales}/en-gb.min.js (69%) rename min/{languages => locales}/en-za.min.js (69%) rename min/{languages => locales}/es-ES.min.js (69%) rename min/{languages => locales}/es.min.js (70%) rename min/{languages => locales}/et.min.js (72%) rename min/{languages => locales}/fi.min.js (69%) rename min/{languages => locales}/fr-CA.min.js (66%) rename min/{languages => locales}/fr-ch.min.js (66%) rename min/{languages => locales}/fr.min.js (67%) rename min/{languages => locales}/hu.min.js (68%) rename min/{languages => locales}/it.min.js (66%) rename min/{languages => locales}/ja.min.js (67%) rename min/{languages => locales}/lv.min.js (78%) rename min/{languages => locales}/nl-nl.min.js (71%) rename min/{languages => locales}/no.min.js (52%) rename min/{languages => locales}/pl.min.js (68%) rename min/{languages => locales}/pt-br.min.js (65%) rename min/{languages => locales}/pt-pt.min.js (67%) rename min/{languages => locales}/ru-UA.min.js (72%) rename min/{languages => locales}/ru.min.js (77%) rename min/{languages => locales}/sk.min.js (68%) rename min/{languages => locales}/th.min.js (73%) rename min/{languages => locales}/tr.min.js (85%) rename min/{languages => locales}/uk-UA.min.js (87%) rename tests/{languages => locales}/be-nl.js (94%) rename tests/{languages => locales}/chs.js (94%) rename tests/{languages => locales}/cs.js (94%) rename tests/{languages => locales}/da-dk.js (94%) rename tests/{languages => locales}/de-ch.js (94%) rename tests/{languages => locales}/de.js (94%) rename tests/{languages => locales}/en-gb.js (94%) rename tests/{languages => locales}/en-za.js (94%) rename tests/{languages => locales}/en.js (98%) rename tests/{languages => locales}/es-ES.js (94%) rename tests/{languages => locales}/es.js (94%) rename tests/{languages => locales}/et.js (94%) rename tests/{languages => locales}/fi.js (94%) rename tests/{languages => locales}/fr-CA.js (94%) rename tests/{languages => locales}/fr-ch.js (94%) rename tests/{languages => locales}/fr.js (94%) rename tests/{languages => locales}/hu.js (94%) rename tests/{languages => locales}/it.js (94%) rename tests/{languages => locales}/ja.js (94%) rename tests/{languages => locales}/lv.js (94%) rename tests/{languages => locales}/nl-nl.js (94%) rename tests/{languages => locales}/no.js (94%) rename tests/{languages => locales}/pl.js (94%) rename tests/{languages => locales}/pt-br.js (94%) rename tests/{languages => locales}/pt-pt.js (94%) rename tests/{languages => locales}/ru-UA.js (94%) rename tests/{languages => locales}/ru.js (94%) rename tests/{languages => locales}/sk.js (94%) rename tests/{languages => locales}/th.js (94%) rename tests/{languages => locales}/tr.js (94%) rename tests/{languages => locales}/uk-UA.js (94%) diff --git a/Gruntfile.js b/Gruntfile.js index 41525e26..c2592eb3 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -6,16 +6,16 @@ module.exports = function(grunt) { 'min/numeral.min.js' : [ 'numeral.js' ], - 'min/languages.min.js': [ - 'languages.js' + 'min/locales.min.js': [ + 'locales.js' ] }; // all the lang files need to be added manually - fs.readdirSync('./languages').forEach(function (path) { + fs.readdirSync('./locales').forEach(function (path) { var file = path.slice(0, -3), - destination = 'min/languages/' + file + '.min.js', - src = ['languages/' + path]; + destination = 'min/locales/' + file + '.min.js', + src = ['locales/' + path]; minifiedFiles[destination] = src; }); @@ -24,16 +24,16 @@ module.exports = function(grunt) { mochaTest : { all: [ 'tests/numeral/*.js', - 'tests/languages/*.js' + 'tests/locales/*.js' ] }, karma: { options: { files: [ 'numeral.js', - 'languages/*.js', + 'locales/*.js', 'tests/numeral/*.js', - 'tests/languages/*.js' + 'tests/locales/*.js' ], frameworks: [ 'mocha', @@ -61,18 +61,18 @@ module.exports = function(grunt) { } }, concat: { - languages: { + locales: { src: [ - 'languages/*.js' + 'locales/*.js' ], - dest: 'languages.js' + dest: 'locales.js' } }, jshint: { all: [ 'Gruntfile.js', 'numeral.js', - 'languages/*.js' + 'locales/*.js' ], options: { 'node': true, diff --git a/README.md b/README.md index 86367110..7ea73d4d 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,8 @@ See [the english unit tests](https://github.com/adamwdraper/Numeral-js/blob/mast ### 2.0.0 +Breaking change: All `language` now renamed to `locale` and standardized to all lowercase filenames + Breaking change: 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 diff --git a/languages.js b/locales.js similarity index 78% rename from languages.js rename to locales.js index ddef04b6..5cec3e7b 100644 --- a/languages.js +++ b/locales.js @@ -1,10 +1,10 @@ /*! @preserve - * numeral.js language configuration - * language : belgium-dutch (be-nl) + * numeral.js locale configuration + * locale : belgium-dutch (be-nl) * author : Dieter Luypaert : https://github.com/moeriki */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal : ',' @@ -26,20 +26,21 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('be-nl', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('be-nl', locale); } }()); + /*! @preserve - * numeral.js language configuration - * language : simplified chinese + * numeral.js locale configuration + * locale : simplified chinese * author : badplum : https://github.com/badplum */ (function () { - var language = { + var locale = { delimiters: { thousands: ',', decimal: '.' @@ -60,21 +61,21 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('chs', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('chs', locale); } }()); /*! @preserve - * numeral.js language configuration - * language : czech (cs) + * numeral.js locale configuration + * locale : czech (cs) * author : Anatoli Papirovski : https://github.com/apapirovski */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -95,21 +96,21 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('cs', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('cs', locale); } }()); /*! @preserve - * numeral.js language configuration - * language : danish denmark (dk) + * numeral.js locale configuration + * locale : danish denmark (dk) * author : Michael Storgaard : https://github.com/mstorgaard */ (function () { - var language = { + var locale = { delimiters: { thousands: '.', decimal: ',' @@ -130,20 +131,20 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('da-dk', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('da-dk', locale); } }()); /*! @preserve - * numeral.js language configuration - * language : German in Switzerland (de-ch) + * 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 () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -164,20 +165,20 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('de-ch', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('de-ch', locale); } }()); /*! @preserve - * numeral.js language configuration - * language : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium + * numeral.js locale configuration + * locale : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium * author : Marco Krage : https://github.com/sinky */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -198,20 +199,20 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('de', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('de', locale); } }()); /*! @preserve - * numeral.js language configuration - * language : english united kingdom (uk) + * numeral.js locale configuration + * locale : english united kingdom (uk) * author : Dan Ristic : https://github.com/dristic */ (function () { - var language = { + var locale = { delimiters: { thousands: ',', decimal: '.' @@ -236,20 +237,20 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('en-gb', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('en-gb', locale); } }()); /*! - * numeral.js language configuration - * language : english south africa (uk) + * numeral.js locale configuration + * locale : english south africa (uk) * author : Etienne Boshoff : etienne@zailab.com */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -274,20 +275,20 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('en-za', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('en-za', locale); } }()); /*! @preserve - * numeral.js language configuration - * language : spanish Spain + * numeral.js locale configuration + * locale : spanish Spain * author : Hernan Garcia : https://github.com/hgarcia */ (function () { - var language = { + var locale = { delimiters: { thousands: '.', decimal: ',' @@ -313,21 +314,21 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('es-ES', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('es-ES', locale); } }()); /*! @preserve - * numeral.js language configuration - * language : spanish + * numeral.js locale configuration + * locale : spanish * author : Hernan Garcia : https://github.com/hgarcia */ (function () { - var language = { + var locale = { delimiters: { thousands: '.', decimal: ',' @@ -353,24 +354,24 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('es', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('es', locale); } }()); /*! @preserve - * numeral.js language configuration - * language : Estonian + * 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 () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -391,21 +392,21 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('et', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('et', locale); } }()); /*! @preserve - * numeral.js language configuration - * language : Finnish + * numeral.js locale configuration + * locale : Finnish * author : Sami Saada : https://github.com/samitheberber */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -426,21 +427,21 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('fi', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('fi', locale); } }()); /*! @preserve - * numeral.js language configuration - * language : french (Canada) (fr-CA) + * numeral.js locale configuration + * locale : french (Canada) (fr-CA) * author : Léo Renaud-Allaire : https://github.com/renaudleo */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -461,20 +462,20 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('fr-CA', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('fr-CA', locale); } }()); /*! @preserve - * numeral.js language configuration - * language : french (fr-ch) + * numeral.js locale configuration + * locale : french (fr-ch) * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var language = { + var locale = { delimiters: { thousands: '\'', decimal: '.' @@ -495,21 +496,21 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('fr-ch', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('fr-ch', locale); } }()); /*! @preserve - * numeral.js language configuration - * language : french (fr) + * numeral.js locale configuration + * locale : french (fr) * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -530,20 +531,20 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('fr', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('fr', locale); } }()); /*! @preserve - * numeral.js language configuration - * language : Hungarian (hu) + * numeral.js locale configuration + * locale : Hungarian (hu) * author : Peter Bakondy : https://github.com/pbakondy */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -564,20 +565,20 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('hu', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('hu', locale); } }()); /*! @preserve - * numeral.js language configuration - * language : italian Italy (it) + * numeral.js locale configuration + * locale : italian Italy (it) * author : Giacomo Trombi : http://cinquepunti.it */ (function () { - var language = { + var locale = { delimiters: { thousands: '.', decimal: ',' @@ -598,20 +599,20 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('it', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('it', locale); } }()); /*! @preserve - * numeral.js language configuration - * language : japanese + * numeral.js locale configuration + * locale : japanese * author : teppeis : https://github.com/teppeis */ (function () { - var language = { + var locale = { delimiters: { thousands: ',', decimal: '.' @@ -632,21 +633,21 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('ja', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('ja', locale); } }()); /*! @preserve - * numeral.js language configuration - * language : Latvian (lv) + * numeral.js locale configuration + * locale : Latvian (lv) * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -666,21 +667,21 @@ }; // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('lv', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('lv', locale); } }()); /*! @preserve - * numeral.js language configuration - * language : netherlands-dutch (nl-nl) + * numeral.js locale configuration + * locale : netherlands-dutch (nl-nl) * author : Dave Clayton : https://github.com/davedx */ (function () { - var language = { + var locale = { delimiters: { thousands: '.', decimal : ',' @@ -702,20 +703,20 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('nl-nl', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('nl-nl', locale); } }()); /*! - * numeral.js language configuration - * language : norwegian (bokmål) + * numeral.js locale configuration + * locale : norwegian (bokmål) * author : Ove Andersen : https://github.com/azzlack */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -736,24 +737,24 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('nb-no', language); - this.numeral.language('nn-no', language); - this.numeral.language('no', language); - this.numeral.language('nb', language); - this.numeral.language('nn', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('nb-no', locale); + this.numeral.locale('nn-no', locale); + this.numeral.locale('no', locale); + this.numeral.locale('nb', locale); + this.numeral.locale('nn', locale); } }()); /*! @preserve - * numeral.js language configuration - * language : polish (pl) + * numeral.js locale configuration + * locale : polish (pl) * author : Dominik Bulaj : https://github.com/dominikbulaj */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -774,20 +775,20 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('pl', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('pl', locale); } }()); /*! @preserve - * numeral.js language configuration - * language : portuguese brazil (pt-br) + * numeral.js locale configuration + * locale : portuguese brazil (pt-br) * author : Ramiro Varandas Jr : https://github.com/ramirovjr */ (function () { - var language = { + var locale = { delimiters: { thousands: '.', decimal: ',' @@ -808,20 +809,20 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('pt-br', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('pt-br', locale); } }()); /*! @preserve - * numeral.js language configuration - * language : portuguese (pt-pt) + * numeral.js locale configuration + * locale : portuguese (pt-pt) * author : Diogo Resende : https://github.com/dresende */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -842,19 +843,19 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('pt-pt', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('pt-pt', locale); } }()); -// numeral.js language configuration -// language : Russian for the Ukraine (ru-UA) +// numeral.js locale configuration +// locale : Russian for the Ukraine (ru-UA) // author : Anatoli Papirovski : https://github.com/apapirovski (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -878,21 +879,21 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('ru-UA', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('ru-UA', locale); } }()); /*! @preserve - * numeral.js language configuration - * language : russian (ru) + * numeral.js locale configuration + * locale : russian (ru) * author : Anatoli Papirovski : https://github.com/apapirovski */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -916,21 +917,21 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('ru', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('ru', locale); } }()); /*! @preserve - * numeral.js language configuration - * language : slovak (sk) + * numeral.js locale configuration + * locale : slovak (sk) * author : Ahmed Al Hafoudh : http://www.freevision.sk */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -951,21 +952,21 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('sk', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('sk', locale); } }()); /*! @preserve - * numeral.js language configuration - * language : thai (th) + * numeral.js locale configuration + * locale : thai (th) * author : Sathit Jittanupat : https://github.com/jojosati */ (function () { - var language = { + var locale = { delimiters: { thousands: ',', decimal: '.' @@ -986,17 +987,17 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('th', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('th', locale); } }()); /*! @preserve - * numeral.js language configuration - * language : turkish (tr) + * 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 () { @@ -1025,7 +1026,7 @@ 60: '\'ıncı', 90: '\'ıncı' }, - language = { + locale = { delimiters: { thousands: '.', decimal: ',' @@ -1054,19 +1055,19 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('tr', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('tr', locale); } }()); -// 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 = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -1090,10 +1091,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('uk-UA', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('uk-UA', locale); } }()); diff --git a/languages/be-nl.js b/locales/be-nl.js similarity index 78% rename from languages/be-nl.js rename to locales/be-nl.js index 78d8cd06..836e50ff 100644 --- a/languages/be-nl.js +++ b/locales/be-nl.js @@ -1,10 +1,10 @@ /*! @preserve - * numeral.js language configuration - * language : belgium-dutch (be-nl) + * numeral.js locale configuration + * locale : belgium-dutch (be-nl) * author : Dieter Luypaert : https://github.com/moeriki */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal : ',' @@ -26,10 +26,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('be-nl', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('be-nl', locale); } -}()); \ No newline at end of file +}()); diff --git a/languages/chs.js b/locales/chs.js similarity index 73% rename from languages/chs.js rename to locales/chs.js index ab88f61d..7eed3adc 100644 --- a/languages/chs.js +++ b/locales/chs.js @@ -1,10 +1,10 @@ /*! @preserve - * numeral.js language configuration - * language : simplified chinese + * numeral.js locale configuration + * locale : simplified chinese * author : badplum : https://github.com/badplum */ (function () { - var language = { + var locale = { delimiters: { thousands: ',', decimal: '.' @@ -25,10 +25,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('chs', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('chs', locale); } }()); diff --git a/languages/cs.js b/locales/cs.js similarity index 77% rename from languages/cs.js rename to locales/cs.js index 15aa7121..5d3ceb2d 100644 --- a/languages/cs.js +++ b/locales/cs.js @@ -1,10 +1,10 @@ /*! @preserve - * numeral.js language configuration - * language : czech (cs) + * numeral.js locale configuration + * locale : czech (cs) * author : Anatoli Papirovski : https://github.com/apapirovski */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -25,10 +25,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('cs', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('cs', locale); } }()); diff --git a/languages/da-dk.js b/locales/da-dk.js similarity index 76% rename from languages/da-dk.js rename to locales/da-dk.js index ae7b41ec..aada27c8 100644 --- a/languages/da-dk.js +++ b/locales/da-dk.js @@ -1,10 +1,10 @@ /*! @preserve - * numeral.js language configuration - * language : danish denmark (dk) + * numeral.js locale configuration + * locale : danish denmark (dk) * author : Michael Storgaard : https://github.com/mstorgaard */ (function () { - var language = { + var locale = { delimiters: { thousands: '.', decimal: ',' @@ -25,10 +25,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('da-dk', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('da-dk', locale); } }()); \ No newline at end of file diff --git a/languages/de-ch.js b/locales/de-ch.js similarity index 76% rename from languages/de-ch.js rename to locales/de-ch.js index cd5afa5b..d2b6bb64 100644 --- a/languages/de-ch.js +++ b/locales/de-ch.js @@ -1,10 +1,10 @@ /*! @preserve - * numeral.js language configuration - * language : German in Switzerland (de-ch) + * 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 () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -25,10 +25,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('de-ch', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('de-ch', locale); } }()); \ No newline at end of file diff --git a/languages/de.js b/locales/de.js similarity index 71% rename from languages/de.js rename to locales/de.js index 422408bb..20495f02 100644 --- a/languages/de.js +++ b/locales/de.js @@ -1,10 +1,10 @@ /*! @preserve - * numeral.js language configuration - * language : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium + * numeral.js locale configuration + * locale : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium * author : Marco Krage : https://github.com/sinky */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -25,10 +25,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('de', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('de', locale); } }()); \ No newline at end of file diff --git a/languages/en-gb.js b/locales/en-gb.js similarity index 79% rename from languages/en-gb.js rename to locales/en-gb.js index f1bac3e3..bd813462 100644 --- a/languages/en-gb.js +++ b/locales/en-gb.js @@ -1,10 +1,10 @@ /*! @preserve - * numeral.js language configuration - * language : english united kingdom (uk) + * numeral.js locale configuration + * locale : english united kingdom (uk) * author : Dan Ristic : https://github.com/dristic */ (function () { - var language = { + var locale = { delimiters: { thousands: ',', decimal: '.' @@ -29,10 +29,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('en-gb', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('en-gb', locale); } }()); \ No newline at end of file diff --git a/languages/en-za.js b/locales/en-za.js similarity index 79% rename from languages/en-za.js rename to locales/en-za.js index 0a57b45c..72d50450 100644 --- a/languages/en-za.js +++ b/locales/en-za.js @@ -1,10 +1,10 @@ /*! - * numeral.js language configuration - * language : english south africa (uk) + * numeral.js locale configuration + * locale : english south africa (uk) * author : Etienne Boshoff : etienne@zailab.com */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -29,10 +29,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('en-za', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('en-za', locale); } }()); \ No newline at end of file diff --git a/languages/es-ES.js b/locales/es-ES.js similarity index 81% rename from languages/es-ES.js rename to locales/es-ES.js index f1e61bdd..50ad1a90 100644 --- a/languages/es-ES.js +++ b/locales/es-ES.js @@ -1,10 +1,10 @@ /*! @preserve - * numeral.js language configuration - * language : spanish Spain + * numeral.js locale configuration + * locale : spanish Spain * author : Hernan Garcia : https://github.com/hgarcia */ (function () { - var language = { + var locale = { delimiters: { thousands: '.', decimal: ',' @@ -30,10 +30,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('es-ES', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('es-ES', locale); } }()); diff --git a/languages/es.js b/locales/es.js similarity index 81% rename from languages/es.js rename to locales/es.js index d084de38..c3276634 100644 --- a/languages/es.js +++ b/locales/es.js @@ -1,10 +1,10 @@ /*! @preserve - * numeral.js language configuration - * language : spanish + * numeral.js locale configuration + * locale : spanish * author : Hernan Garcia : https://github.com/hgarcia */ (function () { - var language = { + var locale = { delimiters: { thousands: '.', decimal: ',' @@ -30,10 +30,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('es', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('es', locale); } }()); diff --git a/languages/et.js b/locales/et.js similarity index 79% rename from languages/et.js rename to locales/et.js index cb81dd67..3d5826f9 100644 --- a/languages/et.js +++ b/locales/et.js @@ -1,13 +1,13 @@ /*! @preserve - * numeral.js language configuration - * language : Estonian + * 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 () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -28,10 +28,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('et', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('et', locale); } }()); diff --git a/languages/fi.js b/locales/fi.js similarity index 77% rename from languages/fi.js rename to locales/fi.js index a8c16915..5efac798 100644 --- a/languages/fi.js +++ b/locales/fi.js @@ -1,10 +1,10 @@ /*! @preserve - * numeral.js language configuration - * language : Finnish + * numeral.js locale configuration + * locale : Finnish * author : Sami Saada : https://github.com/samitheberber */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -25,10 +25,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('fi', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('fi', locale); } }()); diff --git a/languages/fr-CA.js b/locales/fr-CA.js similarity index 76% rename from languages/fr-CA.js rename to locales/fr-CA.js index 3e95f0cd..9b4ca436 100644 --- a/languages/fr-CA.js +++ b/locales/fr-CA.js @@ -1,10 +1,10 @@ /*! @preserve - * numeral.js language configuration - * language : french (Canada) (fr-CA) + * numeral.js locale configuration + * locale : french (Canada) (fr-CA) * author : Léo Renaud-Allaire : https://github.com/renaudleo */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -25,10 +25,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('fr-CA', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('fr-CA', locale); } }()); \ No newline at end of file diff --git a/languages/fr-ch.js b/locales/fr-ch.js similarity index 77% rename from languages/fr-ch.js rename to locales/fr-ch.js index 40072e49..73ff5965 100644 --- a/languages/fr-ch.js +++ b/locales/fr-ch.js @@ -1,10 +1,10 @@ /*! @preserve - * numeral.js language configuration - * language : french (fr-ch) + * numeral.js locale configuration + * locale : french (fr-ch) * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var language = { + var locale = { delimiters: { thousands: '\'', decimal: '.' @@ -25,10 +25,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('fr-ch', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('fr-ch', locale); } }()); diff --git a/languages/fr.js b/locales/fr.js similarity index 77% rename from languages/fr.js rename to locales/fr.js index d2b3dd69..a6d8f474 100644 --- a/languages/fr.js +++ b/locales/fr.js @@ -1,10 +1,10 @@ /*! @preserve - * numeral.js language configuration - * language : french (fr) + * numeral.js locale configuration + * locale : french (fr) * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -25,10 +25,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('fr', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('fr', locale); } }()); \ No newline at end of file diff --git a/languages/hu.js b/locales/hu.js similarity index 78% rename from languages/hu.js rename to locales/hu.js index dc2119e7..e587db2c 100644 --- a/languages/hu.js +++ b/locales/hu.js @@ -1,10 +1,10 @@ /*! @preserve - * numeral.js language configuration - * language : Hungarian (hu) + * numeral.js locale configuration + * locale : Hungarian (hu) * author : Peter Bakondy : https://github.com/pbakondy */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -25,10 +25,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('hu', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('hu', locale); } }()); \ No newline at end of file diff --git a/languages/it.js b/locales/it.js similarity index 76% rename from languages/it.js rename to locales/it.js index 502c7b9b..4d5ae6a2 100644 --- a/languages/it.js +++ b/locales/it.js @@ -1,10 +1,10 @@ /*! @preserve - * numeral.js language configuration - * language : italian Italy (it) + * numeral.js locale configuration + * locale : italian Italy (it) * author : Giacomo Trombi : http://cinquepunti.it */ (function () { - var language = { + var locale = { delimiters: { thousands: '.', decimal: ',' @@ -25,10 +25,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('it', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('it', locale); } }()); \ No newline at end of file diff --git a/languages/ja.js b/locales/ja.js similarity index 77% rename from languages/ja.js rename to locales/ja.js index c1c28e09..8f008f76 100644 --- a/languages/ja.js +++ b/locales/ja.js @@ -1,10 +1,10 @@ /*! @preserve - * numeral.js language configuration - * language : japanese + * numeral.js locale configuration + * locale : japanese * author : teppeis : https://github.com/teppeis */ (function () { - var language = { + var locale = { delimiters: { thousands: ',', decimal: '.' @@ -25,10 +25,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('ja', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('ja', locale); } }()); diff --git a/languages/lv.js b/locales/lv.js similarity index 77% rename from languages/lv.js rename to locales/lv.js index 9cbf4851..0737c1ab 100644 --- a/languages/lv.js +++ b/locales/lv.js @@ -1,10 +1,10 @@ /*! @preserve - * numeral.js language configuration - * language : Latvian (lv) + * numeral.js locale configuration + * locale : Latvian (lv) * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -24,10 +24,10 @@ }; // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('lv', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('lv', locale); } }()); diff --git a/languages/nl-nl.js b/locales/nl-nl.js similarity index 79% rename from languages/nl-nl.js rename to locales/nl-nl.js index 5ea7354a..e64702e1 100644 --- a/languages/nl-nl.js +++ b/locales/nl-nl.js @@ -1,10 +1,10 @@ /*! @preserve - * numeral.js language configuration - * language : netherlands-dutch (nl-nl) + * numeral.js locale configuration + * locale : netherlands-dutch (nl-nl) * author : Dave Clayton : https://github.com/davedx */ (function () { - var language = { + var locale = { delimiters: { thousands: '.', decimal : ',' @@ -26,10 +26,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('nl-nl', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('nl-nl', locale); } }()); \ No newline at end of file diff --git a/languages/no.js b/locales/no.js similarity index 61% rename from languages/no.js rename to locales/no.js index 5fc36203..fec5a39e 100644 --- a/languages/no.js +++ b/locales/no.js @@ -1,10 +1,10 @@ /*! - * numeral.js language configuration - * language : norwegian (bokmål) + * numeral.js locale configuration + * locale : norwegian (bokmål) * author : Ove Andersen : https://github.com/azzlack */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -25,14 +25,14 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('nb-no', language); - this.numeral.language('nn-no', language); - this.numeral.language('no', language); - this.numeral.language('nb', language); - this.numeral.language('nn', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('nb-no', locale); + this.numeral.locale('nn-no', locale); + this.numeral.locale('no', locale); + this.numeral.locale('nb', locale); + this.numeral.locale('nn', locale); } }()); \ No newline at end of file diff --git a/languages/pl.js b/locales/pl.js similarity index 77% rename from languages/pl.js rename to locales/pl.js index 3ffd9011..59f5f6a2 100644 --- a/languages/pl.js +++ b/locales/pl.js @@ -1,10 +1,10 @@ /*! @preserve - * numeral.js language configuration - * language : polish (pl) + * numeral.js locale configuration + * locale : polish (pl) * author : Dominik Bulaj : https://github.com/dominikbulaj */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -25,10 +25,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('pl', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('pl', locale); } }()); \ No newline at end of file diff --git a/languages/pt-br.js b/locales/pt-br.js similarity index 75% rename from languages/pt-br.js rename to locales/pt-br.js index c9ff8424..0fd6e23d 100644 --- a/languages/pt-br.js +++ b/locales/pt-br.js @@ -1,10 +1,10 @@ /*! @preserve - * numeral.js language configuration - * language : portuguese brazil (pt-br) + * numeral.js locale configuration + * locale : portuguese brazil (pt-br) * author : Ramiro Varandas Jr : https://github.com/ramirovjr */ (function () { - var language = { + var locale = { delimiters: { thousands: '.', decimal: ',' @@ -25,10 +25,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('pt-br', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('pt-br', locale); } }()); \ No newline at end of file diff --git a/languages/pt-pt.js b/locales/pt-pt.js similarity index 76% rename from languages/pt-pt.js rename to locales/pt-pt.js index 83a174e0..9ad29b39 100644 --- a/languages/pt-pt.js +++ b/locales/pt-pt.js @@ -1,10 +1,10 @@ /*! @preserve - * numeral.js language configuration - * language : portuguese (pt-pt) + * numeral.js locale configuration + * locale : portuguese (pt-pt) * author : Diogo Resende : https://github.com/dresende */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -25,10 +25,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('pt-pt', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('pt-pt', locale); } }()); diff --git a/languages/ru-UA.js b/locales/ru-UA.js similarity index 79% rename from languages/ru-UA.js rename to locales/ru-UA.js index 37a1c046..5168a76f 100644 --- a/languages/ru-UA.js +++ b/locales/ru-UA.js @@ -1,8 +1,8 @@ -// numeral.js language configuration -// language : Russian for the Ukraine (ru-UA) +// numeral.js locale configuration +// locale : Russian for the Ukraine (ru-UA) // author : Anatoli Papirovski : https://github.com/apapirovski (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -26,10 +26,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('ru-UA', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('ru-UA', locale); } }()); diff --git a/languages/ru.js b/locales/ru.js similarity index 81% rename from languages/ru.js rename to locales/ru.js index ff22c83a..9f94dfa1 100644 --- a/languages/ru.js +++ b/locales/ru.js @@ -1,10 +1,10 @@ /*! @preserve - * numeral.js language configuration - * language : russian (ru) + * numeral.js locale configuration + * locale : russian (ru) * author : Anatoli Papirovski : https://github.com/apapirovski */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -28,10 +28,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('ru', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('ru', locale); } }()); diff --git a/languages/sk.js b/locales/sk.js similarity index 77% rename from languages/sk.js rename to locales/sk.js index 6bae7213..72f846a2 100644 --- a/languages/sk.js +++ b/locales/sk.js @@ -1,10 +1,10 @@ /*! @preserve - * numeral.js language configuration - * language : slovak (sk) + * numeral.js locale configuration + * locale : slovak (sk) * author : Ahmed Al Hafoudh : http://www.freevision.sk */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -25,10 +25,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('sk', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('sk', locale); } }()); diff --git a/languages/th.js b/locales/th.js similarity index 79% rename from languages/th.js rename to locales/th.js index f1f8a214..9203051d 100644 --- a/languages/th.js +++ b/locales/th.js @@ -1,10 +1,10 @@ /*! @preserve - * numeral.js language configuration - * language : thai (th) + * numeral.js locale configuration + * locale : thai (th) * author : Sathit Jittanupat : https://github.com/jojosati */ (function () { - var language = { + var locale = { delimiters: { thousands: ',', decimal: '.' @@ -25,10 +25,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('th', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('th', locale); } }()); diff --git a/languages/tr.js b/locales/tr.js similarity index 89% rename from languages/tr.js rename to locales/tr.js index 1f333876..8f58b9b5 100644 --- a/languages/tr.js +++ b/locales/tr.js @@ -1,6 +1,6 @@ /*! @preserve - * numeral.js language configuration - * language : turkish (tr) + * 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 () { @@ -29,7 +29,7 @@ 60: '\'ıncı', 90: '\'ıncı' }, - language = { + locale = { delimiters: { thousands: '.', decimal: ',' @@ -58,10 +58,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('tr', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('tr', locale); } }()); diff --git a/languages/uk-UA.js b/locales/uk-UA.js similarity index 79% rename from languages/uk-UA.js rename to locales/uk-UA.js index ef54fd4a..9bee3ddf 100644 --- a/languages/uk-UA.js +++ b/locales/uk-UA.js @@ -1,8 +1,8 @@ -// 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 = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -26,10 +26,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('uk-UA', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('uk-UA', locale); } }()); diff --git a/min/languages.min.js b/min/locales.min.js similarity index 64% rename from min/languages.min.js rename to min/locales.min.js index 4f1fda68..6e549e5e 100644 --- a/min/languages.min.js +++ b/min/locales.min.js @@ -1,144 +1,144 @@ /*! @preserve - * numeral.js language configuration - * language : belgium-dutch (be-nl) + * numeral.js locale configuration + * locale : 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)}(),/*! @preserve - * numeral.js language configuration - * language : simplified chinese +!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.locale&&this.numeral.locale("be-nl",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : simplified chinese * author : badplum : https://github.com/badplum */ -function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("chs",a)}(),/*! @preserve - * numeral.js language configuration - * language : czech (cs) +function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("chs",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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)}(),/*! @preserve - * numeral.js language configuration - * language : danish denmark (dk) +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.locale&&this.numeral.locale("cs",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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(a){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)}(),/*! @preserve - * numeral.js language configuration - * language : German in Switzerland (de-ch) +function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mia",trillion:"b"},ordinal:function(a){return"."},currency:{symbol:"DKK"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("da-dk",a)}(),/*! @preserve + * 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(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){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)}(),/*! @preserve - * numeral.js language configuration - * language : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"CHF"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de-ch",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("de",a)}(),/*! @preserve - * numeral.js language configuration - * language : english united kingdom (uk) +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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 : english south africa (uk) +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.locale&&this.numeral.locale("en-gb",a)}(),/*! + * numeral.js locale configuration + * locale : english south africa (uk) * author : Etienne Boshoff : etienne@zailab.com */ -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:"R"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("en-za",a)}(),/*! @preserve - * numeral.js language configuration - * language : spanish Spain +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:"R"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("en-za",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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-ES",a)}(),/*! @preserve - * numeral.js language configuration - * language : spanish +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.locale&&this.numeral.locale("es-ES",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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)}(),/*! @preserve - * numeral.js language configuration - * language : Estonian +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.locale&&this.numeral.locale("es",a)}(),/*! @preserve + * 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(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("et",a)}(),/*! @preserve - * numeral.js language configuration - * language : Finnish +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("et",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("fi",a)}(),/*! @preserve - * numeral.js language configuration - * language : french (Canada) (fr-CA) +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("fi",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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)}(),/*! @preserve - * numeral.js language configuration - * language : french (fr-ch) +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.locale&&this.numeral.locale("fr-CA",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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)}(),/*! @preserve - * numeral.js language configuration - * language : french (fr) +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.locale&&this.numeral.locale("fr-ch",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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)}(),/*! @preserve - * numeral.js language configuration - * language : Hungarian (hu) +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.locale&&this.numeral.locale("fr",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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(a){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)}(),/*! @preserve - * numeral.js language configuration - * language : italian Italy (it) +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("hu",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("it",a)}(),/*! @preserve - * numeral.js language configuration - * language : japanese +function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("it",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : japanese * author : teppeis : https://github.com/teppeis */ -function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("ja",a)}(),/*! @preserve - * numeral.js language configuration - * language : Latvian (lv) +function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("ja",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : Latvian (lv) * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks */ -function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("lv",a)}(),/*! @preserve - * numeral.js language configuration - * language : netherlands-dutch (nl-nl) +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("lv",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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 : norwegian (bokmål) +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.locale&&this.numeral.locale("nl-nl",a)}(),/*! + * numeral.js locale configuration + * locale : norwegian (bokmål) * author : Ove Andersen : https://github.com/azzlack */ -function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&(this.numeral.language("nb-no",a),this.numeral.language("nn-no",a),this.numeral.language("no",a),this.numeral.language("nb",a),this.numeral.language("nn",a))}(),/*! @preserve - * numeral.js language configuration - * language : polish (pl) +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&(this.numeral.locale("nb-no",a),this.numeral.locale("nn-no",a),this.numeral.locale("no",a),this.numeral.locale("nb",a),this.numeral.locale("nn",a))}(),/*! @preserve + * numeral.js locale configuration + * locale : 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(a){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)}(),/*! @preserve - * numeral.js language configuration - * language : portuguese brazil (pt-br) +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pl",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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(a){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)}(),/*! @preserve - * numeral.js language configuration - * language : portuguese (pt-pt) +function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mil",million:"milhões",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"R$"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pt-br",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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(a){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)}(),/*! @preserve - * numeral.js language configuration - * language : russian (ru) +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("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.locale&&this.numeral.locale("ru-UA",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : russian (ru) * author : Anatoli Papirovski : https://github.com/apapirovski */ -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("ru",a)}(),/*! @preserve - * numeral.js language configuration - * language : slovak (sk) +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.locale&&this.numeral.locale("ru",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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)}(),/*! @preserve - * numeral.js language configuration - * language : thai (th) +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.locale&&this.numeral.locale("sk",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : thai (th) * author : Sathit Jittanupat : https://github.com/jojosati */ -function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("th",a)}(),/*! @preserve - * numeral.js language configuration - * language : turkish (tr) +function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("th",a)}(),/*! @preserve + * 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(){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 +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.locale&&this.numeral.locale("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.locale&&this.numeral.locale("uk-UA",a)}(); \ No newline at end of file diff --git a/min/languages/be-nl.min.js b/min/locales/be-nl.min.js similarity index 72% rename from min/languages/be-nl.min.js rename to min/locales/be-nl.min.js index 8450d92d..45b353bc 100644 --- a/min/languages/be-nl.min.js +++ b/min/locales/be-nl.min.js @@ -1,6 +1,6 @@ /*! @preserve - * numeral.js language configuration - * language : belgium-dutch (be-nl) + * numeral.js locale configuration + * locale : 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 +!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.locale&&this.numeral.locale("be-nl",a)}(); \ No newline at end of file diff --git a/min/languages/chs.min.js b/min/locales/chs.min.js similarity index 65% rename from min/languages/chs.min.js rename to min/locales/chs.min.js index 77aa10a7..532af4de 100644 --- a/min/languages/chs.min.js +++ b/min/locales/chs.min.js @@ -1,6 +1,6 @@ /*! @preserve - * numeral.js language configuration - * language : simplified chinese + * numeral.js locale configuration + * locale : simplified chinese * author : badplum : https://github.com/badplum */ -!function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){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 +!function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("chs",a)}(); \ No newline at end of file diff --git a/min/languages/cs.min.js b/min/locales/cs.min.js similarity index 68% rename from min/languages/cs.min.js rename to min/locales/cs.min.js index 0fddd92d..ff93d158 100644 --- a/min/languages/cs.min.js +++ b/min/locales/cs.min.js @@ -1,6 +1,6 @@ /*! @preserve - * numeral.js language configuration - * language : czech (cs) + * numeral.js locale configuration + * locale : 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 +!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.locale&&this.numeral.locale("cs",a)}(); \ No newline at end of file diff --git a/min/languages/da-dk.min.js b/min/locales/da-dk.min.js similarity index 67% rename from min/languages/da-dk.min.js rename to min/locales/da-dk.min.js index 5697c3fe..d12df301 100644 --- a/min/languages/da-dk.min.js +++ b/min/locales/da-dk.min.js @@ -1,6 +1,6 @@ /*! @preserve - * numeral.js language configuration - * language : danish denmark (dk) + * numeral.js locale configuration + * locale : 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(a){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 +!function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mia",trillion:"b"},ordinal:function(a){return"."},currency:{symbol:"DKK"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("da-dk",a)}(); \ No newline at end of file diff --git a/min/languages/de-ch.min.js b/min/locales/de-ch.min.js similarity index 69% rename from min/languages/de-ch.min.js rename to min/locales/de-ch.min.js index 8f359117..90e0bd13 100644 --- a/min/languages/de-ch.min.js +++ b/min/locales/de-ch.min.js @@ -1,6 +1,6 @@ /*! @preserve - * numeral.js language configuration - * language : German in Switzerland (de-ch) + * 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(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){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 +!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"CHF"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de-ch",a)}(); \ No newline at end of file diff --git a/min/languages/de.min.js b/min/locales/de.min.js similarity index 60% rename from min/languages/de.min.js rename to min/locales/de.min.js index 6911e0c5..9506a501 100644 --- a/min/languages/de.min.js +++ b/min/locales/de.min.js @@ -1,6 +1,6 @@ /*! @preserve - * numeral.js language configuration - * language : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium + * numeral.js locale configuration + * locale : 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(a){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 +!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de",a)}(); \ No newline at end of file diff --git a/min/languages/en-gb.min.js b/min/locales/en-gb.min.js similarity index 69% rename from min/languages/en-gb.min.js rename to min/locales/en-gb.min.js index 9938bf28..7ed000f5 100644 --- a/min/languages/en-gb.min.js +++ b/min/locales/en-gb.min.js @@ -1,6 +1,6 @@ /*! @preserve - * numeral.js language configuration - * language : english united kingdom (uk) + * numeral.js locale configuration + * locale : 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 +!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.locale&&this.numeral.locale("en-gb",a)}(); \ No newline at end of file diff --git a/min/languages/en-za.min.js b/min/locales/en-za.min.js similarity index 69% rename from min/languages/en-za.min.js rename to min/locales/en-za.min.js index 516c0a50..df38b31c 100644 --- a/min/languages/en-za.min.js +++ b/min/locales/en-za.min.js @@ -1,6 +1,6 @@ /*! - * numeral.js language configuration - * language : english south africa (uk) + * numeral.js locale configuration + * locale : english south africa (uk) * author : Etienne Boshoff : etienne@zailab.com */ -!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:"R"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("en-za",a)}(); \ No newline at end of file +!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:"R"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("en-za",a)}(); \ No newline at end of file diff --git a/min/languages/es-ES.min.js b/min/locales/es-ES.min.js similarity index 69% rename from min/languages/es-ES.min.js rename to min/locales/es-ES.min.js index 16f2fd45..3c0a9c85 100644 --- a/min/languages/es-ES.min.js +++ b/min/locales/es-ES.min.js @@ -1,6 +1,6 @@ /*! @preserve - * numeral.js language configuration - * language : spanish Spain + * numeral.js locale configuration + * locale : 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-ES",a)}(); \ No newline at end of file +!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.locale&&this.numeral.locale("es-ES",a)}(); \ No newline at end of file diff --git a/min/languages/es.min.js b/min/locales/es.min.js similarity index 70% rename from min/languages/es.min.js rename to min/locales/es.min.js index 6dd1e380..028cca7e 100644 --- a/min/languages/es.min.js +++ b/min/locales/es.min.js @@ -1,6 +1,6 @@ /*! @preserve - * numeral.js language configuration - * language : spanish + * numeral.js locale configuration + * locale : 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 +!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.locale&&this.numeral.locale("es",a)}(); \ No newline at end of file diff --git a/min/languages/et.min.js b/min/locales/et.min.js similarity index 72% rename from min/languages/et.min.js rename to min/locales/et.min.js index 9376cdc8..ad2e5f99 100644 --- a/min/languages/et.min.js +++ b/min/locales/et.min.js @@ -1,9 +1,9 @@ /*! @preserve - * numeral.js language configuration - * language : Estonian + * 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(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){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 +!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("et",a)}(); \ No newline at end of file diff --git a/min/languages/fi.min.js b/min/locales/fi.min.js similarity index 69% rename from min/languages/fi.min.js rename to min/locales/fi.min.js index 821e7a00..a68e2bf0 100644 --- a/min/languages/fi.min.js +++ b/min/locales/fi.min.js @@ -1,6 +1,6 @@ /*! @preserve - * numeral.js language configuration - * language : Finnish + * numeral.js locale configuration + * locale : 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(a){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 +!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("fi",a)}(); \ No newline at end of file diff --git a/min/languages/fr-CA.min.js b/min/locales/fr-CA.min.js similarity index 66% rename from min/languages/fr-CA.min.js rename to min/locales/fr-CA.min.js index 60e58b6f..cf67c8dc 100644 --- a/min/languages/fr-CA.min.js +++ b/min/locales/fr-CA.min.js @@ -1,6 +1,6 @@ /*! @preserve - * numeral.js language configuration - * language : french (Canada) (fr-CA) + * numeral.js locale configuration + * locale : 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 +!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.locale&&this.numeral.locale("fr-CA",a)}(); \ No newline at end of file diff --git a/min/languages/fr-ch.min.js b/min/locales/fr-ch.min.js similarity index 66% rename from min/languages/fr-ch.min.js rename to min/locales/fr-ch.min.js index b354bcd3..946a7322 100644 --- a/min/languages/fr-ch.min.js +++ b/min/locales/fr-ch.min.js @@ -1,6 +1,6 @@ /*! @preserve - * numeral.js language configuration - * language : french (fr-ch) + * numeral.js locale configuration + * locale : 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 +!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.locale&&this.numeral.locale("fr-ch",a)}(); \ No newline at end of file diff --git a/min/languages/fr.min.js b/min/locales/fr.min.js similarity index 67% rename from min/languages/fr.min.js rename to min/locales/fr.min.js index fdc97c19..620e00d5 100644 --- a/min/languages/fr.min.js +++ b/min/locales/fr.min.js @@ -1,6 +1,6 @@ /*! @preserve - * numeral.js language configuration - * language : french (fr) + * numeral.js locale configuration + * locale : 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 +!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.locale&&this.numeral.locale("fr",a)}(); \ No newline at end of file diff --git a/min/languages/hu.min.js b/min/locales/hu.min.js similarity index 68% rename from min/languages/hu.min.js rename to min/locales/hu.min.js index 52d5d94b..78cca6a4 100644 --- a/min/languages/hu.min.js +++ b/min/locales/hu.min.js @@ -1,6 +1,6 @@ /*! @preserve - * numeral.js language configuration - * language : Hungarian (hu) + * numeral.js locale configuration + * locale : 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(a){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 +!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("hu",a)}(); \ No newline at end of file diff --git a/min/languages/it.min.js b/min/locales/it.min.js similarity index 66% rename from min/languages/it.min.js rename to min/locales/it.min.js index 16f30ac4..452d6920 100644 --- a/min/languages/it.min.js +++ b/min/locales/it.min.js @@ -1,6 +1,6 @@ /*! @preserve - * numeral.js language configuration - * language : italian Italy (it) + * numeral.js locale configuration + * locale : 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(a){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 +!function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("it",a)}(); \ No newline at end of file diff --git a/min/languages/ja.min.js b/min/locales/ja.min.js similarity index 67% rename from min/languages/ja.min.js rename to min/locales/ja.min.js index 908b028c..a30c0cf3 100644 --- a/min/languages/ja.min.js +++ b/min/locales/ja.min.js @@ -1,6 +1,6 @@ /*! @preserve - * numeral.js language configuration - * language : japanese + * numeral.js locale configuration + * locale : japanese * author : teppeis : https://github.com/teppeis */ -!function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){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 +!function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("ja",a)}(); \ No newline at end of file diff --git a/min/languages/lv.min.js b/min/locales/lv.min.js similarity index 78% rename from min/languages/lv.min.js rename to min/locales/lv.min.js index 31237ccd..9b986e48 100644 --- a/min/languages/lv.min.js +++ b/min/locales/lv.min.js @@ -1,6 +1,6 @@ /*! @preserve - * numeral.js language configuration - * language : Latvian (lv) + * numeral.js locale configuration + * locale : Latvian (lv) * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks */ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("lv",a)}(); \ No newline at end of file +!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("lv",a)}(); \ No newline at end of file diff --git a/min/languages/nl-nl.min.js b/min/locales/nl-nl.min.js similarity index 71% rename from min/languages/nl-nl.min.js rename to min/locales/nl-nl.min.js index ed20694f..d5a17aeb 100644 --- a/min/languages/nl-nl.min.js +++ b/min/locales/nl-nl.min.js @@ -1,6 +1,6 @@ /*! @preserve - * numeral.js language configuration - * language : netherlands-dutch (nl-nl) + * numeral.js locale configuration + * locale : 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 +!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.locale&&this.numeral.locale("nl-nl",a)}(); \ No newline at end of file diff --git a/min/languages/no.min.js b/min/locales/no.min.js similarity index 52% rename from min/languages/no.min.js rename to min/locales/no.min.js index 71c8277a..73b752f2 100644 --- a/min/languages/no.min.js +++ b/min/locales/no.min.js @@ -1,6 +1,6 @@ /*! - * numeral.js language configuration - * language : norwegian (bokmål) + * numeral.js locale configuration + * locale : norwegian (bokmål) * author : Ove Andersen : https://github.com/azzlack */ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&(this.numeral.language("nb-no",a),this.numeral.language("nn-no",a),this.numeral.language("no",a),this.numeral.language("nb",a),this.numeral.language("nn",a))}(); \ No newline at end of file +!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&(this.numeral.locale("nb-no",a),this.numeral.locale("nn-no",a),this.numeral.locale("no",a),this.numeral.locale("nb",a),this.numeral.locale("nn",a))}(); \ No newline at end of file diff --git a/min/languages/pl.min.js b/min/locales/pl.min.js similarity index 68% rename from min/languages/pl.min.js rename to min/locales/pl.min.js index 7faaa0d1..3368afbf 100644 --- a/min/languages/pl.min.js +++ b/min/locales/pl.min.js @@ -1,6 +1,6 @@ /*! @preserve - * numeral.js language configuration - * language : polish (pl) + * numeral.js locale configuration + * locale : 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(a){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 +!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pl",a)}(); \ No newline at end of file diff --git a/min/languages/pt-br.min.js b/min/locales/pt-br.min.js similarity index 65% rename from min/languages/pt-br.min.js rename to min/locales/pt-br.min.js index 67835eb8..3f7ff464 100644 --- a/min/languages/pt-br.min.js +++ b/min/locales/pt-br.min.js @@ -1,6 +1,6 @@ /*! @preserve - * numeral.js language configuration - * language : portuguese brazil (pt-br) + * numeral.js locale configuration + * locale : 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(a){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 +!function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mil",million:"milhões",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"R$"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pt-br",a)}(); \ No newline at end of file diff --git a/min/languages/pt-pt.min.js b/min/locales/pt-pt.min.js similarity index 67% rename from min/languages/pt-pt.min.js rename to min/locales/pt-pt.min.js index c85431f1..05f12a97 100644 --- a/min/languages/pt-pt.min.js +++ b/min/locales/pt-pt.min.js @@ -1,6 +1,6 @@ /*! @preserve - * numeral.js language configuration - * language : portuguese (pt-pt) + * numeral.js locale configuration + * locale : 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(a){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 +!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pt-pt",a)}(); \ No newline at end of file diff --git a/min/languages/ru-UA.min.js b/min/locales/ru-UA.min.js similarity index 72% rename from min/languages/ru-UA.min.js rename to min/locales/ru-UA.min.js index 9b4f23fc..a5cfc11c 100644 --- a/min/languages/ru-UA.min.js +++ b/min/locales/ru-UA.min.js @@ -1 +1 @@ -!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 +!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.locale&&this.numeral.locale("ru-UA",a)}(); \ No newline at end of file diff --git a/min/languages/ru.min.js b/min/locales/ru.min.js similarity index 77% rename from min/languages/ru.min.js rename to min/locales/ru.min.js index f07551a3..efe028c5 100644 --- a/min/languages/ru.min.js +++ b/min/locales/ru.min.js @@ -1,6 +1,6 @@ /*! @preserve - * numeral.js language configuration - * language : russian (ru) + * numeral.js locale configuration + * locale : russian (ru) * author : Anatoli Papirovski : https://github.com/apapirovski */ -!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("ru",a)}(); \ No newline at end of file +!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.locale&&this.numeral.locale("ru",a)}(); \ No newline at end of file diff --git a/min/languages/sk.min.js b/min/locales/sk.min.js similarity index 68% rename from min/languages/sk.min.js rename to min/locales/sk.min.js index 6b75a44e..179c2da2 100644 --- a/min/languages/sk.min.js +++ b/min/locales/sk.min.js @@ -1,6 +1,6 @@ /*! @preserve - * numeral.js language configuration - * language : slovak (sk) + * numeral.js locale configuration + * locale : 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 +!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.locale&&this.numeral.locale("sk",a)}(); \ No newline at end of file diff --git a/min/languages/th.min.js b/min/locales/th.min.js similarity index 73% rename from min/languages/th.min.js rename to min/locales/th.min.js index cbd6ce5c..7ec860e6 100644 --- a/min/languages/th.min.js +++ b/min/locales/th.min.js @@ -1,6 +1,6 @@ /*! @preserve - * numeral.js language configuration - * language : thai (th) + * numeral.js locale configuration + * locale : thai (th) * author : Sathit Jittanupat : https://github.com/jojosati */ -!function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){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 +!function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("th",a)}(); \ No newline at end of file diff --git a/min/languages/tr.min.js b/min/locales/tr.min.js similarity index 85% rename from min/languages/tr.min.js rename to min/locales/tr.min.js index 9d9e0cbc..5396fee5 100644 --- a/min/languages/tr.min.js +++ b/min/locales/tr.min.js @@ -1,6 +1,6 @@ /*! @preserve - * numeral.js language configuration - * language : turkish (tr) + * 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(){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 +!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.locale&&this.numeral.locale("tr",b)}(); \ No newline at end of file diff --git a/min/languages/uk-UA.min.js b/min/locales/uk-UA.min.js similarity index 87% rename from min/languages/uk-UA.min.js rename to min/locales/uk-UA.min.js index 958ebf71..3de87f79 100644 --- a/min/languages/uk-UA.min.js +++ b/min/locales/uk-UA.min.js @@ -1 +1 @@ -!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 +!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.locale&&this.numeral.locale("uk-UA",a)}(); \ No newline at end of file diff --git a/min/numeral.min.js b/min/numeral.min.js index d5e00efd..5bdbd5f9 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * 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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var j;return j=0===a._value&&null!==s.zeroFormat?s.zeroFormat:null===a._value&&null!==s.nullFormat?s.nullFormat:b.indexOf("$")>-1?d(a,b,c):b.indexOf("%")>-1?e(a,b,c):b.indexOf(":")>-1?h(a,b):b.indexOf("b")>-1||b.indexOf("ib")>-1?f(a,b,c):b.indexOf("o")>-1?g(a,b,c):i(a._value,b,c)}function d(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),1>=f?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,q[s.currentLanguage].currency.symbol+j),e=e.join("")):e=q[s.currentLanguage].currency.symbol+j+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,j+q[s.currentLanguage].currency.symbol),e=e.join("")):e=e+j+q[s.currentLanguage].currency.symbol,e}function e(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 f(a,b,c){var d,e,f,g,h=b.indexOf("ib")>-1?t.iec:t.bytes,j=a._value,k="";for(b.indexOf(" b")>-1||b.indexOf(" ib")>-1?(k=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.length;e++)if(f=Math.pow(1024,e),g=Math.pow(1024,e+1),null===j||0===j||j>=f&&g>j){k+=h[e],f>0&&(j/=f);break}return d=i(j,b,c),d+k}function g(a,b,c){var d,e="";return b.indexOf(" o")>-1?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=q[s.currentLanguage].ordinal(a._value),d=i(a._value,b,c),d+e}function h(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 i(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,r=!1,t="",u=!1;return null===a&&(a=0),e=Math.abs(a),c.indexOf("(")>-1?(i=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(j=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(m=c.indexOf("aK")>=0,n=c.indexOf("aM")>=0,o=c.indexOf("aB")>=0,p=c.indexOf("aT")>=0,r=m||n||o||p,c.indexOf(" a")>-1&&(l=" "),c=c.replace(new RegExp(l+"a[KMBT]?"),""),e>=Math.pow(10,12)&&!r||p?(l+=q[s.currentLanguage].abbreviations.trillion,a/=Math.pow(10,12)):e=Math.pow(10,9)&&!r||o?(l+=q[s.currentLanguage].abbreviations.billion,a/=Math.pow(10,9)):e=Math.pow(10,6)&&!r||n?(l+=q[s.currentLanguage].abbreviations.million,a/=Math.pow(10,6)):(e=Math.pow(10,3)&&!r||m)&&(l+=q[s.currentLanguage].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("[.]")>-1&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.indexOf("[")>-1?(g=g.replace("]",""),g=g.split("["),t=b(a,g[0].length+g[1].length,d,g[1].length)):t=b(a,g.length,d),f=t.split(".")[0],t=t.indexOf(".")>-1?q[s.currentLanguage].delimiters.decimal+t.split(".")[1]:"",k&&0===Number(t.slice(1))&&(t="")):f=b(a,null,d),f.indexOf("-")>-1&&(f=f.slice(1),u=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+q[s.currentLanguage].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&u?"(":"")+(!i&&u?"-":"")+(!u&&j?"+":"")+f+t+(l?l:"")+(i&&u?")":"")}function j(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.indexOf(":")>-1)h=k(b);else if(b===s.zeroFormat||b===s.nullFormat)h=0;else{for("."!==q[s.currentLanguage].delimiters.decimal&&(b=b.replace(/\./g,"").replace(q[s.currentLanguage].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+q[s.currentLanguage].abbreviations.thousand+"(?:\\)|(\\"+q[s.currentLanguage].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+q[s.currentLanguage].abbreviations.million+"(?:\\)|(\\"+q[s.currentLanguage].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+q[s.currentLanguage].abbreviations.billion+"(?:\\)|(\\"+q[s.currentLanguage].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+q[s.currentLanguage].abbreviations.trillion+"(?:\\)|(\\"+q[s.currentLanguage].currency.symbol+")?(?:\\))?)?$"),g=1;g<=t.bytes.length&&!(j=b.indexOf(t.bytes[g])>-1||b.indexOf(t.iec[g])>-1?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.indexOf("%")>-1?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function k(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 l(a,b){q[a]=b}function m(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function n(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=m(a),d=m(b);return c>d?c:d},-(1/0))}var o,p="1.5.5",q={},r={currentLanguage:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},s={currentLanguage:r.currentLanguage,zeroFormat:r.zeroFormat,nullFormat:r.nullFormat,defaultFormat:r.defaultFormat},t={bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"],iec:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]};o=function(b){return b=o.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b?null:Number(b)?Number(b):o.fn.unformat(b),new a(b)},o.version=p,o.isNumeral=function(b){return b instanceof a},o.language=function(a,b){if(!a)return s.currentLanguage;if(a=a.toLowerCase(),a&&!b){if(!q[a])throw new Error("Unknown language : "+a);s.currentLanguage=a}return(b||!q[a])&&l(a,b),o},o.reset=function(){for(var a in r)s[a]=r[a]},o.languageData=function(a){if(!a)return q[s.currentLanguage];if(!q[a])throw new Error("Unknown language : "+a);return q[a]},o.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:"$"}}),o.zeroFormat=function(a){s.zeroFormat="string"==typeof a?a:null},o.nullFormat=function(a){s.nullFormat="string"==typeof a?a:null},o.defaultFormat=function(a){s.defaultFormat="string"==typeof a?a:"0.0"},o.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=o.languageData(b)}catch(k){i=o.languageData(o.language())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),o.fn=a.prototype={clone:function(){return o(this)},format:function(a,b){return c(this,a?a:s.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:j(this,a?a:s.defaultFormat)},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,d,e){return a+c*b}var c=n.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-c*b}var c=n.call(null,this._value,a);return this._value=[a].reduce(b,this._value*c)/c,this},multiply:function(a){function b(a,b,c,d){var e=n(a,b);return a*e*(b*e)/(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=n(a,b);return a*e/(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(o(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=o),"undefined"==typeof ender&&(this.numeral=o),"function"==typeof define&&define.amd&&define([],function(){return o})}).call(this); \ No newline at end of file +(function(){function a(a){this._value=a}function b(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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var j;return j=0===a._value&&null!==s.zeroFormat?s.zeroFormat:null===a._value&&null!==s.nullFormat?s.nullFormat:b.indexOf("$")>-1?d(a,b,c):b.indexOf("%")>-1?e(a,b,c):b.indexOf(":")>-1?h(a,b):b.indexOf("b")>-1||b.indexOf("ib")>-1?f(a,b,c):b.indexOf("o")>-1?g(a,b,c):i(a._value,b,c)}function d(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),1>=f?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,q[s.currentLocale].currency.symbol+j),e=e.join("")):e=q[s.currentLocale].currency.symbol+j+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,j+q[s.currentLocale].currency.symbol),e=e.join("")):e=e+j+q[s.currentLocale].currency.symbol,e}function e(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 f(a,b,c){var d,e,f,g,h=b.indexOf("ib")>-1?t.bytes.binary:t.bytes.decimal,j=a._value,k="";for(b.indexOf(" b")>-1||b.indexOf(" ib")>-1?(k=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===j||0===j||j>=f&&g>j){k+=h.suffixes[e],f>0&&(j/=f);break}return d=i(j,b,c),d+k}function g(a,b,c){var d,e="";return b.indexOf(" o")>-1?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=q[s.currentLocale].ordinal(a._value),d=i(a._value,b,c),d+e}function h(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 i(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,r=!1,t="",u=!1;return null===a&&(a=0),e=Math.abs(a),c.indexOf("(")>-1?(i=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(j=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(m=c.indexOf("aK")>=0,n=c.indexOf("aM")>=0,o=c.indexOf("aB")>=0,p=c.indexOf("aT")>=0,r=m||n||o||p,c.indexOf(" a")>-1&&(l=" "),c=c.replace(new RegExp(l+"a[KMBT]?"),""),e>=Math.pow(10,12)&&!r||p?(l+=q[s.currentLocale].abbreviations.trillion,a/=Math.pow(10,12)):e=Math.pow(10,9)&&!r||o?(l+=q[s.currentLocale].abbreviations.billion,a/=Math.pow(10,9)):e=Math.pow(10,6)&&!r||n?(l+=q[s.currentLocale].abbreviations.million,a/=Math.pow(10,6)):(e=Math.pow(10,3)&&!r||m)&&(l+=q[s.currentLocale].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("[.]")>-1&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.indexOf("[")>-1?(g=g.replace("]",""),g=g.split("["),t=b(a,g[0].length+g[1].length,d,g[1].length)):t=b(a,g.length,d),f=t.split(".")[0],t=t.indexOf(".")>-1?q[s.currentLocale].delimiters.decimal+t.split(".")[1]:"",k&&0===Number(t.slice(1))&&(t="")):f=b(a,null,d),f.indexOf("-")>-1&&(f=f.slice(1),u=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+q[s.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&u?"(":"")+(!i&&u?"-":"")+(!u&&j?"+":"")+f+t+(l?l:"")+(i&&u?")":"")}function j(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.indexOf(":")>-1)h=k(b);else if(b===s.zeroFormat||b===s.nullFormat)h=0;else{for("."!==q[s.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(q[s.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.million+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.billion+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=t.bytes.decimal.suffixes.length&&!(j=b.indexOf(t.bytes.decimal.suffixes[g])>-1||b.indexOf(t.bytes.binary.suffixes[g])>-1?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.indexOf("%")>-1?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function k(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 l(a,b){q[a]=b}function m(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function n(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=m(a),d=m(b);return c>d?c:d},-(1/0))}var o,p="1.5.6",q={},r={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},s={currentLocale:r.currentLocale,zeroFormat:r.zeroFormat,nullFormat:r.nullFormat,defaultFormat:r.defaultFormat},t={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};o=function(b){return b=o.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):o.fn.unformat(b),new a(b)},o.version=p,o.isNumeral=function(b){return b instanceof a},o.locale=function(a,b){if(!a)return s.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!q[a])throw new Error("Unknown locale : "+a);s.currentLocale=a}return(b||!q[a])&&l(a,b),o},o.reset=function(){for(var a in r)s[a]=r[a]},o.localeData=function(a){if(!a)return q[s.currentLocale];if(!q[a])throw new Error("Unknown locale : "+a);return q[a]},o.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:"$"}}),o.zeroFormat=function(a){s.zeroFormat="string"==typeof a?a:null},o.nullFormat=function(a){s.nullFormat="string"==typeof a?a:null},o.defaultFormat=function(a){s.defaultFormat="string"==typeof a?a:"0.0"},o.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=o.localeData(b)}catch(k){i=o.localeData(o.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),o.fn=a.prototype={clone:function(){return o(this)},format:function(a,b){return c(this,a?a:s.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:j(this,a?a:s.defaultFormat)},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,d,e){return a+c*b}var c=n.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-c*b}var c=n.call(null,this._value,a);return this._value=[a].reduce(b,this._value*c)/c,this},multiply:function(a){function b(a,b,c,d){var e=n(a,b);return a*e*(b*e)/(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=n(a,b);return a*e/(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(o(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=o),"undefined"==typeof ender&&(this.numeral=o),"function"==typeof define&&define.amd&&define([],function(){return o})}).call(this); \ No newline at end of file diff --git a/numeral.js b/numeral.js index 5e69f4b3..98184f7d 100644 --- a/numeral.js +++ b/numeral.js @@ -14,16 +14,16 @@ var numeral, VERSION = '1.5.6', - // internal storage for language config files - languages = {}, + // internal storage for locale config files + locales = {}, defaults = { - currentLanguage: 'en', + currentLocale: 'en', zeroFormat: null, nullFormat: null, defaultFormat: '0,0' }, options = { - currentLanguage: defaults.currentLanguage, + currentLocale: defaults.currentLocale, zeroFormat: defaults.zeroFormat, nullFormat: defaults.nullFormat, defaultFormat: defaults.defaultFormat @@ -150,18 +150,18 @@ // the symbol appears before the "(" or "-" spliceIndex = 0; } - output.splice(spliceIndex, 0, languages[options.currentLanguage].currency.symbol + space); + output.splice(spliceIndex, 0, locales[options.currentLocale].currency.symbol + space); output = output.join(''); } else { - output = languages[options.currentLanguage].currency.symbol + space + output; + output = locales[options.currentLocale].currency.symbol + space + output; } } else { if (output.indexOf(')') > -1) { output = output.split(''); - output.splice(-1, 0, space + languages[options.currentLanguage].currency.symbol); + output.splice(-1, 0, space + locales[options.currentLocale].currency.symbol); output = output.join(''); } else { - output = output + space + languages[options.currentLanguage].currency.symbol; + output = output + space + locales[options.currentLocale].currency.symbol; } } @@ -243,7 +243,7 @@ format = format.replace('o', ''); } - ordinal += languages[options.currentLanguage].ordinal(n._value); + ordinal += locales[options.currentLocale].ordinal(n._value); output = formatNumber(n._value, format, roundingFunction); @@ -312,19 +312,19 @@ if (abs >= Math.pow(10, 12) && !abbrForce || abbrT) { // trillion - abbr = abbr + languages[options.currentLanguage].abbreviations.trillion; + abbr = abbr + locales[options.currentLocale].abbreviations.trillion; value = value / Math.pow(10, 12); } else if (abs < Math.pow(10, 12) && abs >= Math.pow(10, 9) && !abbrForce || abbrB) { // billion - abbr = abbr + languages[options.currentLanguage].abbreviations.billion; + abbr = abbr + locales[options.currentLocale].abbreviations.billion; value = value / Math.pow(10, 9); } else if (abs < Math.pow(10, 9) && abs >= Math.pow(10, 6) && !abbrForce || abbrM) { // million - abbr = abbr + languages[options.currentLanguage].abbreviations.million; + abbr = abbr + locales[options.currentLocale].abbreviations.million; value = value / Math.pow(10, 6); } else if (abs < Math.pow(10, 6) && abs >= Math.pow(10, 3) && !abbrForce || abbrK) { // thousand - abbr = abbr + languages[options.currentLanguage].abbreviations.thousand; + abbr = abbr + locales[options.currentLocale].abbreviations.thousand; value = value / Math.pow(10, 3); } } @@ -351,7 +351,7 @@ w = d.split('.')[0]; if (d.indexOf('.') > -1) { - d = languages[options.currentLanguage].delimiters.decimal + d.split('.')[1]; + d = locales[options.currentLocale].delimiters.decimal + d.split('.')[1]; } else { d = ''; } @@ -370,7 +370,7 @@ } if (thousands > -1) { - w = w.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + languages[options.currentLanguage].delimiters.thousands); + w = w.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + locales[options.currentLocale].delimiters.thousands); } if (format.indexOf('.') === 0) { @@ -402,15 +402,15 @@ if (string === options.zeroFormat || string === options.nullFormat) { value = 0; } else { - if (languages[options.currentLanguage].delimiters.decimal !== '.') { - string = string.replace(/\./g, '').replace(languages[options.currentLanguage].delimiters.decimal, '.'); + if (locales[options.currentLocale].delimiters.decimal !== '.') { + string = string.replace(/\./g, '').replace(locales[options.currentLocale].delimiters.decimal, '.'); } // see if abbreviations are there so that we can multiply to the correct number - thousandRegExp = new RegExp('[^a-zA-Z]' + languages[options.currentLanguage].abbreviations.thousand + '(?:\\)|(\\' + languages[options.currentLanguage].currency.symbol + ')?(?:\\))?)?$'); - millionRegExp = new RegExp('[^a-zA-Z]' + languages[options.currentLanguage].abbreviations.million + '(?:\\)|(\\' + languages[options.currentLanguage].currency.symbol + ')?(?:\\))?)?$'); - billionRegExp = new RegExp('[^a-zA-Z]' + languages[options.currentLanguage].abbreviations.billion + '(?:\\)|(\\' + languages[options.currentLanguage].currency.symbol + ')?(?:\\))?)?$'); - trillionRegExp = new RegExp('[^a-zA-Z]' + languages[options.currentLanguage].abbreviations.trillion + '(?:\\)|(\\' + languages[options.currentLanguage].currency.symbol + ')?(?:\\))?)?$'); + thousandRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.thousand + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); + millionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.million + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); + billionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.billion + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); + trillionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.trillion + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); // see if bytes are there so that we can multiply to the correct number for (power = 1; power <= config.bytes.decimal.suffixes.length; power++) { @@ -492,26 +492,26 @@ }; - // This function will load languages and then set the global language. If + // This function will load locales and then set the global locale. If // no arguments are passed in, it will simply return the current global - // language key. - numeral.language = function(key, values) { + // locale key. + numeral.locale = function(key, values) { if (!key) { - return options.currentLanguage; + return options.currentLocale; } key = key.toLowerCase(); if (key && !values) { - if (!languages[key]) { - throw new Error('Unknown language : ' + key); + if (!locales[key]) { + throw new Error('Unknown locale : ' + key); } - options.currentLanguage = key; + options.currentLocale = key; } - if (values || !languages[key]) { - loadLanguage(key, values); + if (values || !locales[key]) { + loadLocale(key, values); } return numeral; @@ -523,22 +523,22 @@ } }; - // This function provides access to the loaded language data. If + // This function provides access to the loaded locale data. If // no arguments are passed in, it will simply return the current - // global language object. - numeral.languageData = function(key) { + // global locale object. + numeral.localeData = function(key) { if (!key) { - return languages[options.currentLanguage]; + return locales[options.currentLocale]; } - if (!languages[key]) { - throw new Error('Unknown language : ' + key); + if (!locales[key]) { + throw new Error('Unknown locale : ' + key); } - return languages[key]; + return locales[key]; }; - numeral.language('en', { + numeral.locale('en', { delimiters: { thousands: ',', decimal: '.' @@ -580,7 +580,7 @@ _valArray, _abbrObj, _thousandRegEx, - languageData, + localeData, temp; //coerce val to string @@ -604,22 +604,22 @@ return false; } - //get the decimal and thousands separator from numeral.languageData + //get the decimal and thousands separator from numeral.localeData try { - //check if the culture is understood by numeral. if not, default it to current language - languageData = numeral.languageData(culture); + //check if the culture is understood by numeral. if not, default it to current locale + localeData = numeral.localeData(culture); } catch (e) { - languageData = numeral.languageData(numeral.language()); + localeData = numeral.localeData(numeral.locale()); } - //setup the delimiters and currency symbol based on culture/language - _currSymbol = languageData.currency.symbol; - _abbrObj = languageData.abbreviations; - _decimalSep = languageData.delimiters.decimal; - if (languageData.delimiters.thousands === '.') { + //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 = languageData.delimiters.thousands; + _thousandSep = localeData.delimiters.thousands; } // validating currency symbol @@ -666,8 +666,8 @@ Helpers ************************************/ - function loadLanguage(key, values) { - languages[key] = values; + function loadLocale(key, values) { + locales[key] = values; } /************************************ diff --git a/tests/languages/be-nl.js b/tests/locales/be-nl.js similarity index 94% rename from tests/languages/be-nl.js rename to tests/locales/be-nl.js index e9816eee..6be7485e 100644 --- a/tests/languages/be-nl.js +++ b/tests/locales/be-nl.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/be-nl'); + var locale = require('../../locales/be-nl'); } -describe('Language: be-nl', function() { +describe('Locale: be-nl', function() { before(function() { - numeral.language('be-nl', language); + numeral.locale('be-nl', locale); - numeral.language('be-nl'); + numeral.locale('be-nl'); }); after(function() { diff --git a/tests/languages/chs.js b/tests/locales/chs.js similarity index 94% rename from tests/languages/chs.js rename to tests/locales/chs.js index e5b50ff2..30787d37 100644 --- a/tests/languages/chs.js +++ b/tests/locales/chs.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/chs'); + var locale = require('../../locales/chs'); } -describe('Language: chs', function() { +describe('Locale: chs', function() { before(function() { - numeral.language('chs', language); + numeral.locale('chs', locale); - numeral.language('chs'); + numeral.locale('chs'); }); after(function() { diff --git a/tests/languages/cs.js b/tests/locales/cs.js similarity index 94% rename from tests/languages/cs.js rename to tests/locales/cs.js index af797538..cbff3ef8 100644 --- a/tests/languages/cs.js +++ b/tests/locales/cs.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/cs'); + var locale = require('../../locales/cs'); } -describe('Language: cs', function() { +describe('Locale: cs', function() { before(function() { - numeral.language('cs', language); + numeral.locale('cs', locale); - numeral.language('cs'); + numeral.locale('cs'); }); after(function() { diff --git a/tests/languages/da-dk.js b/tests/locales/da-dk.js similarity index 94% rename from tests/languages/da-dk.js rename to tests/locales/da-dk.js index 17f5798f..c8ed7fff 100644 --- a/tests/languages/da-dk.js +++ b/tests/locales/da-dk.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/da-dk'); + var locale = require('../../locales/da-dk'); } -describe('Language: da-dk', function() { +describe('Locale: da-dk', function() { before(function() { - numeral.language('da-dk', language); + numeral.locale('da-dk', locale); - numeral.language('da-dk'); + numeral.locale('da-dk'); }); after(function() { diff --git a/tests/languages/de-ch.js b/tests/locales/de-ch.js similarity index 94% rename from tests/languages/de-ch.js rename to tests/locales/de-ch.js index 9cae4b1d..af86325f 100644 --- a/tests/languages/de-ch.js +++ b/tests/locales/de-ch.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/de-ch'); + var locale = require('../../locales/de-ch'); } -describe('Language: de-ch', function() { +describe('Locale: de-ch', function() { before(function() { - numeral.language('de-ch', language); + numeral.locale('de-ch', locale); - numeral.language('de-ch'); + numeral.locale('de-ch'); }); after(function() { diff --git a/tests/languages/de.js b/tests/locales/de.js similarity index 94% rename from tests/languages/de.js rename to tests/locales/de.js index 8daae61a..047c553e 100644 --- a/tests/languages/de.js +++ b/tests/locales/de.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/de'); + var locale = require('../../locales/de'); } -describe('Language: de', function() { +describe('Locale: de', function() { before(function() { - numeral.language('de', language); + numeral.locale('de', locale); - numeral.language('de'); + numeral.locale('de'); }); after(function() { diff --git a/tests/languages/en-gb.js b/tests/locales/en-gb.js similarity index 94% rename from tests/languages/en-gb.js rename to tests/locales/en-gb.js index cd4d05f7..4bbc7221 100644 --- a/tests/languages/en-gb.js +++ b/tests/locales/en-gb.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/en-gb'); + var locale = require('../../locales/en-gb'); } -describe('Language: en-gb', function() { +describe('Locale: en-gb', function() { before(function() { - numeral.language('en-gb', language); + numeral.locale('en-gb', locale); - numeral.language('en-gb'); + numeral.locale('en-gb'); }); after(function() { diff --git a/tests/languages/en-za.js b/tests/locales/en-za.js similarity index 94% rename from tests/languages/en-za.js rename to tests/locales/en-za.js index 93baadf4..065304fc 100644 --- a/tests/languages/en-za.js +++ b/tests/locales/en-za.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/en-za'); + var locale = require('../../locales/en-za'); } -describe('Language: en-za', function() { +describe('Locale: en-za', function() { before(function() { - numeral.language('en-za', language); + numeral.locale('en-za', locale); - numeral.language('en-za'); + numeral.locale('en-za'); }); after(function() { diff --git a/tests/languages/en.js b/tests/locales/en.js similarity index 98% rename from tests/languages/en.js rename to tests/locales/en.js index 97e76650..287ae541 100644 --- a/tests/languages/en.js +++ b/tests/locales/en.js @@ -4,7 +4,7 @@ if (typeof module !== 'undefined' && module.exports) { var expect = require('chai').expect; } -describe('Language: en', function() { +describe('Locale: en', function() { describe('Number', function() { it('should format a number', function() { diff --git a/tests/languages/es-ES.js b/tests/locales/es-ES.js similarity index 94% rename from tests/languages/es-ES.js rename to tests/locales/es-ES.js index 08311618..8894def9 100644 --- a/tests/languages/es-ES.js +++ b/tests/locales/es-ES.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/es-ES'); + var locale = require('../../locales/es-ES'); } -describe('Language: es-ES', function() { +describe('Locale: es-ES', function() { before(function() { - numeral.language('es-ES', language); + numeral.locale('es-ES', locale); - numeral.language('es-ES'); + numeral.locale('es-ES'); }); after(function() { diff --git a/tests/languages/es.js b/tests/locales/es.js similarity index 94% rename from tests/languages/es.js rename to tests/locales/es.js index 04a2b271..1c27512d 100644 --- a/tests/languages/es.js +++ b/tests/locales/es.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/es'); + var locale = require('../../locales/es'); } -describe('Language: es', function() { +describe('Locale: es', function() { before(function() { - numeral.language('es', language); + numeral.locale('es', locale); - numeral.language('es'); + numeral.locale('es'); }); after(function() { diff --git a/tests/languages/et.js b/tests/locales/et.js similarity index 94% rename from tests/languages/et.js rename to tests/locales/et.js index 3ec74a4c..4b1b575a 100644 --- a/tests/languages/et.js +++ b/tests/locales/et.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/et'); + var locale = require('../../locales/et'); } -describe('Language: et', function() { +describe('Locale: et', function() { before(function() { - numeral.language('et', language); + numeral.locale('et', locale); - numeral.language('et'); + numeral.locale('et'); }); after(function() { diff --git a/tests/languages/fi.js b/tests/locales/fi.js similarity index 94% rename from tests/languages/fi.js rename to tests/locales/fi.js index dfd22a1d..e934cdd0 100644 --- a/tests/languages/fi.js +++ b/tests/locales/fi.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/fi'); + var locale = require('../../locales/fi'); } -describe('Language: fi', function() { +describe('Locale: fi', function() { before(function() { - numeral.language('fi', language); + numeral.locale('fi', locale); - numeral.language('fi'); + numeral.locale('fi'); }); after(function() { diff --git a/tests/languages/fr-CA.js b/tests/locales/fr-CA.js similarity index 94% rename from tests/languages/fr-CA.js rename to tests/locales/fr-CA.js index 24da89c5..e98910c0 100644 --- a/tests/languages/fr-CA.js +++ b/tests/locales/fr-CA.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/fr-CA'); + var locale = require('../../locales/fr-CA'); } -describe('Language: fr-CA', function() { +describe('Locale: fr-CA', function() { before(function() { - numeral.language('fr-CA', language); + numeral.locale('fr-CA', locale); - numeral.language('fr-CA'); + numeral.locale('fr-CA'); }); after(function() { diff --git a/tests/languages/fr-ch.js b/tests/locales/fr-ch.js similarity index 94% rename from tests/languages/fr-ch.js rename to tests/locales/fr-ch.js index aeb96800..57230ba5 100644 --- a/tests/languages/fr-ch.js +++ b/tests/locales/fr-ch.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/fr-ch'); + var locale = require('../../locales/fr-ch'); } -describe('Language: fr-ch', function() { +describe('Locale: fr-ch', function() { before(function() { - numeral.language('fr-ch', language); + numeral.locale('fr-ch', locale); - numeral.language('fr-ch'); + numeral.locale('fr-ch'); }); after(function() { diff --git a/tests/languages/fr.js b/tests/locales/fr.js similarity index 94% rename from tests/languages/fr.js rename to tests/locales/fr.js index b03627eb..73564648 100644 --- a/tests/languages/fr.js +++ b/tests/locales/fr.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/fr'); + var locale = require('../../locales/fr'); } -describe('Language: fr', function() { +describe('Locale: fr', function() { before(function() { - numeral.language('fr', language); + numeral.locale('fr', locale); - numeral.language('fr'); + numeral.locale('fr'); }); after(function() { diff --git a/tests/languages/hu.js b/tests/locales/hu.js similarity index 94% rename from tests/languages/hu.js rename to tests/locales/hu.js index 6a50ef8a..5525dae3 100644 --- a/tests/languages/hu.js +++ b/tests/locales/hu.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/hu'); + var locale = require('../../locales/hu'); } -describe('Language: hu', function() { +describe('Locale: hu', function() { before(function() { - numeral.language('hu', language); + numeral.locale('hu', locale); - numeral.language('hu'); + numeral.locale('hu'); }); after(function() { diff --git a/tests/languages/it.js b/tests/locales/it.js similarity index 94% rename from tests/languages/it.js rename to tests/locales/it.js index 7e7b3dc3..506d36ea 100644 --- a/tests/languages/it.js +++ b/tests/locales/it.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/it'); + var locale = require('../../locales/it'); } -describe('Language: it', function() { +describe('Locale: it', function() { before(function() { - numeral.language('it', language); + numeral.locale('it', locale); - numeral.language('it'); + numeral.locale('it'); }); after(function() { diff --git a/tests/languages/ja.js b/tests/locales/ja.js similarity index 94% rename from tests/languages/ja.js rename to tests/locales/ja.js index 26d89627..50c39ace 100644 --- a/tests/languages/ja.js +++ b/tests/locales/ja.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/ja'); + var locale = require('../../locales/ja'); } -describe('Language: ja', function() { +describe('Locale: ja', function() { before(function() { - numeral.language('ja', language); + numeral.locale('ja', locale); - numeral.language('ja'); + numeral.locale('ja'); }); after(function() { diff --git a/tests/languages/lv.js b/tests/locales/lv.js similarity index 94% rename from tests/languages/lv.js rename to tests/locales/lv.js index e6581d8c..44ff450f 100644 --- a/tests/languages/lv.js +++ b/tests/locales/lv.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/lv'); + var locale = require('../../locales/lv'); } -describe('Language: lv', function() { +describe('Locale: lv', function() { before(function() { - numeral.language('lv', language); + numeral.locale('lv', locale); - numeral.language('lv'); + numeral.locale('lv'); }); after(function() { diff --git a/tests/languages/nl-nl.js b/tests/locales/nl-nl.js similarity index 94% rename from tests/languages/nl-nl.js rename to tests/locales/nl-nl.js index 32c93085..a269365e 100644 --- a/tests/languages/nl-nl.js +++ b/tests/locales/nl-nl.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/nl-nl'); + var locale = require('../../locales/nl-nl'); } -describe('Language: nl-nl', function() { +describe('Locale: nl-nl', function() { before(function() { - numeral.language('nl-nl', language); + numeral.locale('nl-nl', locale); - numeral.language('nl-nl'); + numeral.locale('nl-nl'); }); after(function() { diff --git a/tests/languages/no.js b/tests/locales/no.js similarity index 94% rename from tests/languages/no.js rename to tests/locales/no.js index a77804eb..5714719d 100644 --- a/tests/languages/no.js +++ b/tests/locales/no.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/no'); + var locale = require('../../locales/no'); } -describe('Language: no', function() { +describe('Locale: no', function() { before(function() { - numeral.language('no', language); + numeral.locale('no', locale); - numeral.language('no'); + numeral.locale('no'); }); after(function() { diff --git a/tests/languages/pl.js b/tests/locales/pl.js similarity index 94% rename from tests/languages/pl.js rename to tests/locales/pl.js index a7c086bc..740a71f4 100644 --- a/tests/languages/pl.js +++ b/tests/locales/pl.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/pl'); + var locale = require('../../locales/pl'); } -describe('Language: pl', function() { +describe('Locale: pl', function() { before(function() { - numeral.language('pl', language); + numeral.locale('pl', locale); - numeral.language('pl'); + numeral.locale('pl'); }); after(function() { diff --git a/tests/languages/pt-br.js b/tests/locales/pt-br.js similarity index 94% rename from tests/languages/pt-br.js rename to tests/locales/pt-br.js index 99d95b15..3f137c2c 100644 --- a/tests/languages/pt-br.js +++ b/tests/locales/pt-br.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/pt-br'); + var locale = require('../../locales/pt-br'); } -describe('Language: pt-br', function() { +describe('Locale: pt-br', function() { before(function() { - numeral.language('pt-br', language); + numeral.locale('pt-br', locale); - numeral.language('pt-br'); + numeral.locale('pt-br'); }); after(function() { diff --git a/tests/languages/pt-pt.js b/tests/locales/pt-pt.js similarity index 94% rename from tests/languages/pt-pt.js rename to tests/locales/pt-pt.js index 7cf49103..cf241f06 100644 --- a/tests/languages/pt-pt.js +++ b/tests/locales/pt-pt.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/pt-pt'); + var locale = require('../../locales/pt-pt'); } -describe('Language: pt-pt', function() { +describe('Locale: pt-pt', function() { before(function() { - numeral.language('pt-pt', language); + numeral.locale('pt-pt', locale); - numeral.language('pt-pt'); + numeral.locale('pt-pt'); }); after(function() { diff --git a/tests/languages/ru-UA.js b/tests/locales/ru-UA.js similarity index 94% rename from tests/languages/ru-UA.js rename to tests/locales/ru-UA.js index f533cc48..abe40354 100644 --- a/tests/languages/ru-UA.js +++ b/tests/locales/ru-UA.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/ru-UA'); + var locale = require('../../locales/ru-UA'); } -describe('Language: ru-UA', function() { +describe('Locale: ru-UA', function() { before(function() { - numeral.language('ru-UA', language); + numeral.locale('ru-UA', locale); - numeral.language('ru-UA'); + numeral.locale('ru-UA'); }); after(function() { diff --git a/tests/languages/ru.js b/tests/locales/ru.js similarity index 94% rename from tests/languages/ru.js rename to tests/locales/ru.js index 52b00a69..d9b4d02f 100644 --- a/tests/languages/ru.js +++ b/tests/locales/ru.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/ru'); + var locale = require('../../locales/ru'); } -describe('Language: ru', function() { +describe('Locale: ru', function() { before(function() { - numeral.language('ru', language); + numeral.locale('ru', locale); - numeral.language('ru'); + numeral.locale('ru'); }); after(function() { diff --git a/tests/languages/sk.js b/tests/locales/sk.js similarity index 94% rename from tests/languages/sk.js rename to tests/locales/sk.js index 28a63713..76e2ff91 100644 --- a/tests/languages/sk.js +++ b/tests/locales/sk.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/sk'); + var locale = require('../../locales/sk'); } -describe('Language: sk', function() { +describe('Locale: sk', function() { before(function() { - numeral.language('sk', language); + numeral.locale('sk', locale); - numeral.language('sk'); + numeral.locale('sk'); }); after(function() { diff --git a/tests/languages/th.js b/tests/locales/th.js similarity index 94% rename from tests/languages/th.js rename to tests/locales/th.js index 31538981..e155df1b 100644 --- a/tests/languages/th.js +++ b/tests/locales/th.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/th'); + var locale = require('../../locales/th'); } -describe('Language: th', function() { +describe('Locale: th', function() { before(function() { - numeral.language('th', language); + numeral.locale('th', locale); - numeral.language('th'); + numeral.locale('th'); }); after(function() { diff --git a/tests/languages/tr.js b/tests/locales/tr.js similarity index 94% rename from tests/languages/tr.js rename to tests/locales/tr.js index 30dffe9a..5cbd0f0b 100644 --- a/tests/languages/tr.js +++ b/tests/locales/tr.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/tr'); + var locale = require('../../locales/tr'); } -describe('Language: tr', function() { +describe('Locale: tr', function() { before(function() { - numeral.language('tr', language); + numeral.locale('tr', locale); - numeral.language('tr'); + numeral.locale('tr'); }); after(function() { diff --git a/tests/languages/uk-UA.js b/tests/locales/uk-UA.js similarity index 94% rename from tests/languages/uk-UA.js rename to tests/locales/uk-UA.js index ed8ce934..103a2d07 100644 --- a/tests/languages/uk-UA.js +++ b/tests/locales/uk-UA.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/uk-UA'); + var locale = require('../../locales/uk-UA'); } -describe('Language: uk-UA', function() { +describe('Locale: uk-UA', function() { before(function() { - numeral.language('uk-UA', language); + numeral.locale('uk-UA', locale); - numeral.language('uk-UA'); + numeral.locale('uk-UA'); }); after(function() { diff --git a/tests/numeral/misc.js b/tests/numeral/misc.js index 56018836..dd766b5a 100644 --- a/tests/numeral/misc.js +++ b/tests/numeral/misc.js @@ -135,8 +135,8 @@ describe('Misc', function() { }); }); - describe('Language Data', function() { - it('should use custom language data', function() { + describe('Locale Data', function() { + it('should use custom locale data', function() { var cOld = '$', cNew = '!', formatTestVal = function() { @@ -145,23 +145,23 @@ describe('Misc', function() { oldCurrencyVal = cOld + '100', newCurrencyVal = cNew + '100'; - expect(numeral.languageData().currency.symbol).to.equal(cOld); - expect(numeral.languageData('en').currency.symbol).to.equal(cOld); + expect(numeral.localeData().currency.symbol).to.equal(cOld); + expect(numeral.localeData('en').currency.symbol).to.equal(cOld); - numeral.languageData().currency.symbol = cNew; - expect(numeral.languageData().currency.symbol).to.equal(cNew); + numeral.localeData().currency.symbol = cNew; + expect(numeral.localeData().currency.symbol).to.equal(cNew); expect(formatTestVal()).to.equal(newCurrencyVal); - numeral.languageData().currency.symbol = cOld; - expect(numeral.languageData().currency.symbol).to.equal('$'); + numeral.localeData().currency.symbol = cOld; + expect(numeral.localeData().currency.symbol).to.equal('$'); expect(formatTestVal()).to.equal(oldCurrencyVal); - numeral.languageData('en').currency.symbol = cNew; - expect(numeral.languageData().currency.symbol).to.equal(cNew); + numeral.localeData('en').currency.symbol = cNew; + expect(numeral.localeData().currency.symbol).to.equal(cNew); expect(formatTestVal()).to.equal(newCurrencyVal); - numeral.languageData('en').currency.symbol = cOld; - expect(numeral.languageData().currency.symbol).to.equal(cOld); + numeral.localeData('en').currency.symbol = cOld; + expect(numeral.localeData().currency.symbol).to.equal(cOld); expect(formatTestVal()).to.equal(oldCurrencyVal); }); }); diff --git a/tests/numeral/validate.js b/tests/numeral/validate.js index 9a16bb6d..61f3e144 100644 --- a/tests/numeral/validate.js +++ b/tests/numeral/validate.js @@ -5,7 +5,7 @@ if (typeof module !== 'undefined' && module.exports) { } describe('Validate', function() { - var language = 'en'; + var locale = 'en'; after(function() { numeral.reset(); @@ -36,7 +36,7 @@ describe('Validate', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral.validate(tests[i][0], language)).to.equal(tests[i][1]); + expect(numeral.validate(tests[i][0], locale)).to.equal(tests[i][1]); } }); }); @@ -73,7 +73,7 @@ describe('Validate', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral.validate(tests[i][0], language)).to.equal(tests[i][1]); + expect(numeral.validate(tests[i][0], locale)).to.equal(tests[i][1]); } }); }); From 6dcf5ec1635afbbafb40c7dc10765e56d2b5d17a Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 24 Nov 2016 23:09:53 -0800 Subject: [PATCH 066/150] lowercase all locales --- locales.js | 14 +++++++------- locales/es-ES.js | 2 +- locales/fr-CA.js | 4 ++-- locales/ru-UA.js | 4 ++-- locales/uk-UA.js | 4 ++-- min/locales.min.js | 10 +++++----- min/locales/es-ES.min.js | 2 +- min/locales/fr-CA.min.js | 4 ++-- min/locales/ru-UA.min.js | 2 +- min/locales/uk-UA.min.js | 2 +- tests/locales/es-ES.js | 8 ++++---- tests/locales/fr-CA.js | 8 ++++---- tests/locales/ru-UA.js | 8 ++++---- tests/locales/uk-UA.js | 8 ++++---- 14 files changed, 40 insertions(+), 40 deletions(-) diff --git a/locales.js b/locales.js index 5cec3e7b..753650eb 100644 --- a/locales.js +++ b/locales.js @@ -318,7 +318,7 @@ } // Browser if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('es-ES', locale); + this.numeral.locale('es-es', locale); } }()); @@ -437,7 +437,7 @@ /*! @preserve * numeral.js locale configuration - * locale : french (Canada) (fr-CA) + * locale : french (Canada) (fr-ca) * author : Léo Renaud-Allaire : https://github.com/renaudleo */ (function () { @@ -466,7 +466,7 @@ } // Browser if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('fr-CA', locale); + this.numeral.locale('fr-ca', locale); } }()); /*! @preserve @@ -852,7 +852,7 @@ }()); // numeral.js locale configuration -// locale : Russian for the Ukraine (ru-UA) +// locale : Russian for the Ukraine (ru-ua) // author : Anatoli Papirovski : https://github.com/apapirovski (function () { var locale = { @@ -883,7 +883,7 @@ } // Browser if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('ru-UA', locale); + this.numeral.locale('ru-ua', locale); } }()); @@ -1064,7 +1064,7 @@ }()); // numeral.js locale configuration -// locale : Ukrainian for the Ukraine (uk-UA) +// locale : Ukrainian for the Ukraine (uk-ua) // author : Michael Piefel : https://github.com/piefel (with help from Tetyana Kuzmenko) (function () { var locale = { @@ -1095,6 +1095,6 @@ } // Browser if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('uk-UA', locale); + this.numeral.locale('uk-ua', locale); } }()); diff --git a/locales/es-ES.js b/locales/es-ES.js index 50ad1a90..839c3dc0 100644 --- a/locales/es-ES.js +++ b/locales/es-ES.js @@ -34,6 +34,6 @@ } // Browser if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('es-ES', locale); + this.numeral.locale('es-es', locale); } }()); diff --git a/locales/fr-CA.js b/locales/fr-CA.js index 9b4ca436..5116dd52 100644 --- a/locales/fr-CA.js +++ b/locales/fr-CA.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js locale configuration - * locale : french (Canada) (fr-CA) + * locale : french (Canada) (fr-ca) * author : Léo Renaud-Allaire : https://github.com/renaudleo */ (function () { @@ -29,6 +29,6 @@ } // Browser if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('fr-CA', locale); + this.numeral.locale('fr-ca', locale); } }()); \ No newline at end of file diff --git a/locales/ru-UA.js b/locales/ru-UA.js index 5168a76f..93d4f386 100644 --- a/locales/ru-UA.js +++ b/locales/ru-UA.js @@ -1,5 +1,5 @@ // numeral.js locale configuration -// locale : Russian for the Ukraine (ru-UA) +// locale : Russian for the Ukraine (ru-ua) // author : Anatoli Papirovski : https://github.com/apapirovski (function () { var locale = { @@ -30,6 +30,6 @@ } // Browser if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('ru-UA', locale); + this.numeral.locale('ru-ua', locale); } }()); diff --git a/locales/uk-UA.js b/locales/uk-UA.js index 9bee3ddf..d1e8d042 100644 --- a/locales/uk-UA.js +++ b/locales/uk-UA.js @@ -1,5 +1,5 @@ // numeral.js locale configuration -// locale : Ukrainian for the Ukraine (uk-UA) +// locale : Ukrainian for the Ukraine (uk-ua) // author : Michael Piefel : https://github.com/piefel (with help from Tetyana Kuzmenko) (function () { var locale = { @@ -30,6 +30,6 @@ } // Browser if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('uk-UA', locale); + this.numeral.locale('uk-ua', locale); } }()); diff --git a/min/locales.min.js b/min/locales.min.js index 6e549e5e..c1f3c0f1 100644 --- a/min/locales.min.js +++ b/min/locales.min.js @@ -43,7 +43,7 @@ function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand * locale : 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.locale&&this.numeral.locale("es-ES",a)}(),/*! @preserve +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.locale&&this.numeral.locale("es-es",a)}(),/*! @preserve * numeral.js locale configuration * locale : spanish * author : Hernan Garcia : https://github.com/hgarcia @@ -63,10 +63,10 @@ function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand */ function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("fi",a)}(),/*! @preserve * numeral.js locale configuration - * locale : french (Canada) (fr-CA) + * locale : 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.locale&&this.numeral.locale("fr-CA",a)}(),/*! @preserve +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.locale&&this.numeral.locale("fr-ca",a)}(),/*! @preserve * numeral.js locale configuration * locale : french (fr-ch) * author : Adam Draper : https://github.com/adamwdraper @@ -121,7 +121,7 @@ function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand * locale : 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(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("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.locale&&this.numeral.locale("ru-UA",a)}(),/*! @preserve +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("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.locale&&this.numeral.locale("ru-ua",a)}(),/*! @preserve * numeral.js locale configuration * locale : russian (ru) * author : Anatoli Papirovski : https://github.com/apapirovski @@ -141,4 +141,4 @@ function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand * 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(){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.locale&&this.numeral.locale("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.locale&&this.numeral.locale("uk-UA",a)}(); \ No newline at end of file +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.locale&&this.numeral.locale("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.locale&&this.numeral.locale("uk-ua",a)}(); \ No newline at end of file diff --git a/min/locales/es-ES.min.js b/min/locales/es-ES.min.js index 3c0a9c85..67e0f971 100644 --- a/min/locales/es-ES.min.js +++ b/min/locales/es-ES.min.js @@ -3,4 +3,4 @@ * locale : 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.locale&&this.numeral.locale("es-ES",a)}(); \ No newline at end of file +!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.locale&&this.numeral.locale("es-es",a)}(); \ No newline at end of file diff --git a/min/locales/fr-CA.min.js b/min/locales/fr-CA.min.js index cf67c8dc..9e5326db 100644 --- a/min/locales/fr-CA.min.js +++ b/min/locales/fr-CA.min.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js locale configuration - * locale : french (Canada) (fr-CA) + * locale : 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.locale&&this.numeral.locale("fr-CA",a)}(); \ No newline at end of file +!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.locale&&this.numeral.locale("fr-ca",a)}(); \ No newline at end of file diff --git a/min/locales/ru-UA.min.js b/min/locales/ru-UA.min.js index a5cfc11c..daf31256 100644 --- a/min/locales/ru-UA.min.js +++ b/min/locales/ru-UA.min.js @@ -1 +1 @@ -!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.locale&&this.numeral.locale("ru-UA",a)}(); \ No newline at end of file +!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.locale&&this.numeral.locale("ru-ua",a)}(); \ No newline at end of file diff --git a/min/locales/uk-UA.min.js b/min/locales/uk-UA.min.js index 3de87f79..25f0b784 100644 --- a/min/locales/uk-UA.min.js +++ b/min/locales/uk-UA.min.js @@ -1 +1 @@ -!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.locale&&this.numeral.locale("uk-UA",a)}(); \ No newline at end of file +!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.locale&&this.numeral.locale("uk-ua",a)}(); \ No newline at end of file diff --git a/tests/locales/es-ES.js b/tests/locales/es-ES.js index 8894def9..a97f7651 100644 --- a/tests/locales/es-ES.js +++ b/tests/locales/es-ES.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var locale = require('../../locales/es-ES'); + var locale = require('../../locales/es-es'); } -describe('Locale: es-ES', function() { +describe('Locale: es-es', function() { before(function() { - numeral.locale('es-ES', locale); + numeral.locale('es-es', locale); - numeral.locale('es-ES'); + numeral.locale('es-es'); }); after(function() { diff --git a/tests/locales/fr-CA.js b/tests/locales/fr-CA.js index e98910c0..ba5dfc00 100644 --- a/tests/locales/fr-CA.js +++ b/tests/locales/fr-CA.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var locale = require('../../locales/fr-CA'); + var locale = require('../../locales/fr-ca'); } -describe('Locale: fr-CA', function() { +describe('Locale: fr-ca', function() { before(function() { - numeral.locale('fr-CA', locale); + numeral.locale('fr-ca', locale); - numeral.locale('fr-CA'); + numeral.locale('fr-ca'); }); after(function() { diff --git a/tests/locales/ru-UA.js b/tests/locales/ru-UA.js index abe40354..711ad919 100644 --- a/tests/locales/ru-UA.js +++ b/tests/locales/ru-UA.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var locale = require('../../locales/ru-UA'); + var locale = require('../../locales/ru-ua'); } -describe('Locale: ru-UA', function() { +describe('Locale: ru-ua', function() { before(function() { - numeral.locale('ru-UA', locale); + numeral.locale('ru-ua', locale); - numeral.locale('ru-UA'); + numeral.locale('ru-ua'); }); after(function() { diff --git a/tests/locales/uk-UA.js b/tests/locales/uk-UA.js index 103a2d07..1e5940fa 100644 --- a/tests/locales/uk-UA.js +++ b/tests/locales/uk-UA.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var locale = require('../../locales/uk-UA'); + var locale = require('../../locales/uk-ua'); } -describe('Locale: uk-UA', function() { +describe('Locale: uk-ua', function() { before(function() { - numeral.locale('uk-UA', locale); + numeral.locale('uk-ua', locale); - numeral.locale('uk-UA'); + numeral.locale('uk-ua'); }); after(function() { From 0fb7ee40632d2768a589c8b2102a9be1fa297785 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 24 Nov 2016 23:12:59 -0800 Subject: [PATCH 067/150] create new numeral and locales file --- Gruntfile.js | 10 + min/numeral-with-locales.min.js | 151 +++ numeral-with-locales.js | 1958 +++++++++++++++++++++++++++++++ 3 files changed, 2119 insertions(+) create mode 100644 min/numeral-with-locales.min.js create mode 100644 numeral-with-locales.js diff --git a/Gruntfile.js b/Gruntfile.js index c2592eb3..96702826 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -8,6 +8,9 @@ module.exports = function(grunt) { ], 'min/locales.min.js': [ 'locales.js' + ], + 'min/numeral-with-locales.min.js': [ + 'numeral-with-locales.js' ] }; @@ -66,6 +69,13 @@ module.exports = function(grunt) { 'locales/*.js' ], dest: 'locales.js' + }, + numeralWithLocales: { + src: [ + 'numeral.js', + 'locales/*.js' + ], + dest: 'numeral-with-locales.js' } }, jshint: { diff --git a/min/numeral-with-locales.min.js b/min/numeral-with-locales.min.js new file mode 100644 index 00000000..baae1436 --- /dev/null +++ b/min/numeral-with-locales.min.js @@ -0,0 +1,151 @@ +/*! @preserve + * numeral.js + * version : 1.5.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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var j;return j=0===a._value&&null!==s.zeroFormat?s.zeroFormat:null===a._value&&null!==s.nullFormat?s.nullFormat:b.indexOf("$")>-1?d(a,b,c):b.indexOf("%")>-1?e(a,b,c):b.indexOf(":")>-1?h(a,b):b.indexOf("b")>-1||b.indexOf("ib")>-1?f(a,b,c):b.indexOf("o")>-1?g(a,b,c):i(a._value,b,c)}function d(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),1>=f?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,q[s.currentLocale].currency.symbol+j),e=e.join("")):e=q[s.currentLocale].currency.symbol+j+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,j+q[s.currentLocale].currency.symbol),e=e.join("")):e=e+j+q[s.currentLocale].currency.symbol,e}function e(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 f(a,b,c){var d,e,f,g,h=b.indexOf("ib")>-1?t.bytes.binary:t.bytes.decimal,j=a._value,k="";for(b.indexOf(" b")>-1||b.indexOf(" ib")>-1?(k=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===j||0===j||j>=f&&g>j){k+=h.suffixes[e],f>0&&(j/=f);break}return d=i(j,b,c),d+k}function g(a,b,c){var d,e="";return b.indexOf(" o")>-1?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=q[s.currentLocale].ordinal(a._value),d=i(a._value,b,c),d+e}function h(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 i(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,r=!1,t="",u=!1;return null===a&&(a=0),e=Math.abs(a),c.indexOf("(")>-1?(i=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(j=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(m=c.indexOf("aK")>=0,n=c.indexOf("aM")>=0,o=c.indexOf("aB")>=0,p=c.indexOf("aT")>=0,r=m||n||o||p,c.indexOf(" a")>-1&&(l=" "),c=c.replace(new RegExp(l+"a[KMBT]?"),""),e>=Math.pow(10,12)&&!r||p?(l+=q[s.currentLocale].abbreviations.trillion,a/=Math.pow(10,12)):e=Math.pow(10,9)&&!r||o?(l+=q[s.currentLocale].abbreviations.billion,a/=Math.pow(10,9)):e=Math.pow(10,6)&&!r||n?(l+=q[s.currentLocale].abbreviations.million,a/=Math.pow(10,6)):(e=Math.pow(10,3)&&!r||m)&&(l+=q[s.currentLocale].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("[.]")>-1&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.indexOf("[")>-1?(g=g.replace("]",""),g=g.split("["),t=b(a,g[0].length+g[1].length,d,g[1].length)):t=b(a,g.length,d),f=t.split(".")[0],t=t.indexOf(".")>-1?q[s.currentLocale].delimiters.decimal+t.split(".")[1]:"",k&&0===Number(t.slice(1))&&(t="")):f=b(a,null,d),f.indexOf("-")>-1&&(f=f.slice(1),u=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+q[s.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&u?"(":"")+(!i&&u?"-":"")+(!u&&j?"+":"")+f+t+(l?l:"")+(i&&u?")":"")}function j(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.indexOf(":")>-1)h=k(b);else if(b===s.zeroFormat||b===s.nullFormat)h=0;else{for("."!==q[s.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(q[s.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.million+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.billion+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=t.bytes.decimal.suffixes.length&&!(j=b.indexOf(t.bytes.decimal.suffixes[g])>-1||b.indexOf(t.bytes.binary.suffixes[g])>-1?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.indexOf("%")>-1?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function k(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 l(a,b){q[a]=b}function m(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function n(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=m(a),d=m(b);return c>d?c:d},-(1/0))}var o,p="1.5.6",q={},r={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},s={currentLocale:r.currentLocale,zeroFormat:r.zeroFormat,nullFormat:r.nullFormat,defaultFormat:r.defaultFormat},t={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};o=function(b){return b=o.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):o.fn.unformat(b),new a(b)},o.version=p,o.isNumeral=function(b){return b instanceof a},o.locale=function(a,b){if(!a)return s.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!q[a])throw new Error("Unknown locale : "+a);s.currentLocale=a}return(b||!q[a])&&l(a,b),o},o.reset=function(){for(var a in r)s[a]=r[a]},o.localeData=function(a){if(!a)return q[s.currentLocale];if(!q[a])throw new Error("Unknown locale : "+a);return q[a]},o.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:"$"}}),o.zeroFormat=function(a){s.zeroFormat="string"==typeof a?a:null},o.nullFormat=function(a){s.nullFormat="string"==typeof a?a:null},o.defaultFormat=function(a){s.defaultFormat="string"==typeof a?a:"0.0"},o.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=o.localeData(b)}catch(k){i=o.localeData(o.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),o.fn=a.prototype={clone:function(){return o(this)},format:function(a,b){return c(this,a?a:s.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:j(this,a?a:s.defaultFormat)},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,d,e){return a+c*b}var c=n.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-c*b}var c=n.call(null,this._value,a);return this._value=[a].reduce(b,this._value*c)/c,this},multiply:function(a){function b(a,b,c,d){var e=n(a,b);return a*e*(b*e)/(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=n(a,b);return a*e/(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(o(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=o),"undefined"==typeof ender&&(this.numeral=o),"function"==typeof define&&define.amd&&define([],function(){return o})}).call(this),/*! @preserve + * numeral.js locale configuration + * locale : 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.locale&&this.numeral.locale("be-nl",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : simplified chinese + * author : badplum : https://github.com/badplum + */ +function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("chs",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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.locale&&this.numeral.locale("cs",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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(a){return"."},currency:{symbol:"DKK"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("da-dk",a)}(),/*! @preserve + * 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(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"CHF"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de-ch",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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.locale&&this.numeral.locale("en-gb",a)}(),/*! + * numeral.js locale configuration + * locale : english south africa (uk) + * author : Etienne Boshoff : etienne@zailab.com + */ +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:"R"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("en-za",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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.locale&&this.numeral.locale("es-es",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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.locale&&this.numeral.locale("es",a)}(),/*! @preserve + * 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(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("et",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("fi",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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.locale&&this.numeral.locale("fr-ca",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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.locale&&this.numeral.locale("fr-ch",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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.locale&&this.numeral.locale("fr",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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(a){return"."},currency:{symbol:" Ft"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("hu",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("it",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : japanese + * author : teppeis : https://github.com/teppeis + */ +function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("ja",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : Latvian (lv) + * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks + */ +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("lv",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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.locale&&this.numeral.locale("nl-nl",a)}(),/*! + * numeral.js locale configuration + * locale : norwegian (bokmål) + * author : Ove Andersen : https://github.com/azzlack + */ +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&(this.numeral.locale("nb-no",a),this.numeral.locale("nn-no",a),this.numeral.locale("no",a),this.numeral.locale("nb",a),this.numeral.locale("nn",a))}(),/*! @preserve + * numeral.js locale configuration + * locale : 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(a){return"."},currency:{symbol:"PLN"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pl",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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(a){return"º"},currency:{symbol:"R$"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pt-br",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("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.locale&&this.numeral.locale("ru-ua",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : russian (ru) + * author : Anatoli Papirovski : https://github.com/apapirovski + */ +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.locale&&this.numeral.locale("ru",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : 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.locale&&this.numeral.locale("sk",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : thai (th) + * author : Sathit Jittanupat : https://github.com/jojosati + */ +function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("th",a)}(),/*! @preserve + * 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(){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.locale&&this.numeral.locale("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.locale&&this.numeral.locale("uk-ua",a)}(); \ No newline at end of file diff --git a/numeral-with-locales.js b/numeral-with-locales.js new file mode 100644 index 00000000..88ed85ea --- /dev/null +++ b/numeral-with-locales.js @@ -0,0 +1,1958 @@ +/*! @preserve + * numeral.js + * version : 1.5.6 + * author : Adam Draper + * license : MIT + * http://adamwdraper.github.com/Numeral-js/ + */ + +(function() { + + /************************************ + Variables + ************************************/ + + var numeral, + VERSION = '1.5.6', + // internal storage for locale config files + locales = {}, + defaults = { + currentLocale: 'en', + zeroFormat: null, + nullFormat: null, + defaultFormat: '0,0' + }, + options = { + currentLocale: defaults.currentLocale, + zeroFormat: defaults.zeroFormat, + nullFormat: defaults.nullFormat, + defaultFormat: defaults.defaultFormat + }, + config = { + bytes: { + 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'] + } + } + }; + + + /************************************ + 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, 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); + + //roundingFunction = (roundingFunction !== undefined ? roundingFunction : Math.round); + // Multiply up by precision, round accurately, then divide and use native toFixed(): + output = (roundingFunction(value * power) / power).toFixed(boundedPrecision); + + if (optionals > maxDecimals - boundedPrecision) { + optionalsRegExp = new RegExp('\\.?0{1,' + (optionals - (maxDecimals - boundedPrecision)) + '}$'); + output = output.replace(optionalsRegExp, ''); + } + + return output; + } + + /************************************ + Formatting + ************************************/ + + // determine what type of formatting we need to do + function formatNumeral(n, format, roundingFunction) { + var output; + + if (n._value === 0 && options.zeroFormat !== null) { + output = options.zeroFormat; + } else if (n._value === null && options.nullFormat !== null) { + output = options.nullFormat; + } else { + // figure out what kind of format we are dealing with + if (format.indexOf('$') > -1) { + output = formatCurrency(n, format, roundingFunction); + } else if (format.indexOf('%') > -1) { + output = formatPercentage(n, format, roundingFunction); + } else if (format.indexOf(':') > -1) { + output = formatTime(n, format); + } else if (format.indexOf('b') > -1 || format.indexOf('ib') > -1) { + output = formatBytes(n, format, roundingFunction); + } else if (format.indexOf('o') > -1) { + output = formatOrdinal(n, format, roundingFunction); + } else { + output = formatNumber(n._value, format, roundingFunction); + } + } + + return output; + } + + 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('$', ''); + } + + // format the number + output = formatNumber(n._value, format, roundingFunction, false); + + // 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, locales[options.currentLocale].currency.symbol + space); + output = output.join(''); + } else { + output = locales[options.currentLocale].currency.symbol + space + output; + } + } else { + if (output.indexOf(')') > -1) { + output = output.split(''); + output.splice(-1, 0, space + locales[options.currentLocale].currency.symbol); + output = output.join(''); + } else { + output = output + space + locales[options.currentLocale].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 output; + } + + function formatBytes(n, format, roundingFunction) { + var output, + bytes = format.indexOf('ib') > -1 ? config.bytes.binary : config.bytes.decimal, + value = n._value, + suffix = '', + power, + min, + max; + + // check for space before + if (format.indexOf(' b') > -1 || format.indexOf(' ib') > -1) { + suffix = ' '; + format = format.replace(' ib', '').replace(' b', ''); + } else { + format = format.replace('ib', '').replace('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 = formatNumber(value, format, roundingFunction); + + return output + suffix; + } + + function formatOrdinal(n, format, roundingFunction) { + var output, + ordinal = ''; + + // check for space before + if (format.indexOf(' o') > -1) { + ordinal = ' '; + format = format.replace(' o', ''); + } else { + format = format.replace('o', ''); + } + + ordinal += locales[options.currentLocale].ordinal(n._value); + + output = formatNumber(n._value, format, roundingFunction); + + return output + ordinal; + } + + 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); + } + + 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 + abs, + min, + max, + power, + w, + precision, + thousands, + d = '', + neg = false; + + if (value === null) { + 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 (format.indexOf('(') > -1) { + negP = true; + format = format.slice(1, -1); + } else if (format.indexOf('+') > -1) { + signed = true; + 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; + + // check for space before abbreviation + if (format.indexOf(' a') > -1) { + abbr = ' '; + } + + format = format.replace(new RegExp(abbr + 'a[KMBT]?'), ''); + + if (abs >= Math.pow(10, 12) && !abbrForce || abbrT) { + // trillion + abbr = abbr + locales[options.currentLocale].abbreviations.trillion; + value = value / Math.pow(10, 12); + } else if (abs < Math.pow(10, 12) && abs >= Math.pow(10, 9) && !abbrForce || abbrB) { + // billion + abbr = abbr + locales[options.currentLocale].abbreviations.billion; + value = value / Math.pow(10, 9); + } else if (abs < Math.pow(10, 9) && abs >= Math.pow(10, 6) && !abbrForce || abbrM) { + // million + abbr = abbr + locales[options.currentLocale].abbreviations.million; + value = value / Math.pow(10, 6); + } else if (abs < Math.pow(10, 6) && abs >= Math.pow(10, 3) && !abbrForce || abbrK) { + // thousand + abbr = abbr + locales[options.currentLocale].abbreviations.thousand; + value = value / Math.pow(10, 3); + } + } + + + if (format.indexOf('[.]') > -1) { + optDec = true; + format = format.replace('[.]', '.'); + } + + w = value.toString().split('.')[0]; + precision = format.split('.')[1]; + thousands = format.indexOf(','); + + if (precision) { + if (precision.indexOf('[') > -1) { + precision = precision.replace(']', ''); + precision = precision.split('['); + d = toFixed(value, (precision[0].length + precision[1].length), roundingFunction, precision[1].length); + } else { + d = toFixed(value, precision.length, roundingFunction); + } + + w = d.split('.')[0]; + + if (d.indexOf('.') > -1) { + d = locales[options.currentLocale].delimiters.decimal + d.split('.')[1]; + } else { + d = ''; + } + + if (optDec && Number(d.slice(1)) === 0) { + d = ''; + } + } else { + w = toFixed(value, null, roundingFunction); + } + + // format number + if (w.indexOf('-') > -1) { + w = w.slice(1); + neg = true; + } + + if (thousands > -1) { + w = w.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + locales[options.currentLocale].delimiters.thousands); + } + + if (format.indexOf('.') === 0) { + w = ''; + } + + return ((negP && neg) ? '(' : '') + ((!negP && neg) ? '-' : '') + ((!neg && signed) ? '+' : '') + w + d + ((abbr) ? abbr : '') + ((negP && neg) ? ')' : ''); + } + + + /************************************ + Unformatting + ************************************/ + + // revert to number + function unformatNumeral(n, string) { + var stringOriginal = string, + thousandRegExp, + millionRegExp, + billionRegExp, + trillionRegExp, + bytesMultiplier = false, + power, + value; + + if (string.indexOf(':') > -1) { + value = unformatTime(string); + } else { + if (string === options.zeroFormat || string === options.nullFormat) { + value = 0; + } else { + if (locales[options.currentLocale].delimiters.decimal !== '.') { + string = string.replace(/\./g, '').replace(locales[options.currentLocale].delimiters.decimal, '.'); + } + + // see if abbreviations are there so that we can multiply to the correct number + thousandRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.thousand + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); + millionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.million + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); + billionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.billion + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); + trillionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.trillion + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); + + // see if bytes are there so that we can multiply to the correct number + for (power = 1; power <= config.bytes.decimal.suffixes.length; power++) { + bytesMultiplier = ((string.indexOf(config.bytes.decimal.suffixes[power]) > -1) || (string.indexOf(config.bytes.binary.suffixes[power]) > -1))? Math.pow(1024, power) : false; + + if (bytesMultiplier) { + break; + } + } + + // do some math to create our number + value = bytesMultiplier ? bytesMultiplier : 1; + value *= stringOriginal.match(thousandRegExp) ? Math.pow(10, 3) : 1; + value *= stringOriginal.match(millionRegExp) ? Math.pow(10, 6) : 1; + value *= stringOriginal.match(billionRegExp) ? Math.pow(10, 9) : 1; + value *= stringOriginal.match(trillionRegExp) ? Math.pow(10, 12) : 1; + // check for percentage + value *= string.indexOf('%') > -1 ? 0.01 : 1; + // check for negative number + value *= (string.split('-').length + Math.min(string.split('(').length - 1, string.split(')').length - 1)) % 2 ? 1 : -1; + // remove non numbers + value *= Number(string.replace(/[^0-9\.]+/g, '')); + // round if we are talking about bytes + value = bytesMultiplier ? Math.ceil(value) : value; + } + } + + n._value = value; + + return n._value; + } + 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); + } + + + /************************************ + Top Level Functions + ************************************/ + + numeral = function(input) { + if (numeral.isNumeral(input)) { + input = input.value(); + } else if (input === 0 || typeof input === 'undefined') { + input = 0; + } else if (input === null || Number.isNaN(input)) { + input = null; + } else if (!Number(input)) { + input = numeral.fn.unformat(input); + } else { + input = Number(input); + } + + return new Numeral(input); + }; + + // version number + numeral.version = VERSION; + + // compare numeral object + numeral.isNumeral = function(obj) { + return obj instanceof Numeral; + }; + + + // This function will load locales and then set the global locale. If + // no arguments are passed in, it will simply return the current global + // locale key. + numeral.locale = function(key, values) { + if (!key) { + return options.currentLocale; + } + + key = key.toLowerCase(); + + if (key && !values) { + if (!locales[key]) { + throw new Error('Unknown locale : ' + key); + } + + options.currentLocale = key; + } + + if (values || !locales[key]) { + loadLocale(key, values); + } + + return numeral; + }; + + numeral.reset = function() { + for (var property in defaults) { + options[property] = defaults[property]; + } + }; + + // 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]; + } + + if (!locales[key]) { + throw new Error('Unknown locale : ' + key); + } + + return locales[key]; + }; + + numeral.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: '$' + } + }); + + 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.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; + }; + + /************************************ + Helpers + ************************************/ + + function loadLocale(key, values) { + locales[key] = values; + } + + /************************************ + Floating-point helpers + ************************************/ + + // The floating-point helper functions and implementation + // borrows heavily from sinful.js: http://guipn.github.io/sinful.js/ + + Number.isNaN = Number.isNaN || function(value) { + return typeof value === 'number' && isNaN(value); + }; + + + // Production steps of ECMA-262, Edition 5, 15.4.4.21 + // Reference: http://es5.github.io/#x15.4.4.21 + if (!Array.prototype.reduce) { + Array.prototype.reduce = function(callback /*, initialValue*/) { + 'use strict'; + 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(this), len = t.length >>> 0, k = 0, value; + + if (arguments.length === 2) { + value = arguments[1]; + } 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. + */ + function multiplier(x) { + var parts = x.toString().split('.'); + if (parts.length < 2) { + return 1; + } + return 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. + */ + 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); + } + + + /************************************ + Numeral Prototype + ************************************/ + + + numeral.fn = Numeral.prototype = { + + clone: function() { + return numeral(this); + }, + + format: function (inputString, roundingFunction) { + return formatNumeral(this, + inputString ? inputString : options.defaultFormat, + roundingFunction !== undefined ? roundingFunction : Math.round + ); + }, + + unformat: function (inputString) { + if (Object.prototype.toString.call(inputString) === '[object Number]') { + return inputString; + } + + return unformatNumeral(this, inputString ? inputString : options.defaultFormat); + }, + + value: function() { + return this._value; + }, + + valueOf: function() { + return this._value; + }, + + 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 + corrFactor * curr; + } + this._value = [this._value, value].reduce(cback, 0) / corrFactor; + return this; + }, + + 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; + }, + + multiply: function(value) { + function cback(accum, curr, currI, O) { + var corrFactor = correctionFactor(accum, curr); + return (accum * corrFactor) * (curr * corrFactor) / + (corrFactor * corrFactor); + } + 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); + } + this._value = [this._value, value].reduce(cback); + return this; + }, + + difference: function(value) { + return Math.abs(numeral(this._value).subtract(value).value()); + } + + }; + + /************************************ + Exposing Numeral + ************************************/ + + // CommonJS module is defined + if (typeof module !== 'undefined' && module.exports) { + module.exports = numeral; + } + + /*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; + } + + /*global define:false */ + if (typeof define === 'function' && define.amd) { + define([], function() { + return numeral; + }); + } +}).call(this); + +/*! @preserve + * numeral.js locale configuration + * locale : belgium-dutch (be-nl) + * author : Dieter Luypaert : https://github.com/moeriki + */ +(function () { + var locale = { + 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 = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('be-nl', locale); + } +}()); + +/*! @preserve + * numeral.js locale configuration + * locale : simplified chinese + * author : badplum : https://github.com/badplum + */ +(function () { + var locale = { + delimiters: { + thousands: ',', + decimal: '.' + }, + abbreviations: { + thousand: '千', + million: '百万', + billion: '十亿', + trillion: '兆' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: '¥' + } + }; + + // Node + if (typeof module !== 'undefined' && module.exports) { + module.exports = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('chs', locale); + } +}()); + +/*! @preserve + * numeral.js locale configuration + * locale : czech (cs) + * author : Anatoli Papirovski : https://github.com/apapirovski + */ +(function () { + var locale = { + 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 = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('cs', locale); + } +}()); + +/*! @preserve + * numeral.js locale configuration + * locale : danish denmark (dk) + * author : Michael Storgaard : https://github.com/mstorgaard + */ +(function () { + var locale = { + 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 = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('da-dk', locale); + } +}()); +/*! @preserve + * 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 () { + var locale = { + 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 = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('de-ch', locale); + } +}()); +/*! @preserve + * numeral.js locale configuration + * locale : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium + * author : Marco Krage : https://github.com/sinky + */ +(function () { + var locale = { + 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 = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('de', locale); + } +}()); +/*! @preserve + * numeral.js locale configuration + * locale : english united kingdom (uk) + * author : Dan Ristic : https://github.com/dristic + */ +(function () { + var locale = { + 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 = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('en-gb', locale); + } +}()); +/*! + * numeral.js locale configuration + * locale : english south africa (uk) + * author : Etienne Boshoff : etienne@zailab.com + */ +(function () { + var locale = { + 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' + } + }; + + // Node + if (typeof module !== 'undefined' && module.exports) { + module.exports = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('en-za', locale); + } +}()); +/*! @preserve + * numeral.js locale configuration + * locale : spanish Spain + * author : Hernan Garcia : https://github.com/hgarcia + */ +(function () { + var locale = { + 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 = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('es-es', locale); + } +}()); + +/*! @preserve + * numeral.js locale configuration + * locale : spanish + * author : Hernan Garcia : https://github.com/hgarcia + */ +(function () { + var locale = { + 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 = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('es', locale); + } +}()); + +/*! @preserve + * 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 () { + var locale = { + 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 = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('et', locale); + } +}()); + +/*! @preserve + * numeral.js locale configuration + * locale : Finnish + * author : Sami Saada : https://github.com/samitheberber + */ +(function () { + var locale = { + 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 = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('fi', locale); + } +}()); + +/*! @preserve + * numeral.js locale configuration + * locale : french (Canada) (fr-ca) + * author : Léo Renaud-Allaire : https://github.com/renaudleo + */ +(function () { + var locale = { + 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 = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('fr-ca', locale); + } +}()); +/*! @preserve + * numeral.js locale configuration + * locale : french (fr-ch) + * author : Adam Draper : https://github.com/adamwdraper + */ +(function () { + var locale = { + 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 = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('fr-ch', locale); + } +}()); + +/*! @preserve + * numeral.js locale configuration + * locale : french (fr) + * author : Adam Draper : https://github.com/adamwdraper + */ +(function () { + var locale = { + 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 = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('fr', locale); + } +}()); +/*! @preserve + * numeral.js locale configuration + * locale : Hungarian (hu) + * author : Peter Bakondy : https://github.com/pbakondy + */ +(function () { + var locale = { + 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 = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('hu', locale); + } +}()); +/*! @preserve + * numeral.js locale configuration + * locale : italian Italy (it) + * author : Giacomo Trombi : http://cinquepunti.it + */ +(function () { + var locale = { + 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 = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('it', locale); + } +}()); +/*! @preserve + * numeral.js locale configuration + * locale : japanese + * author : teppeis : https://github.com/teppeis + */ +(function () { + var locale = { + delimiters: { + thousands: ',', + decimal: '.' + }, + abbreviations: { + thousand: '千', + million: '百万', + billion: '十億', + trillion: '兆' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: '¥' + } + }; + + // Node + if (typeof module !== 'undefined' && module.exports) { + module.exports = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('ja', locale); + } +}()); + +/*! @preserve + * numeral.js locale configuration + * locale : Latvian (lv) + * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks + */ +(function () { + var locale = { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: ' tūkst.', + million: ' milj.', + billion: ' mljrd.', + trillion: ' trilj.' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: '€' + } + }; + // Node + if (typeof module !== 'undefined' && module.exports) { + module.exports = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('lv', locale); + } +}()); + +/*! @preserve + * numeral.js locale configuration + * locale : netherlands-dutch (nl-nl) + * author : Dave Clayton : https://github.com/davedx + */ +(function () { + var locale = { + 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 = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('nl-nl', locale); + } +}()); +/*! + * numeral.js locale configuration + * locale : norwegian (bokmål) + * author : Ove Andersen : https://github.com/azzlack + */ +(function () { + var locale = { + delimiters: { + thousands: ' ', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: 'kr' + } + }; + + // Node + if (typeof module !== 'undefined' && module.exports) { + module.exports = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('nb-no', locale); + this.numeral.locale('nn-no', locale); + this.numeral.locale('no', locale); + this.numeral.locale('nb', locale); + this.numeral.locale('nn', locale); + } +}()); +/*! @preserve + * numeral.js locale configuration + * locale : polish (pl) + * author : Dominik Bulaj : https://github.com/dominikbulaj + */ +(function () { + var locale = { + 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 = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('pl', locale); + } +}()); +/*! @preserve + * numeral.js locale configuration + * locale : portuguese brazil (pt-br) + * author : Ramiro Varandas Jr : https://github.com/ramirovjr + */ +(function () { + var locale = { + 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 = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('pt-br', locale); + } +}()); +/*! @preserve + * numeral.js locale configuration + * locale : portuguese (pt-pt) + * author : Diogo Resende : https://github.com/dresende + */ +(function () { + var locale = { + 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 = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('pt-pt', locale); + } +}()); + +// numeral.js locale configuration +// locale : Russian for the Ukraine (ru-ua) +// author : Anatoli Papirovski : https://github.com/apapirovski +(function () { + var locale = { + 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 = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('ru-ua', locale); + } +}()); + +/*! @preserve + * numeral.js locale configuration + * locale : russian (ru) + * author : Anatoli Papirovski : https://github.com/apapirovski + */ +(function () { + var locale = { + 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: 'руб.' + } + }; + + // Node + if (typeof module !== 'undefined' && module.exports) { + module.exports = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('ru', locale); + } +}()); + +/*! @preserve + * numeral.js locale configuration + * locale : slovak (sk) + * author : Ahmed Al Hafoudh : http://www.freevision.sk + */ +(function () { + var locale = { + 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 = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('sk', locale); + } +}()); + +/*! @preserve + * numeral.js locale configuration + * locale : thai (th) + * author : Sathit Jittanupat : https://github.com/jojosati + */ +(function () { + var locale = { + delimiters: { + thousands: ',', + decimal: '.' + }, + abbreviations: { + thousand: 'พัน', + million: 'ล้าน', + billion: 'พันล้าน', + trillion: 'ล้านล้าน' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: '฿' + } + }; + + // Node + if (typeof module !== 'undefined' && module.exports) { + module.exports = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('th', locale); + } +}()); + +/*! @preserve + * 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 () { + 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ı' + }, + locale = { + 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 = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('tr', locale); + } +}()); + +// 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 locale = { + 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 = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('uk-ua', locale); + } +}()); From b52245b864fe3d0c2984be417a6282681405cee7 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 24 Nov 2016 23:23:10 -0800 Subject: [PATCH 068/150] make sure localeData uses lowercase keys --- min/numeral-with-locales.min.js | 2 +- min/numeral.min.js | 2 +- numeral-with-locales.js | 3 +++ numeral.js | 3 +++ tests/numeral/misc.js | 17 +++++++++++++++++ 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/min/numeral-with-locales.min.js b/min/numeral-with-locales.min.js index baae1436..058c0fb8 100644 --- a/min/numeral-with-locales.min.js +++ b/min/numeral-with-locales.min.js @@ -5,7 +5,7 @@ * 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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var j;return j=0===a._value&&null!==s.zeroFormat?s.zeroFormat:null===a._value&&null!==s.nullFormat?s.nullFormat:b.indexOf("$")>-1?d(a,b,c):b.indexOf("%")>-1?e(a,b,c):b.indexOf(":")>-1?h(a,b):b.indexOf("b")>-1||b.indexOf("ib")>-1?f(a,b,c):b.indexOf("o")>-1?g(a,b,c):i(a._value,b,c)}function d(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),1>=f?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,q[s.currentLocale].currency.symbol+j),e=e.join("")):e=q[s.currentLocale].currency.symbol+j+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,j+q[s.currentLocale].currency.symbol),e=e.join("")):e=e+j+q[s.currentLocale].currency.symbol,e}function e(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 f(a,b,c){var d,e,f,g,h=b.indexOf("ib")>-1?t.bytes.binary:t.bytes.decimal,j=a._value,k="";for(b.indexOf(" b")>-1||b.indexOf(" ib")>-1?(k=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===j||0===j||j>=f&&g>j){k+=h.suffixes[e],f>0&&(j/=f);break}return d=i(j,b,c),d+k}function g(a,b,c){var d,e="";return b.indexOf(" o")>-1?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=q[s.currentLocale].ordinal(a._value),d=i(a._value,b,c),d+e}function h(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 i(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,r=!1,t="",u=!1;return null===a&&(a=0),e=Math.abs(a),c.indexOf("(")>-1?(i=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(j=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(m=c.indexOf("aK")>=0,n=c.indexOf("aM")>=0,o=c.indexOf("aB")>=0,p=c.indexOf("aT")>=0,r=m||n||o||p,c.indexOf(" a")>-1&&(l=" "),c=c.replace(new RegExp(l+"a[KMBT]?"),""),e>=Math.pow(10,12)&&!r||p?(l+=q[s.currentLocale].abbreviations.trillion,a/=Math.pow(10,12)):e=Math.pow(10,9)&&!r||o?(l+=q[s.currentLocale].abbreviations.billion,a/=Math.pow(10,9)):e=Math.pow(10,6)&&!r||n?(l+=q[s.currentLocale].abbreviations.million,a/=Math.pow(10,6)):(e=Math.pow(10,3)&&!r||m)&&(l+=q[s.currentLocale].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("[.]")>-1&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.indexOf("[")>-1?(g=g.replace("]",""),g=g.split("["),t=b(a,g[0].length+g[1].length,d,g[1].length)):t=b(a,g.length,d),f=t.split(".")[0],t=t.indexOf(".")>-1?q[s.currentLocale].delimiters.decimal+t.split(".")[1]:"",k&&0===Number(t.slice(1))&&(t="")):f=b(a,null,d),f.indexOf("-")>-1&&(f=f.slice(1),u=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+q[s.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&u?"(":"")+(!i&&u?"-":"")+(!u&&j?"+":"")+f+t+(l?l:"")+(i&&u?")":"")}function j(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.indexOf(":")>-1)h=k(b);else if(b===s.zeroFormat||b===s.nullFormat)h=0;else{for("."!==q[s.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(q[s.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.million+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.billion+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=t.bytes.decimal.suffixes.length&&!(j=b.indexOf(t.bytes.decimal.suffixes[g])>-1||b.indexOf(t.bytes.binary.suffixes[g])>-1?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.indexOf("%")>-1?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function k(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 l(a,b){q[a]=b}function m(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function n(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=m(a),d=m(b);return c>d?c:d},-(1/0))}var o,p="1.5.6",q={},r={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},s={currentLocale:r.currentLocale,zeroFormat:r.zeroFormat,nullFormat:r.nullFormat,defaultFormat:r.defaultFormat},t={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};o=function(b){return b=o.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):o.fn.unformat(b),new a(b)},o.version=p,o.isNumeral=function(b){return b instanceof a},o.locale=function(a,b){if(!a)return s.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!q[a])throw new Error("Unknown locale : "+a);s.currentLocale=a}return(b||!q[a])&&l(a,b),o},o.reset=function(){for(var a in r)s[a]=r[a]},o.localeData=function(a){if(!a)return q[s.currentLocale];if(!q[a])throw new Error("Unknown locale : "+a);return q[a]},o.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:"$"}}),o.zeroFormat=function(a){s.zeroFormat="string"==typeof a?a:null},o.nullFormat=function(a){s.nullFormat="string"==typeof a?a:null},o.defaultFormat=function(a){s.defaultFormat="string"==typeof a?a:"0.0"},o.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=o.localeData(b)}catch(k){i=o.localeData(o.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),o.fn=a.prototype={clone:function(){return o(this)},format:function(a,b){return c(this,a?a:s.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:j(this,a?a:s.defaultFormat)},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,d,e){return a+c*b}var c=n.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-c*b}var c=n.call(null,this._value,a);return this._value=[a].reduce(b,this._value*c)/c,this},multiply:function(a){function b(a,b,c,d){var e=n(a,b);return a*e*(b*e)/(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=n(a,b);return a*e/(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(o(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=o),"undefined"==typeof ender&&(this.numeral=o),"function"==typeof define&&define.amd&&define([],function(){return o})}).call(this),/*! @preserve +(function(){function a(a){this._value=a}function b(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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var j;return j=0===a._value&&null!==s.zeroFormat?s.zeroFormat:null===a._value&&null!==s.nullFormat?s.nullFormat:b.indexOf("$")>-1?d(a,b,c):b.indexOf("%")>-1?e(a,b,c):b.indexOf(":")>-1?h(a,b):b.indexOf("b")>-1||b.indexOf("ib")>-1?f(a,b,c):b.indexOf("o")>-1?g(a,b,c):i(a._value,b,c)}function d(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),1>=f?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,q[s.currentLocale].currency.symbol+j),e=e.join("")):e=q[s.currentLocale].currency.symbol+j+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,j+q[s.currentLocale].currency.symbol),e=e.join("")):e=e+j+q[s.currentLocale].currency.symbol,e}function e(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 f(a,b,c){var d,e,f,g,h=b.indexOf("ib")>-1?t.bytes.binary:t.bytes.decimal,j=a._value,k="";for(b.indexOf(" b")>-1||b.indexOf(" ib")>-1?(k=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===j||0===j||j>=f&&g>j){k+=h.suffixes[e],f>0&&(j/=f);break}return d=i(j,b,c),d+k}function g(a,b,c){var d,e="";return b.indexOf(" o")>-1?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=q[s.currentLocale].ordinal(a._value),d=i(a._value,b,c),d+e}function h(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 i(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,r=!1,t="",u=!1;return null===a&&(a=0),e=Math.abs(a),c.indexOf("(")>-1?(i=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(j=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(m=c.indexOf("aK")>=0,n=c.indexOf("aM")>=0,o=c.indexOf("aB")>=0,p=c.indexOf("aT")>=0,r=m||n||o||p,c.indexOf(" a")>-1&&(l=" "),c=c.replace(new RegExp(l+"a[KMBT]?"),""),e>=Math.pow(10,12)&&!r||p?(l+=q[s.currentLocale].abbreviations.trillion,a/=Math.pow(10,12)):e=Math.pow(10,9)&&!r||o?(l+=q[s.currentLocale].abbreviations.billion,a/=Math.pow(10,9)):e=Math.pow(10,6)&&!r||n?(l+=q[s.currentLocale].abbreviations.million,a/=Math.pow(10,6)):(e=Math.pow(10,3)&&!r||m)&&(l+=q[s.currentLocale].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("[.]")>-1&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.indexOf("[")>-1?(g=g.replace("]",""),g=g.split("["),t=b(a,g[0].length+g[1].length,d,g[1].length)):t=b(a,g.length,d),f=t.split(".")[0],t=t.indexOf(".")>-1?q[s.currentLocale].delimiters.decimal+t.split(".")[1]:"",k&&0===Number(t.slice(1))&&(t="")):f=b(a,null,d),f.indexOf("-")>-1&&(f=f.slice(1),u=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+q[s.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&u?"(":"")+(!i&&u?"-":"")+(!u&&j?"+":"")+f+t+(l?l:"")+(i&&u?")":"")}function j(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.indexOf(":")>-1)h=k(b);else if(b===s.zeroFormat||b===s.nullFormat)h=0;else{for("."!==q[s.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(q[s.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.million+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.billion+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=t.bytes.decimal.suffixes.length&&!(j=b.indexOf(t.bytes.decimal.suffixes[g])>-1||b.indexOf(t.bytes.binary.suffixes[g])>-1?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.indexOf("%")>-1?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function k(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 l(a,b){q[a]=b}function m(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function n(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=m(a),d=m(b);return c>d?c:d},-(1/0))}var o,p="1.5.6",q={},r={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},s={currentLocale:r.currentLocale,zeroFormat:r.zeroFormat,nullFormat:r.nullFormat,defaultFormat:r.defaultFormat},t={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};o=function(b){return b=o.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):o.fn.unformat(b),new a(b)},o.version=p,o.isNumeral=function(b){return b instanceof a},o.locale=function(a,b){if(!a)return s.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!q[a])throw new Error("Unknown locale : "+a);s.currentLocale=a}return(b||!q[a])&&l(a,b),o},o.reset=function(){for(var a in r)s[a]=r[a]},o.localeData=function(a){if(!a)return q[s.currentLocale];if(a=a.toLowerCase(),!q[a])throw new Error("Unknown locale : "+a);return q[a]},o.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:"$"}}),o.zeroFormat=function(a){s.zeroFormat="string"==typeof a?a:null},o.nullFormat=function(a){s.nullFormat="string"==typeof a?a:null},o.defaultFormat=function(a){s.defaultFormat="string"==typeof a?a:"0.0"},o.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=o.localeData(b)}catch(k){i=o.localeData(o.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),o.fn=a.prototype={clone:function(){return o(this)},format:function(a,b){return c(this,a?a:s.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:j(this,a?a:s.defaultFormat)},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,d,e){return a+c*b}var c=n.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-c*b}var c=n.call(null,this._value,a);return this._value=[a].reduce(b,this._value*c)/c,this},multiply:function(a){function b(a,b,c,d){var e=n(a,b);return a*e*(b*e)/(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=n(a,b);return a*e/(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(o(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=o),"undefined"==typeof ender&&(this.numeral=o),"function"==typeof define&&define.amd&&define([],function(){return o})}).call(this),/*! @preserve * numeral.js locale configuration * locale : belgium-dutch (be-nl) * author : Dieter Luypaert : https://github.com/moeriki diff --git a/min/numeral.min.js b/min/numeral.min.js index 5bdbd5f9..a84df27b 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * 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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var j;return j=0===a._value&&null!==s.zeroFormat?s.zeroFormat:null===a._value&&null!==s.nullFormat?s.nullFormat:b.indexOf("$")>-1?d(a,b,c):b.indexOf("%")>-1?e(a,b,c):b.indexOf(":")>-1?h(a,b):b.indexOf("b")>-1||b.indexOf("ib")>-1?f(a,b,c):b.indexOf("o")>-1?g(a,b,c):i(a._value,b,c)}function d(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),1>=f?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,q[s.currentLocale].currency.symbol+j),e=e.join("")):e=q[s.currentLocale].currency.symbol+j+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,j+q[s.currentLocale].currency.symbol),e=e.join("")):e=e+j+q[s.currentLocale].currency.symbol,e}function e(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 f(a,b,c){var d,e,f,g,h=b.indexOf("ib")>-1?t.bytes.binary:t.bytes.decimal,j=a._value,k="";for(b.indexOf(" b")>-1||b.indexOf(" ib")>-1?(k=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===j||0===j||j>=f&&g>j){k+=h.suffixes[e],f>0&&(j/=f);break}return d=i(j,b,c),d+k}function g(a,b,c){var d,e="";return b.indexOf(" o")>-1?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=q[s.currentLocale].ordinal(a._value),d=i(a._value,b,c),d+e}function h(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 i(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,r=!1,t="",u=!1;return null===a&&(a=0),e=Math.abs(a),c.indexOf("(")>-1?(i=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(j=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(m=c.indexOf("aK")>=0,n=c.indexOf("aM")>=0,o=c.indexOf("aB")>=0,p=c.indexOf("aT")>=0,r=m||n||o||p,c.indexOf(" a")>-1&&(l=" "),c=c.replace(new RegExp(l+"a[KMBT]?"),""),e>=Math.pow(10,12)&&!r||p?(l+=q[s.currentLocale].abbreviations.trillion,a/=Math.pow(10,12)):e=Math.pow(10,9)&&!r||o?(l+=q[s.currentLocale].abbreviations.billion,a/=Math.pow(10,9)):e=Math.pow(10,6)&&!r||n?(l+=q[s.currentLocale].abbreviations.million,a/=Math.pow(10,6)):(e=Math.pow(10,3)&&!r||m)&&(l+=q[s.currentLocale].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("[.]")>-1&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.indexOf("[")>-1?(g=g.replace("]",""),g=g.split("["),t=b(a,g[0].length+g[1].length,d,g[1].length)):t=b(a,g.length,d),f=t.split(".")[0],t=t.indexOf(".")>-1?q[s.currentLocale].delimiters.decimal+t.split(".")[1]:"",k&&0===Number(t.slice(1))&&(t="")):f=b(a,null,d),f.indexOf("-")>-1&&(f=f.slice(1),u=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+q[s.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&u?"(":"")+(!i&&u?"-":"")+(!u&&j?"+":"")+f+t+(l?l:"")+(i&&u?")":"")}function j(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.indexOf(":")>-1)h=k(b);else if(b===s.zeroFormat||b===s.nullFormat)h=0;else{for("."!==q[s.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(q[s.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.million+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.billion+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=t.bytes.decimal.suffixes.length&&!(j=b.indexOf(t.bytes.decimal.suffixes[g])>-1||b.indexOf(t.bytes.binary.suffixes[g])>-1?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.indexOf("%")>-1?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function k(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 l(a,b){q[a]=b}function m(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function n(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=m(a),d=m(b);return c>d?c:d},-(1/0))}var o,p="1.5.6",q={},r={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},s={currentLocale:r.currentLocale,zeroFormat:r.zeroFormat,nullFormat:r.nullFormat,defaultFormat:r.defaultFormat},t={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};o=function(b){return b=o.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):o.fn.unformat(b),new a(b)},o.version=p,o.isNumeral=function(b){return b instanceof a},o.locale=function(a,b){if(!a)return s.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!q[a])throw new Error("Unknown locale : "+a);s.currentLocale=a}return(b||!q[a])&&l(a,b),o},o.reset=function(){for(var a in r)s[a]=r[a]},o.localeData=function(a){if(!a)return q[s.currentLocale];if(!q[a])throw new Error("Unknown locale : "+a);return q[a]},o.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:"$"}}),o.zeroFormat=function(a){s.zeroFormat="string"==typeof a?a:null},o.nullFormat=function(a){s.nullFormat="string"==typeof a?a:null},o.defaultFormat=function(a){s.defaultFormat="string"==typeof a?a:"0.0"},o.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=o.localeData(b)}catch(k){i=o.localeData(o.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),o.fn=a.prototype={clone:function(){return o(this)},format:function(a,b){return c(this,a?a:s.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:j(this,a?a:s.defaultFormat)},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,d,e){return a+c*b}var c=n.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-c*b}var c=n.call(null,this._value,a);return this._value=[a].reduce(b,this._value*c)/c,this},multiply:function(a){function b(a,b,c,d){var e=n(a,b);return a*e*(b*e)/(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=n(a,b);return a*e/(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(o(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=o),"undefined"==typeof ender&&(this.numeral=o),"function"==typeof define&&define.amd&&define([],function(){return o})}).call(this); \ No newline at end of file +(function(){function a(a){this._value=a}function b(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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var j;return j=0===a._value&&null!==s.zeroFormat?s.zeroFormat:null===a._value&&null!==s.nullFormat?s.nullFormat:b.indexOf("$")>-1?d(a,b,c):b.indexOf("%")>-1?e(a,b,c):b.indexOf(":")>-1?h(a,b):b.indexOf("b")>-1||b.indexOf("ib")>-1?f(a,b,c):b.indexOf("o")>-1?g(a,b,c):i(a._value,b,c)}function d(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),1>=f?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,q[s.currentLocale].currency.symbol+j),e=e.join("")):e=q[s.currentLocale].currency.symbol+j+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,j+q[s.currentLocale].currency.symbol),e=e.join("")):e=e+j+q[s.currentLocale].currency.symbol,e}function e(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 f(a,b,c){var d,e,f,g,h=b.indexOf("ib")>-1?t.bytes.binary:t.bytes.decimal,j=a._value,k="";for(b.indexOf(" b")>-1||b.indexOf(" ib")>-1?(k=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===j||0===j||j>=f&&g>j){k+=h.suffixes[e],f>0&&(j/=f);break}return d=i(j,b,c),d+k}function g(a,b,c){var d,e="";return b.indexOf(" o")>-1?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=q[s.currentLocale].ordinal(a._value),d=i(a._value,b,c),d+e}function h(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 i(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,r=!1,t="",u=!1;return null===a&&(a=0),e=Math.abs(a),c.indexOf("(")>-1?(i=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(j=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(m=c.indexOf("aK")>=0,n=c.indexOf("aM")>=0,o=c.indexOf("aB")>=0,p=c.indexOf("aT")>=0,r=m||n||o||p,c.indexOf(" a")>-1&&(l=" "),c=c.replace(new RegExp(l+"a[KMBT]?"),""),e>=Math.pow(10,12)&&!r||p?(l+=q[s.currentLocale].abbreviations.trillion,a/=Math.pow(10,12)):e=Math.pow(10,9)&&!r||o?(l+=q[s.currentLocale].abbreviations.billion,a/=Math.pow(10,9)):e=Math.pow(10,6)&&!r||n?(l+=q[s.currentLocale].abbreviations.million,a/=Math.pow(10,6)):(e=Math.pow(10,3)&&!r||m)&&(l+=q[s.currentLocale].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("[.]")>-1&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.indexOf("[")>-1?(g=g.replace("]",""),g=g.split("["),t=b(a,g[0].length+g[1].length,d,g[1].length)):t=b(a,g.length,d),f=t.split(".")[0],t=t.indexOf(".")>-1?q[s.currentLocale].delimiters.decimal+t.split(".")[1]:"",k&&0===Number(t.slice(1))&&(t="")):f=b(a,null,d),f.indexOf("-")>-1&&(f=f.slice(1),u=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+q[s.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&u?"(":"")+(!i&&u?"-":"")+(!u&&j?"+":"")+f+t+(l?l:"")+(i&&u?")":"")}function j(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.indexOf(":")>-1)h=k(b);else if(b===s.zeroFormat||b===s.nullFormat)h=0;else{for("."!==q[s.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(q[s.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.million+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.billion+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=t.bytes.decimal.suffixes.length&&!(j=b.indexOf(t.bytes.decimal.suffixes[g])>-1||b.indexOf(t.bytes.binary.suffixes[g])>-1?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.indexOf("%")>-1?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function k(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 l(a,b){q[a]=b}function m(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function n(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=m(a),d=m(b);return c>d?c:d},-(1/0))}var o,p="1.5.6",q={},r={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},s={currentLocale:r.currentLocale,zeroFormat:r.zeroFormat,nullFormat:r.nullFormat,defaultFormat:r.defaultFormat},t={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};o=function(b){return b=o.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):o.fn.unformat(b),new a(b)},o.version=p,o.isNumeral=function(b){return b instanceof a},o.locale=function(a,b){if(!a)return s.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!q[a])throw new Error("Unknown locale : "+a);s.currentLocale=a}return(b||!q[a])&&l(a,b),o},o.reset=function(){for(var a in r)s[a]=r[a]},o.localeData=function(a){if(!a)return q[s.currentLocale];if(a=a.toLowerCase(),!q[a])throw new Error("Unknown locale : "+a);return q[a]},o.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:"$"}}),o.zeroFormat=function(a){s.zeroFormat="string"==typeof a?a:null},o.nullFormat=function(a){s.nullFormat="string"==typeof a?a:null},o.defaultFormat=function(a){s.defaultFormat="string"==typeof a?a:"0.0"},o.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=o.localeData(b)}catch(k){i=o.localeData(o.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),o.fn=a.prototype={clone:function(){return o(this)},format:function(a,b){return c(this,a?a:s.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:j(this,a?a:s.defaultFormat)},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,d,e){return a+c*b}var c=n.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-c*b}var c=n.call(null,this._value,a);return this._value=[a].reduce(b,this._value*c)/c,this},multiply:function(a){function b(a,b,c,d){var e=n(a,b);return a*e*(b*e)/(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=n(a,b);return a*e/(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(o(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=o),"undefined"==typeof ender&&(this.numeral=o),"function"==typeof define&&define.amd&&define([],function(){return o})}).call(this); \ No newline at end of file diff --git a/numeral-with-locales.js b/numeral-with-locales.js index 88ed85ea..3df01b4c 100644 --- a/numeral-with-locales.js +++ b/numeral-with-locales.js @@ -500,6 +500,7 @@ return options.currentLocale; } + // standardize to lowercase key = key.toLowerCase(); if (key && !values) { @@ -531,6 +532,8 @@ return locales[options.currentLocale]; } + key = key.toLowerCase(); + if (!locales[key]) { throw new Error('Unknown locale : ' + key); } diff --git a/numeral.js b/numeral.js index 98184f7d..fc048c33 100644 --- a/numeral.js +++ b/numeral.js @@ -500,6 +500,7 @@ return options.currentLocale; } + // standardize to lowercase key = key.toLowerCase(); if (key && !values) { @@ -531,6 +532,8 @@ return locales[options.currentLocale]; } + key = key.toLowerCase(); + if (!locales[key]) { throw new Error('Unknown locale : ' + key); } diff --git a/tests/numeral/misc.js b/tests/numeral/misc.js index dd766b5a..254bf29a 100644 --- a/tests/numeral/misc.js +++ b/tests/numeral/misc.js @@ -164,5 +164,22 @@ describe('Misc', function() { expect(numeral.localeData().currency.symbol).to.equal(cOld); expect(formatTestVal()).to.equal(oldCurrencyVal); }); + + it('should key properly on custom locale data', function () { + var customformat = { + format: '0,0.00 $', + currency: { + symbol: '^' + } + }; + + numeral.locale('en-XX', customformat); + + expect(numeral.localeData('en-XX').format).to.equal('0,0.00 $'); + expect(numeral.localeData('en-XX').currency.symbol).to.equal('^'); + + expect(numeral.localeData('en-xx').format).to.equal('0,0.00 $'); + expect(numeral.localeData('en-xx').currency.symbol).to.equal('^'); + }); }); }); From 2e50b371fe46ffbc1b5ac4e27eab48dd52229ba1 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 24 Nov 2016 23:31:10 -0800 Subject: [PATCH 069/150] use latest node --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f22dff0d..9de8cd01 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: node_js node_js: - - "6" + - "node" - "4" before_script: - npm install -g grunt-cli From bd71bde52e68bb8491e3e265abbe6655bdd0a9e0 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 24 Nov 2016 23:41:29 -0800 Subject: [PATCH 070/150] rename locales with git --- locales/{es-ES.js => es-es.js} | 0 locales/{fr-CA.js => fr-ca.js} | 0 locales/{ru-UA.js => ru-ua.js} | 0 locales/{uk-UA.js => uk-ua.js} | 0 tests/locales/{es-ES.js => es-es.js} | 0 tests/locales/{fr-CA.js => fr-ca.js} | 0 tests/locales/{ru-UA.js => ru-ua.js} | 0 tests/locales/{uk-UA.js => uk-ua.js} | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename locales/{es-ES.js => es-es.js} (100%) rename locales/{fr-CA.js => fr-ca.js} (100%) rename locales/{ru-UA.js => ru-ua.js} (100%) rename locales/{uk-UA.js => uk-ua.js} (100%) rename tests/locales/{es-ES.js => es-es.js} (100%) rename tests/locales/{fr-CA.js => fr-ca.js} (100%) rename tests/locales/{ru-UA.js => ru-ua.js} (100%) rename tests/locales/{uk-UA.js => uk-ua.js} (100%) diff --git a/locales/es-ES.js b/locales/es-es.js similarity index 100% rename from locales/es-ES.js rename to locales/es-es.js diff --git a/locales/fr-CA.js b/locales/fr-ca.js similarity index 100% rename from locales/fr-CA.js rename to locales/fr-ca.js diff --git a/locales/ru-UA.js b/locales/ru-ua.js similarity index 100% rename from locales/ru-UA.js rename to locales/ru-ua.js diff --git a/locales/uk-UA.js b/locales/uk-ua.js similarity index 100% rename from locales/uk-UA.js rename to locales/uk-ua.js diff --git a/tests/locales/es-ES.js b/tests/locales/es-es.js similarity index 100% rename from tests/locales/es-ES.js rename to tests/locales/es-es.js diff --git a/tests/locales/fr-CA.js b/tests/locales/fr-ca.js similarity index 100% rename from tests/locales/fr-CA.js rename to tests/locales/fr-ca.js diff --git a/tests/locales/ru-UA.js b/tests/locales/ru-ua.js similarity index 100% rename from tests/locales/ru-UA.js rename to tests/locales/ru-ua.js diff --git a/tests/locales/uk-UA.js b/tests/locales/uk-ua.js similarity index 100% rename from tests/locales/uk-UA.js rename to tests/locales/uk-ua.js From a9edcd4a9f765644ec86defe4338702e80df5847 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sat, 26 Nov 2016 18:12:39 -0800 Subject: [PATCH 071/150] exponential format --- numeral.js | 14 ++++++++++++++ tests/numeral/format.js | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/numeral.js b/numeral.js index fc048c33..d5de658d 100644 --- a/numeral.js +++ b/numeral.js @@ -111,6 +111,8 @@ output = formatBytes(n, format, roundingFunction); } else if (format.indexOf('o') > -1) { output = formatOrdinal(n, format, roundingFunction); + } else if (format.indexOf('e+') > -1) { + output = formatExponential(n, format, roundingFunction); } else { output = formatNumber(n._value, format, roundingFunction); } @@ -250,6 +252,18 @@ return output + ordinal; } + function formatExponential(n, format, roundingFunction) { + var output, + exponential = typeof n._value === 'number' && !Number.isNaN(n._value) ? n._value.toExponential() : '0e+0', + parts = exponential.split('e+'); + + format = format.replace('e+0', ''); + + output = formatNumber(Number(parts[0]), format, roundingFunction); + + return output + 'e+' + parts[1]; + } + function formatTime(n) { var hours = Math.floor(n._value / 60 / 60), minutes = Math.floor((n._value - (hours * 60 * 60)) / 60), diff --git a/tests/numeral/format.js b/tests/numeral/format.js index cab1476c..6f31f493 100644 --- a/tests/numeral/format.js +++ b/tests/numeral/format.js @@ -186,6 +186,25 @@ describe('Format', function() { }); }); + describe('Exponential', function() { + 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'], + [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]); + } + + }); + }); + describe('Rounding', function() { it('should format with rounding', function() { var tests = [ From 883652dee706a283a685fd06147888561a3ccbca Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sat, 26 Nov 2016 20:11:40 -0800 Subject: [PATCH 072/150] format with negative exponential --- numeral.js | 52 +++++++++++++++++++++---------------- tests/numeral/format.js | 2 ++ tests/numeral/manipulate.js | 9 +++++-- tests/numeral/unformat.js | 18 +++++++++++++ 4 files changed, 57 insertions(+), 24 deletions(-) diff --git a/numeral.js b/numeral.js index d5de658d..147fabd4 100644 --- a/numeral.js +++ b/numeral.js @@ -111,7 +111,7 @@ output = formatBytes(n, format, roundingFunction); } else if (format.indexOf('o') > -1) { output = formatOrdinal(n, format, roundingFunction); - } else if (format.indexOf('e+') > -1) { + } else if (format.indexOf('e+') > -1 || format.indexOf('e-') > -1) { output = formatExponential(n, format, roundingFunction); } else { output = formatNumber(n._value, format, roundingFunction); @@ -255,13 +255,13 @@ function formatExponential(n, format, roundingFunction) { var output, exponential = typeof n._value === 'number' && !Number.isNaN(n._value) ? n._value.toExponential() : '0e+0', - parts = exponential.split('e+'); + parts = exponential.split('e'); - format = format.replace('e+0', ''); + format = format.indexOf('e+') > -1 ? format.replace('e+0', '') : format.replace('e-0', ''); output = formatNumber(Number(parts[0]), format, roundingFunction); - return output + 'e+' + parts[1]; + return output + 'e' + parts[1]; } function formatTime(n) { @@ -412,6 +412,8 @@ if (string.indexOf(':') > -1) { value = unformatTime(string); + } else if (string.indexOf('e+') > -1 || string.indexOf('e-') > -1) { + value = unformatExponential(string); } else { if (string === options.zeroFormat || string === options.nullFormat) { value = 0; @@ -456,6 +458,7 @@ return n._value; } + function unformatTime(string) { var timeArray = string.split(':'), seconds = 0; @@ -476,6 +479,20 @@ return Number(seconds); } + function unformatExponential(string) { + var parts = string.indexOf('e+') > -1 ? string.split('e+') : string.split('e-'), + value = Number(parts[0]), + power = Number(parts[1]); + + function cback(accum, curr, currI, O) { + var corrFactor = correctionFactor(accum, curr), + num = (accum * corrFactor) * (curr * corrFactor) / (corrFactor * corrFactor); + return num; + } + + return [value, Math.pow(10, power)].reduce(cback, 1); + } + /************************************ Top Level Functions @@ -687,18 +704,11 @@ locales[key] = values; } - /************************************ - Floating-point helpers - ************************************/ - - // The floating-point helper functions and implementation - // borrows heavily from sinful.js: http://guipn.github.io/sinful.js/ - + // isNaN polyfill Number.isNaN = Number.isNaN || function(value) { return typeof value === 'number' && isNaN(value); }; - // Production steps of ECMA-262, Edition 5, 15.4.4.21 // Reference: http://es5.github.io/#x15.4.4.21 if (!Array.prototype.reduce) { @@ -756,11 +766,10 @@ */ 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); + return args.reduce(function(accum, next) { + var mn = multiplier(next); + return accum > mn ? accum : mn; + }, 1); } @@ -807,7 +816,7 @@ var corrFactor = correctionFactor.call(null, this._value, value); function cback(accum, curr, currI, O) { - return accum + corrFactor * curr; + return accum + Math.round(corrFactor * curr); } this._value = [this._value, value].reduce(cback, 0) / corrFactor; return this; @@ -819,15 +828,14 @@ function cback(accum, curr, currI, O) { return accum - corrFactor * curr; } - this._value = [value].reduce(cback, this._value * corrFactor) / corrFactor; + this._value = [value].reduce(cback, Math.round(this._value * corrFactor)) / corrFactor; return this; }, multiply: function(value) { function cback(accum, curr, currI, O) { var corrFactor = correctionFactor(accum, curr); - return (accum * corrFactor) * (curr * corrFactor) / - (corrFactor * corrFactor); + return Math.round(accum * corrFactor) * Math.round(curr * corrFactor) / Math.round(corrFactor * corrFactor); } this._value = [this._value, value].reduce(cback, 1); return this; @@ -836,7 +844,7 @@ divide: function(value) { function cback(accum, curr, currI, O) { var corrFactor = correctionFactor(accum, curr); - return (accum * corrFactor) / (curr * corrFactor); + return Math.round(accum * corrFactor) / Math.round(curr * corrFactor); } this._value = [this._value, value].reduce(cback); return this; diff --git a/tests/numeral/format.js b/tests/numeral/format.js index 6f31f493..c9c48b78 100644 --- a/tests/numeral/format.js +++ b/tests/numeral/format.js @@ -193,6 +193,8 @@ describe('Format', function() { [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'] ], diff --git a/tests/numeral/manipulate.js b/tests/numeral/manipulate.js index da0c522a..9132b962 100644 --- a/tests/numeral/manipulate.js +++ b/tests/numeral/manipulate.js @@ -15,7 +15,9 @@ describe('Manipulate', function() { [1000,10,1010], [0.5,3,3.5], [-100,200,100], - [0.1,0.2,0.3] + [0.1,0.2,0.3], + [0.289999,0.000001,0.29], + [0.29,0.01,0.3] ], num; @@ -62,7 +64,10 @@ describe('Manipulate', function() { [1000,10,10000], [0.5,3,1.5], [-100,200,-20000], - [0.1,0.2,0.02] + [0.1,0.2,0.02], + [0.28,0.01,0.0028], + [0.29,0.01,0.0029], + [0.00000231,10000000,23.1] ], num; diff --git a/tests/numeral/unformat.js b/tests/numeral/unformat.js index c4b69ea9..a454e79c 100644 --- a/tests/numeral/unformat.js +++ b/tests/numeral/unformat.js @@ -92,4 +92,22 @@ describe('Unformat', function() { } }); }); + + describe('Exponential', function() { + it('should unformat exponential notation', function() { + var tests = [ + ['0e+0',0], + ['1e+0',1], + ['7.7e+1',77], + ['7.7e-3',0.0077], + ['7.712e+2',771.2], + ['-1.0008e+9',-1000800000], + ['-1.0008e-5',-0.000010008] + ]; + + for (var i = 0; i < tests.length; i++) { + expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + } + }); + }); }); From 82cabe2f2afc499217bc2265181f9dbf0c8bec93 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sat, 26 Nov 2016 20:15:26 -0800 Subject: [PATCH 073/150] tests for unformat --- numeral.js | 2 ++ tests/numeral/unformat.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/numeral.js b/numeral.js index 147fabd4..daf91919 100644 --- a/numeral.js +++ b/numeral.js @@ -484,6 +484,8 @@ value = Number(parts[0]), power = Number(parts[1]); + power = string.indexOf('e-') > -1 ? power *= -1 : power; + function cback(accum, curr, currI, O) { var corrFactor = correctionFactor(accum, curr), num = (accum * corrFactor) * (curr * corrFactor) / (corrFactor * corrFactor); diff --git a/tests/numeral/unformat.js b/tests/numeral/unformat.js index a454e79c..e61d2ded 100644 --- a/tests/numeral/unformat.js +++ b/tests/numeral/unformat.js @@ -102,7 +102,7 @@ describe('Unformat', function() { ['7.7e-3',0.0077], ['7.712e+2',771.2], ['-1.0008e+9',-1000800000], - ['-1.0008e-5',-0.000010008] + ['1.08e-5',0.0000108] ]; for (var i = 0; i < tests.length; i++) { From be7fbaa30f594086933e11e8bd5780a0affa63f2 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sat, 26 Nov 2016 20:15:49 -0800 Subject: [PATCH 074/150] build --- min/numeral-with-locales.min.js | 2 +- min/numeral.min.js | 2 +- numeral-with-locales.js | 60 +++++++++++++++++++++++---------- 3 files changed, 44 insertions(+), 20 deletions(-) diff --git a/min/numeral-with-locales.min.js b/min/numeral-with-locales.min.js index 058c0fb8..b38ffc4d 100644 --- a/min/numeral-with-locales.min.js +++ b/min/numeral-with-locales.min.js @@ -5,7 +5,7 @@ * 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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var j;return j=0===a._value&&null!==s.zeroFormat?s.zeroFormat:null===a._value&&null!==s.nullFormat?s.nullFormat:b.indexOf("$")>-1?d(a,b,c):b.indexOf("%")>-1?e(a,b,c):b.indexOf(":")>-1?h(a,b):b.indexOf("b")>-1||b.indexOf("ib")>-1?f(a,b,c):b.indexOf("o")>-1?g(a,b,c):i(a._value,b,c)}function d(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),1>=f?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,q[s.currentLocale].currency.symbol+j),e=e.join("")):e=q[s.currentLocale].currency.symbol+j+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,j+q[s.currentLocale].currency.symbol),e=e.join("")):e=e+j+q[s.currentLocale].currency.symbol,e}function e(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 f(a,b,c){var d,e,f,g,h=b.indexOf("ib")>-1?t.bytes.binary:t.bytes.decimal,j=a._value,k="";for(b.indexOf(" b")>-1||b.indexOf(" ib")>-1?(k=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===j||0===j||j>=f&&g>j){k+=h.suffixes[e],f>0&&(j/=f);break}return d=i(j,b,c),d+k}function g(a,b,c){var d,e="";return b.indexOf(" o")>-1?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=q[s.currentLocale].ordinal(a._value),d=i(a._value,b,c),d+e}function h(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 i(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,r=!1,t="",u=!1;return null===a&&(a=0),e=Math.abs(a),c.indexOf("(")>-1?(i=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(j=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(m=c.indexOf("aK")>=0,n=c.indexOf("aM")>=0,o=c.indexOf("aB")>=0,p=c.indexOf("aT")>=0,r=m||n||o||p,c.indexOf(" a")>-1&&(l=" "),c=c.replace(new RegExp(l+"a[KMBT]?"),""),e>=Math.pow(10,12)&&!r||p?(l+=q[s.currentLocale].abbreviations.trillion,a/=Math.pow(10,12)):e=Math.pow(10,9)&&!r||o?(l+=q[s.currentLocale].abbreviations.billion,a/=Math.pow(10,9)):e=Math.pow(10,6)&&!r||n?(l+=q[s.currentLocale].abbreviations.million,a/=Math.pow(10,6)):(e=Math.pow(10,3)&&!r||m)&&(l+=q[s.currentLocale].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("[.]")>-1&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.indexOf("[")>-1?(g=g.replace("]",""),g=g.split("["),t=b(a,g[0].length+g[1].length,d,g[1].length)):t=b(a,g.length,d),f=t.split(".")[0],t=t.indexOf(".")>-1?q[s.currentLocale].delimiters.decimal+t.split(".")[1]:"",k&&0===Number(t.slice(1))&&(t="")):f=b(a,null,d),f.indexOf("-")>-1&&(f=f.slice(1),u=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+q[s.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&u?"(":"")+(!i&&u?"-":"")+(!u&&j?"+":"")+f+t+(l?l:"")+(i&&u?")":"")}function j(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.indexOf(":")>-1)h=k(b);else if(b===s.zeroFormat||b===s.nullFormat)h=0;else{for("."!==q[s.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(q[s.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.million+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.billion+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=t.bytes.decimal.suffixes.length&&!(j=b.indexOf(t.bytes.decimal.suffixes[g])>-1||b.indexOf(t.bytes.binary.suffixes[g])>-1?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.indexOf("%")>-1?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function k(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 l(a,b){q[a]=b}function m(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function n(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=m(a),d=m(b);return c>d?c:d},-(1/0))}var o,p="1.5.6",q={},r={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},s={currentLocale:r.currentLocale,zeroFormat:r.zeroFormat,nullFormat:r.nullFormat,defaultFormat:r.defaultFormat},t={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};o=function(b){return b=o.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):o.fn.unformat(b),new a(b)},o.version=p,o.isNumeral=function(b){return b instanceof a},o.locale=function(a,b){if(!a)return s.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!q[a])throw new Error("Unknown locale : "+a);s.currentLocale=a}return(b||!q[a])&&l(a,b),o},o.reset=function(){for(var a in r)s[a]=r[a]},o.localeData=function(a){if(!a)return q[s.currentLocale];if(a=a.toLowerCase(),!q[a])throw new Error("Unknown locale : "+a);return q[a]},o.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:"$"}}),o.zeroFormat=function(a){s.zeroFormat="string"==typeof a?a:null},o.nullFormat=function(a){s.nullFormat="string"==typeof a?a:null},o.defaultFormat=function(a){s.defaultFormat="string"==typeof a?a:"0.0"},o.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=o.localeData(b)}catch(k){i=o.localeData(o.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),o.fn=a.prototype={clone:function(){return o(this)},format:function(a,b){return c(this,a?a:s.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:j(this,a?a:s.defaultFormat)},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,d,e){return a+c*b}var c=n.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-c*b}var c=n.call(null,this._value,a);return this._value=[a].reduce(b,this._value*c)/c,this},multiply:function(a){function b(a,b,c,d){var e=n(a,b);return a*e*(b*e)/(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=n(a,b);return a*e/(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(o(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=o),"undefined"==typeof ender&&(this.numeral=o),"function"==typeof define&&define.amd&&define([],function(){return o})}).call(this),/*! @preserve +(function(){function a(a){this._value=a}function b(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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k;return k=0===a._value&&null!==u.zeroFormat?u.zeroFormat:null===a._value&&null!==u.nullFormat?u.nullFormat:b.indexOf("$")>-1?d(a,b,c):b.indexOf("%")>-1?e(a,b,c):b.indexOf(":")>-1?i(a,b):b.indexOf("b")>-1||b.indexOf("ib")>-1?f(a,b,c):b.indexOf("o")>-1?g(a,b,c):b.indexOf("e+")>-1||b.indexOf("e-")>-1?h(a,b,c):j(a._value,b,c)}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i="";return b.indexOf(" $")>-1?(i=" ",b=b.replace(" $","")):b.indexOf("$ ")>-1?(i=" ",b=b.replace("$ ","")):b=b.replace("$",""),e=j(a._value,b,c,!1),1>=f?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e="",f=100*a._value;return b.indexOf(" %")>-1?(e=" ",b=b.replace(" %","")):b=b.replace("%",""),d=j(f,b,c),d.indexOf(")")>-1?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.indexOf("ib")>-1?v.bytes.binary:v.bytes.decimal,i=a._value,k="";for(b.indexOf(" b")>-1||b.indexOf(" ib")>-1?(k=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===i||0===i||i>=f&&g>i){k+=h.suffixes[e],f>0&&(i/=f);break}return d=j(i,b,c),d+k}function g(a,b,c){var d,e="";return b.indexOf(" o")>-1?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=s[u.currentLocale].ordinal(a._value),d=j(a._value,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a._value||Number.isNaN(a._value)?"0e+0":a._value.toExponential(),f=e.split("e");return b=b.indexOf("e+")>-1?b.replace("e+0",""):b.replace("e-0",""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(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 j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r="",t=!1;return null===a&&(a=0),e=Math.abs(a),c.indexOf("(")>-1?(i=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(j=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(m=c.indexOf("aK")>=0,n=c.indexOf("aM")>=0,o=c.indexOf("aB")>=0,p=c.indexOf("aT")>=0,q=m||n||o||p,c.indexOf(" a")>-1&&(l=" "),c=c.replace(new RegExp(l+"a[KMBT]?"),""),e>=Math.pow(10,12)&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=Math.pow(10,12)):e=Math.pow(10,9)&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=Math.pow(10,9)):e=Math.pow(10,6)&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=Math.pow(10,6)):(e=Math.pow(10,3)&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("[.]")>-1&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.indexOf("[")>-1?(g=g.replace("]",""),g=g.split("["),r=b(a,g[0].length+g[1].length,d,g[1].length)):r=b(a,g.length,d),f=r.split(".")[0],r=r.indexOf(".")>-1?s[u.currentLocale].delimiters.decimal+r.split(".")[1]:"",k&&0===Number(r.slice(1))&&(r="")):f=b(a,null,d),f.indexOf("-")>-1&&(f=f.slice(1),t=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&t?"(":"")+(!i&&t?"-":"")+(!t&&j?"+":"")+f+r+(l?l:"")+(i&&t?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.indexOf(":")>-1)h=l(b);else if(b.indexOf("e+")>-1||b.indexOf("e-")>-1)h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.indexOf(v.bytes.decimal.suffixes[g])>-1||b.indexOf(v.bytes.binary.suffixes[g])>-1?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.indexOf("%")>-1?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.indexOf("e+")>-1?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.indexOf("e-")>-1?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.reset=function(){for(var a in t)u[a]=t[a]},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-c*b}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this),/*! @preserve * numeral.js locale configuration * locale : belgium-dutch (be-nl) * author : Dieter Luypaert : https://github.com/moeriki diff --git a/min/numeral.min.js b/min/numeral.min.js index a84df27b..c47d73eb 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * 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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var j;return j=0===a._value&&null!==s.zeroFormat?s.zeroFormat:null===a._value&&null!==s.nullFormat?s.nullFormat:b.indexOf("$")>-1?d(a,b,c):b.indexOf("%")>-1?e(a,b,c):b.indexOf(":")>-1?h(a,b):b.indexOf("b")>-1||b.indexOf("ib")>-1?f(a,b,c):b.indexOf("o")>-1?g(a,b,c):i(a._value,b,c)}function d(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),1>=f?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,q[s.currentLocale].currency.symbol+j),e=e.join("")):e=q[s.currentLocale].currency.symbol+j+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,j+q[s.currentLocale].currency.symbol),e=e.join("")):e=e+j+q[s.currentLocale].currency.symbol,e}function e(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 f(a,b,c){var d,e,f,g,h=b.indexOf("ib")>-1?t.bytes.binary:t.bytes.decimal,j=a._value,k="";for(b.indexOf(" b")>-1||b.indexOf(" ib")>-1?(k=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===j||0===j||j>=f&&g>j){k+=h.suffixes[e],f>0&&(j/=f);break}return d=i(j,b,c),d+k}function g(a,b,c){var d,e="";return b.indexOf(" o")>-1?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=q[s.currentLocale].ordinal(a._value),d=i(a._value,b,c),d+e}function h(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 i(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,r=!1,t="",u=!1;return null===a&&(a=0),e=Math.abs(a),c.indexOf("(")>-1?(i=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(j=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(m=c.indexOf("aK")>=0,n=c.indexOf("aM")>=0,o=c.indexOf("aB")>=0,p=c.indexOf("aT")>=0,r=m||n||o||p,c.indexOf(" a")>-1&&(l=" "),c=c.replace(new RegExp(l+"a[KMBT]?"),""),e>=Math.pow(10,12)&&!r||p?(l+=q[s.currentLocale].abbreviations.trillion,a/=Math.pow(10,12)):e=Math.pow(10,9)&&!r||o?(l+=q[s.currentLocale].abbreviations.billion,a/=Math.pow(10,9)):e=Math.pow(10,6)&&!r||n?(l+=q[s.currentLocale].abbreviations.million,a/=Math.pow(10,6)):(e=Math.pow(10,3)&&!r||m)&&(l+=q[s.currentLocale].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("[.]")>-1&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.indexOf("[")>-1?(g=g.replace("]",""),g=g.split("["),t=b(a,g[0].length+g[1].length,d,g[1].length)):t=b(a,g.length,d),f=t.split(".")[0],t=t.indexOf(".")>-1?q[s.currentLocale].delimiters.decimal+t.split(".")[1]:"",k&&0===Number(t.slice(1))&&(t="")):f=b(a,null,d),f.indexOf("-")>-1&&(f=f.slice(1),u=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+q[s.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&u?"(":"")+(!i&&u?"-":"")+(!u&&j?"+":"")+f+t+(l?l:"")+(i&&u?")":"")}function j(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.indexOf(":")>-1)h=k(b);else if(b===s.zeroFormat||b===s.nullFormat)h=0;else{for("."!==q[s.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(q[s.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.million+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.billion+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+q[s.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+q[s.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=t.bytes.decimal.suffixes.length&&!(j=b.indexOf(t.bytes.decimal.suffixes[g])>-1||b.indexOf(t.bytes.binary.suffixes[g])>-1?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.indexOf("%")>-1?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function k(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 l(a,b){q[a]=b}function m(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function n(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=m(a),d=m(b);return c>d?c:d},-(1/0))}var o,p="1.5.6",q={},r={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},s={currentLocale:r.currentLocale,zeroFormat:r.zeroFormat,nullFormat:r.nullFormat,defaultFormat:r.defaultFormat},t={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};o=function(b){return b=o.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):o.fn.unformat(b),new a(b)},o.version=p,o.isNumeral=function(b){return b instanceof a},o.locale=function(a,b){if(!a)return s.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!q[a])throw new Error("Unknown locale : "+a);s.currentLocale=a}return(b||!q[a])&&l(a,b),o},o.reset=function(){for(var a in r)s[a]=r[a]},o.localeData=function(a){if(!a)return q[s.currentLocale];if(a=a.toLowerCase(),!q[a])throw new Error("Unknown locale : "+a);return q[a]},o.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:"$"}}),o.zeroFormat=function(a){s.zeroFormat="string"==typeof a?a:null},o.nullFormat=function(a){s.nullFormat="string"==typeof a?a:null},o.defaultFormat=function(a){s.defaultFormat="string"==typeof a?a:"0.0"},o.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=o.localeData(b)}catch(k){i=o.localeData(o.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),o.fn=a.prototype={clone:function(){return o(this)},format:function(a,b){return c(this,a?a:s.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:j(this,a?a:s.defaultFormat)},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,d,e){return a+c*b}var c=n.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-c*b}var c=n.call(null,this._value,a);return this._value=[a].reduce(b,this._value*c)/c,this},multiply:function(a){function b(a,b,c,d){var e=n(a,b);return a*e*(b*e)/(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=n(a,b);return a*e/(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(o(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=o),"undefined"==typeof ender&&(this.numeral=o),"function"==typeof define&&define.amd&&define([],function(){return o})}).call(this); \ No newline at end of file +(function(){function a(a){this._value=a}function b(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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k;return k=0===a._value&&null!==u.zeroFormat?u.zeroFormat:null===a._value&&null!==u.nullFormat?u.nullFormat:b.indexOf("$")>-1?d(a,b,c):b.indexOf("%")>-1?e(a,b,c):b.indexOf(":")>-1?i(a,b):b.indexOf("b")>-1||b.indexOf("ib")>-1?f(a,b,c):b.indexOf("o")>-1?g(a,b,c):b.indexOf("e+")>-1||b.indexOf("e-")>-1?h(a,b,c):j(a._value,b,c)}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i="";return b.indexOf(" $")>-1?(i=" ",b=b.replace(" $","")):b.indexOf("$ ")>-1?(i=" ",b=b.replace("$ ","")):b=b.replace("$",""),e=j(a._value,b,c,!1),1>=f?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e="",f=100*a._value;return b.indexOf(" %")>-1?(e=" ",b=b.replace(" %","")):b=b.replace("%",""),d=j(f,b,c),d.indexOf(")")>-1?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.indexOf("ib")>-1?v.bytes.binary:v.bytes.decimal,i=a._value,k="";for(b.indexOf(" b")>-1||b.indexOf(" ib")>-1?(k=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===i||0===i||i>=f&&g>i){k+=h.suffixes[e],f>0&&(i/=f);break}return d=j(i,b,c),d+k}function g(a,b,c){var d,e="";return b.indexOf(" o")>-1?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=s[u.currentLocale].ordinal(a._value),d=j(a._value,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a._value||Number.isNaN(a._value)?"0e+0":a._value.toExponential(),f=e.split("e");return b=b.indexOf("e+")>-1?b.replace("e+0",""):b.replace("e-0",""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(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 j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r="",t=!1;return null===a&&(a=0),e=Math.abs(a),c.indexOf("(")>-1?(i=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(j=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(m=c.indexOf("aK")>=0,n=c.indexOf("aM")>=0,o=c.indexOf("aB")>=0,p=c.indexOf("aT")>=0,q=m||n||o||p,c.indexOf(" a")>-1&&(l=" "),c=c.replace(new RegExp(l+"a[KMBT]?"),""),e>=Math.pow(10,12)&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=Math.pow(10,12)):e=Math.pow(10,9)&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=Math.pow(10,9)):e=Math.pow(10,6)&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=Math.pow(10,6)):(e=Math.pow(10,3)&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("[.]")>-1&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.indexOf("[")>-1?(g=g.replace("]",""),g=g.split("["),r=b(a,g[0].length+g[1].length,d,g[1].length)):r=b(a,g.length,d),f=r.split(".")[0],r=r.indexOf(".")>-1?s[u.currentLocale].delimiters.decimal+r.split(".")[1]:"",k&&0===Number(r.slice(1))&&(r="")):f=b(a,null,d),f.indexOf("-")>-1&&(f=f.slice(1),t=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&t?"(":"")+(!i&&t?"-":"")+(!t&&j?"+":"")+f+r+(l?l:"")+(i&&t?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.indexOf(":")>-1)h=l(b);else if(b.indexOf("e+")>-1||b.indexOf("e-")>-1)h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.indexOf(v.bytes.decimal.suffixes[g])>-1||b.indexOf(v.bytes.binary.suffixes[g])>-1?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.indexOf("%")>-1?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.indexOf("e+")>-1?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.indexOf("e-")>-1?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.reset=function(){for(var a in t)u[a]=t[a]},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-c*b}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this); \ No newline at end of file diff --git a/numeral-with-locales.js b/numeral-with-locales.js index 3df01b4c..0d8bce13 100644 --- a/numeral-with-locales.js +++ b/numeral-with-locales.js @@ -111,6 +111,8 @@ output = formatBytes(n, format, roundingFunction); } else if (format.indexOf('o') > -1) { output = formatOrdinal(n, format, roundingFunction); + } else if (format.indexOf('e+') > -1 || format.indexOf('e-') > -1) { + output = formatExponential(n, format, roundingFunction); } else { output = formatNumber(n._value, format, roundingFunction); } @@ -250,6 +252,18 @@ return output + ordinal; } + function formatExponential(n, format, roundingFunction) { + var output, + exponential = typeof n._value === 'number' && !Number.isNaN(n._value) ? n._value.toExponential() : '0e+0', + parts = exponential.split('e'); + + format = format.indexOf('e+') > -1 ? format.replace('e+0', '') : format.replace('e-0', ''); + + output = formatNumber(Number(parts[0]), format, roundingFunction); + + return output + 'e' + parts[1]; + } + function formatTime(n) { var hours = Math.floor(n._value / 60 / 60), minutes = Math.floor((n._value - (hours * 60 * 60)) / 60), @@ -398,6 +412,8 @@ if (string.indexOf(':') > -1) { value = unformatTime(string); + } else if (string.indexOf('e+') > -1 || string.indexOf('e-') > -1) { + value = unformatExponential(string); } else { if (string === options.zeroFormat || string === options.nullFormat) { value = 0; @@ -442,6 +458,7 @@ return n._value; } + function unformatTime(string) { var timeArray = string.split(':'), seconds = 0; @@ -462,6 +479,22 @@ return Number(seconds); } + function unformatExponential(string) { + var parts = string.indexOf('e+') > -1 ? string.split('e+') : string.split('e-'), + value = Number(parts[0]), + power = Number(parts[1]); + + power = string.indexOf('e-') > -1 ? power *= -1 : power; + + function cback(accum, curr, currI, O) { + var corrFactor = correctionFactor(accum, curr), + num = (accum * corrFactor) * (curr * corrFactor) / (corrFactor * corrFactor); + return num; + } + + return [value, Math.pow(10, power)].reduce(cback, 1); + } + /************************************ Top Level Functions @@ -673,18 +706,11 @@ locales[key] = values; } - /************************************ - Floating-point helpers - ************************************/ - - // The floating-point helper functions and implementation - // borrows heavily from sinful.js: http://guipn.github.io/sinful.js/ - + // isNaN polyfill Number.isNaN = Number.isNaN || function(value) { return typeof value === 'number' && isNaN(value); }; - // Production steps of ECMA-262, Edition 5, 15.4.4.21 // Reference: http://es5.github.io/#x15.4.4.21 if (!Array.prototype.reduce) { @@ -742,11 +768,10 @@ */ 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); + return args.reduce(function(accum, next) { + var mn = multiplier(next); + return accum > mn ? accum : mn; + }, 1); } @@ -793,7 +818,7 @@ var corrFactor = correctionFactor.call(null, this._value, value); function cback(accum, curr, currI, O) { - return accum + corrFactor * curr; + return accum + Math.round(corrFactor * curr); } this._value = [this._value, value].reduce(cback, 0) / corrFactor; return this; @@ -805,15 +830,14 @@ function cback(accum, curr, currI, O) { return accum - corrFactor * curr; } - this._value = [value].reduce(cback, this._value * corrFactor) / corrFactor; + this._value = [value].reduce(cback, Math.round(this._value * corrFactor)) / corrFactor; return this; }, multiply: function(value) { function cback(accum, curr, currI, O) { var corrFactor = correctionFactor(accum, curr); - return (accum * corrFactor) * (curr * corrFactor) / - (corrFactor * corrFactor); + return Math.round(accum * corrFactor) * Math.round(curr * corrFactor) / Math.round(corrFactor * corrFactor); } this._value = [this._value, value].reduce(cback, 1); return this; @@ -822,7 +846,7 @@ divide: function(value) { function cback(accum, curr, currI, O) { var corrFactor = correctionFactor(accum, curr); - return (accum * corrFactor) / (curr * corrFactor); + return Math.round(accum * corrFactor) / Math.round(curr * corrFactor); } this._value = [this._value, value].reduce(cback); return this; From d4b11451d3d9cb3e90d1c0fea178e0fcf15f9d3d Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sat, 26 Nov 2016 20:29:45 -0800 Subject: [PATCH 075/150] update readme with feature and bug fix --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 7ea73d4d..1364b521 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,10 @@ Breaking change: Bytes are now formatted as: `b` (base 1000) and `ib` (base 102 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 From b79cf4e3fe3f967de9fc86f6706347b3763c1fc2 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sat, 26 Nov 2016 22:36:17 -0800 Subject: [PATCH 076/150] fix languages to locales --- locales.js | 82 +++++++++++++++++++++++++++ {languages => locales}/bg.js | 24 ++++---- {languages => locales}/en-au.js | 14 ++--- min/locales.min.js | 12 +++- min/locales/bg.min.js | 6 ++ min/locales/en-au.min.js | 6 ++ min/numeral-with-locales.min.js | 12 +++- numeral-with-locales.js | 82 +++++++++++++++++++++++++++ tests/{languages => locales}/bg.js | 8 +-- tests/{languages => locales}/en-au.js | 8 +-- 10 files changed, 225 insertions(+), 29 deletions(-) rename {languages => locales}/bg.js (70%) rename {languages => locales}/en-au.js (79%) create mode 100644 min/locales/bg.min.js create mode 100644 min/locales/en-au.min.js rename tests/{languages => locales}/bg.js (94%) rename tests/{languages => locales}/en-au.js (94%) diff --git a/locales.js b/locales.js index 753650eb..dfae29a3 100644 --- a/locales.js +++ b/locales.js @@ -34,6 +34,49 @@ } }()); +/*! @preserve + * numeral.js locale configuration + * locale : Bulgarian + * author : Don Vince : https://github.com/donvince/ + */ +(function () { + var locale = { + 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: 'лв' + } + }; + + // Node + if (typeof module !== 'undefined' && module.exports) { + module.exports = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('bg', locale); + } +}()); + /*! @preserve * numeral.js locale configuration * locale : simplified chinese @@ -206,6 +249,45 @@ this.numeral.locale('de', locale); } }()); +/*! @preserve + * numeral.js locale configuration + * locale : English Australia + * author : Don Vince : https://github.com/donvince/ + */ +(function () { + var locale = { + 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 = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('en-au', locale); + } +}()); + /*! @preserve * numeral.js locale configuration * locale : english united kingdom (uk) diff --git a/languages/bg.js b/locales/bg.js similarity index 70% rename from languages/bg.js rename to locales/bg.js index 8de90d57..d4ed06f5 100644 --- a/languages/bg.js +++ b/locales/bg.js @@ -1,10 +1,10 @@ -/*! @preserve - * numeral.js language configuration - * language : Bulgarian +/*! @preserve + * numeral.js locale configuration + * locale : Bulgarian * author : Don Vince : https://github.com/donvince/ */ (function () { - var language = { + var locale = { delimiters: { thousands: ' ', decimal: ',' @@ -17,14 +17,14 @@ }, ordinal: function (number) { // google translate suggests: - // 1st=1-ви; 2nd=2-ри; 7th=7-ми; - // 8th=8-ми and many others end with -ти + // 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 + // 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 ''; + return ''; }, currency: { symbol: 'лв' @@ -33,10 +33,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('bg', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('bg', locale); } -}()); \ No newline at end of file +}()); diff --git a/languages/en-au.js b/locales/en-au.js similarity index 79% rename from languages/en-au.js rename to locales/en-au.js index 83cd5eea..5a7d1bcd 100644 --- a/languages/en-au.js +++ b/locales/en-au.js @@ -1,10 +1,10 @@ /*! @preserve - * numeral.js language configuration - * language : English Australia + * numeral.js locale configuration + * locale : English Australia * author : Don Vince : https://github.com/donvince/ */ (function () { - var language = { + var locale = { delimiters: { thousands: ',', decimal: '.' @@ -29,10 +29,10 @@ // Node if (typeof module !== 'undefined' && module.exports) { - module.exports = language; + module.exports = locale; } // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { - this.numeral.language('en-au', language); + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('en-au', locale); } -}()); \ No newline at end of file +}()); diff --git a/min/locales.min.js b/min/locales.min.js index c1f3c0f1..33f4dde8 100644 --- a/min/locales.min.js +++ b/min/locales.min.js @@ -3,7 +3,12 @@ * locale : 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.locale&&this.numeral.locale("be-nl",a)}(),/*! @preserve +!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.locale&&this.numeral.locale("be-nl",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : Bulgarian + * author : Don Vince : https://github.com/donvince/ + */ +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("bg",a)}(),/*! @preserve * numeral.js locale configuration * locale : simplified chinese * author : badplum : https://github.com/badplum @@ -29,6 +34,11 @@ function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand * author : Marco Krage : https://github.com/sinky */ function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : English Australia + * author : Don Vince : https://github.com/donvince/ + */ +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.locale&&this.numeral.locale("en-au",a)}(),/*! @preserve * numeral.js locale configuration * locale : english united kingdom (uk) * author : Dan Ristic : https://github.com/dristic diff --git a/min/locales/bg.min.js b/min/locales/bg.min.js new file mode 100644 index 00000000..138bdb6d --- /dev/null +++ b/min/locales/bg.min.js @@ -0,0 +1,6 @@ +/*! @preserve + * numeral.js locale configuration + * locale : Bulgarian + * author : Don Vince : https://github.com/donvince/ + */ +!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("bg",a)}(); \ 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..f08c5627 --- /dev/null +++ b/min/locales/en-au.min.js @@ -0,0 +1,6 @@ +/*! @preserve + * numeral.js locale configuration + * locale : English Australia + * author : Don Vince : https://github.com/donvince/ + */ +!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.locale&&this.numeral.locale("en-au",a)}(); \ No newline at end of file diff --git a/min/numeral-with-locales.min.js b/min/numeral-with-locales.min.js index ea0451b0..855b910d 100644 --- a/min/numeral-with-locales.min.js +++ b/min/numeral-with-locales.min.js @@ -10,7 +10,12 @@ * locale : 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.locale&&this.numeral.locale("be-nl",a)}(),/*! @preserve +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.locale&&this.numeral.locale("be-nl",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : Bulgarian + * author : Don Vince : https://github.com/donvince/ + */ +function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("bg",a)}(),/*! @preserve * numeral.js locale configuration * locale : simplified chinese * author : badplum : https://github.com/badplum @@ -36,6 +41,11 @@ function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand * author : Marco Krage : https://github.com/sinky */ function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de",a)}(),/*! @preserve + * numeral.js locale configuration + * locale : English Australia + * author : Don Vince : https://github.com/donvince/ + */ +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.locale&&this.numeral.locale("en-au",a)}(),/*! @preserve * numeral.js locale configuration * locale : english united kingdom (uk) * author : Dan Ristic : https://github.com/dristic diff --git a/numeral-with-locales.js b/numeral-with-locales.js index 6cc9b873..191e845c 100644 --- a/numeral-with-locales.js +++ b/numeral-with-locales.js @@ -919,6 +919,49 @@ } }()); +/*! @preserve + * numeral.js locale configuration + * locale : Bulgarian + * author : Don Vince : https://github.com/donvince/ + */ +(function () { + var locale = { + 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: 'лв' + } + }; + + // Node + if (typeof module !== 'undefined' && module.exports) { + module.exports = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('bg', locale); + } +}()); + /*! @preserve * numeral.js locale configuration * locale : simplified chinese @@ -1091,6 +1134,45 @@ this.numeral.locale('de', locale); } }()); +/*! @preserve + * numeral.js locale configuration + * locale : English Australia + * author : Don Vince : https://github.com/donvince/ + */ +(function () { + var locale = { + 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 = locale; + } + // Browser + if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { + this.numeral.locale('en-au', locale); + } +}()); + /*! @preserve * numeral.js locale configuration * locale : english united kingdom (uk) diff --git a/tests/languages/bg.js b/tests/locales/bg.js similarity index 94% rename from tests/languages/bg.js rename to tests/locales/bg.js index abc1567c..18accf7c 100644 --- a/tests/languages/bg.js +++ b/tests/locales/bg.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/bg'); + var locale = require('../../locales/bg'); } -describe('Language: bg', function() { +describe('Locale: bg', function() { before(function() { - numeral.language('bg', language); + numeral.locale('bg', locale); - numeral.language('bg'); + numeral.locale('bg'); }); after(function() { diff --git a/tests/languages/en-au.js b/tests/locales/en-au.js similarity index 94% rename from tests/languages/en-au.js rename to tests/locales/en-au.js index 70c4f5a4..ea59b27a 100644 --- a/tests/languages/en-au.js +++ b/tests/locales/en-au.js @@ -2,15 +2,15 @@ if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); var expect = require('chai').expect; - var language = require('../../languages/en-au'); + var locale = require('../../locales/en-au'); } -describe('Language: en-au', function() { +describe('Locale: en-au', function() { before(function() { - numeral.language('en-au', language); + numeral.locale('en-au', locale); - numeral.language('en-au'); + numeral.locale('en-au'); }); after(function() { From 84343d13662138cd31c9c768a9d8e0ba5a63b7d8 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sun, 27 Nov 2016 20:54:29 -0800 Subject: [PATCH 077/150] switch for formats --- min/numeral-with-locales.min.js | 2 +- min/numeral.min.js | 2 +- numeral-with-locales.js | 44 ++++++++++++++++++++++----------- numeral.js | 44 ++++++++++++++++++++++----------- 4 files changed, 62 insertions(+), 30 deletions(-) diff --git a/min/numeral-with-locales.min.js b/min/numeral-with-locales.min.js index 855b910d..4bde2b84 100644 --- a/min/numeral-with-locales.min.js +++ b/min/numeral-with-locales.min.js @@ -5,7 +5,7 @@ * 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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k;return k=0===a._value&&null!==u.zeroFormat?u.zeroFormat:null===a._value&&null!==u.nullFormat?u.nullFormat:b.indexOf("$")>-1?d(a,b,c):b.indexOf("%")>-1?e(a,b,c):b.indexOf(":")>-1?i(a,b):b.indexOf("b")>-1||b.indexOf("ib")>-1?f(a,b,c):b.indexOf("o")>-1?g(a,b,c):b.indexOf("e+")>-1||b.indexOf("e-")>-1?h(a,b,c):j(a._value,b,c)}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i="";return b.indexOf(" $")>-1?(i=" ",b=b.replace(" $","")):b.indexOf("$ ")>-1?(i=" ",b=b.replace("$ ","")):b=b.replace("$",""),e=j(a._value,b,c,!1),1>=f?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e="",f=100*a._value;return b.indexOf(" %")>-1?(e=" ",b=b.replace(" %","")):b=b.replace("%",""),d=j(f,b,c),d.indexOf(")")>-1?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.indexOf("ib")>-1?v.bytes.binary:v.bytes.decimal,i=a._value,k="";for(b.indexOf(" b")>-1||b.indexOf(" ib")>-1?(k=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===i||0===i||i>=f&&g>i){k+=h.suffixes[e],f>0&&(i/=f);break}return d=j(i,b,c),d+k}function g(a,b,c){var d,e="";return b.indexOf(" o")>-1?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=s[u.currentLocale].ordinal(a._value),d=j(a._value,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a._value||Number.isNaN(a._value)?"0e+0":a._value.toExponential(),f=e.split("e");return b=b.indexOf("e+")>-1?b.replace("e+0",""):b.replace("e-0",""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(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 j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r="",t=!1;return null===a&&(a=0),e=Math.abs(a),c.indexOf("(")>-1?(i=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(j=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(m=c.indexOf("aK")>=0,n=c.indexOf("aM")>=0,o=c.indexOf("aB")>=0,p=c.indexOf("aT")>=0,q=m||n||o||p,c.indexOf(" a")>-1&&(l=" "),c=c.replace(new RegExp(l+"a[KMBT]?"),""),e>=Math.pow(10,12)&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=Math.pow(10,12)):e=Math.pow(10,9)&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=Math.pow(10,9)):e=Math.pow(10,6)&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=Math.pow(10,6)):(e=Math.pow(10,3)&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("[.]")>-1&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.indexOf("[")>-1?(g=g.replace("]",""),g=g.split("["),r=b(a,g[0].length+g[1].length,d,g[1].length)):r=b(a,g.length,d),f=r.split(".")[0],r=r.indexOf(".")>-1?s[u.currentLocale].delimiters.decimal+r.split(".")[1]:"",k&&0===Number(r.slice(1))&&(r="")):f=b(a,null,d),f.indexOf("-")>-1&&(f=f.slice(1),t=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&t?"(":"")+(!i&&t?"-":"")+(!t&&j?"+":"")+f+r+(l?l:"")+(i&&t?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.indexOf(":")>-1)h=l(b);else if(b.indexOf("e+")>-1||b.indexOf("e-")>-1)h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.indexOf(v.bytes.decimal.suffixes[g])>-1||b.indexOf(v.bytes.binary.suffixes[g])>-1?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.indexOf("%")>-1?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.indexOf("e+")>-1?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.indexOf("e-")>-1?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.reset=function(){for(var a in t)u[a]=t[a]},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this),/*! @preserve +(function(){function a(a){this._value=a}function b(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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m;if(0===a._value&&null!==u.zeroFormat)k=u.zeroFormat;else if(null===a._value&&null!==u.nullFormat)k=u.nullFormat;else if(l=b.match(/(\$|%|:|ib|b|o|e\+|e-)/)){switch(l[0]){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h}k=m(a,b,c)}else k=j(a._value,b,c);return k}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i="";return b.indexOf(" $")>-1?(i=" ",b=b.replace(" $","")):b.indexOf("$ ")>-1?(i=" ",b=b.replace("$ ","")):b=b.replace("$",""),e=j(a._value,b,c,!1),1>=f?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e="",f=100*a._value;return b.indexOf(" %")>-1?(e=" ",b=b.replace(" %","")):b=b.replace("%",""),d=j(f,b,c),d.indexOf(")")>-1?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.indexOf("ib")>-1?v.bytes.binary:v.bytes.decimal,i=a._value,k="";for(b.indexOf(" b")>-1||b.indexOf(" ib")>-1?(k=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===i||0===i||i>=f&&g>i){k+=h.suffixes[e],f>0&&(i/=f);break}return d=j(i,b,c),d+k}function g(a,b,c){var d,e="";return b.indexOf(" o")>-1?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=s[u.currentLocale].ordinal(a._value),d=j(a._value,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a._value||Number.isNaN(a._value)?"0e+0":a._value.toExponential(),f=e.split("e");return b=b.indexOf("e+")>-1?b.replace("e+0",""):b.replace("e-0",""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(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 j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r="",t=!1;return null===a&&(a=0),e=Math.abs(a),c.indexOf("(")>-1?(i=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(j=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(m=c.indexOf("aK")>=0,n=c.indexOf("aM")>=0,o=c.indexOf("aB")>=0,p=c.indexOf("aT")>=0,q=m||n||o||p,c.indexOf(" a")>-1&&(l=" "),c=c.replace(new RegExp(l+"a[KMBT]?"),""),e>=Math.pow(10,12)&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=Math.pow(10,12)):e=Math.pow(10,9)&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=Math.pow(10,9)):e=Math.pow(10,6)&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=Math.pow(10,6)):(e=Math.pow(10,3)&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("[.]")>-1&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.indexOf("[")>-1?(g=g.replace("]",""),g=g.split("["),r=b(a,g[0].length+g[1].length,d,g[1].length)):r=b(a,g.length,d),f=r.split(".")[0],r=r.indexOf(".")>-1?s[u.currentLocale].delimiters.decimal+r.split(".")[1]:"",k&&0===Number(r.slice(1))&&(r="")):f=b(a,null,d),f.indexOf("-")>-1&&(f=f.slice(1),t=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&t?"(":"")+(!i&&t?"-":"")+(!t&&j?"+":"")+f+r+(l?l:"")+(i&&t?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.indexOf(":")>-1)h=l(b);else if(b.indexOf("e+")>-1||b.indexOf("e-")>-1)h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.indexOf(v.bytes.decimal.suffixes[g])>-1||b.indexOf(v.bytes.binary.suffixes[g])>-1?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.indexOf("%")>-1?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.indexOf("e+")>-1?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.indexOf("e-")>-1?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.reset=function(){for(var a in t)u[a]=t[a]},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this),/*! @preserve * numeral.js locale configuration * locale : belgium-dutch (be-nl) * author : Dieter Luypaert : https://github.com/moeriki diff --git a/min/numeral.min.js b/min/numeral.min.js index eae3210e..fcd62f7e 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * 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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k;return k=0===a._value&&null!==u.zeroFormat?u.zeroFormat:null===a._value&&null!==u.nullFormat?u.nullFormat:b.indexOf("$")>-1?d(a,b,c):b.indexOf("%")>-1?e(a,b,c):b.indexOf(":")>-1?i(a,b):b.indexOf("b")>-1||b.indexOf("ib")>-1?f(a,b,c):b.indexOf("o")>-1?g(a,b,c):b.indexOf("e+")>-1||b.indexOf("e-")>-1?h(a,b,c):j(a._value,b,c)}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i="";return b.indexOf(" $")>-1?(i=" ",b=b.replace(" $","")):b.indexOf("$ ")>-1?(i=" ",b=b.replace("$ ","")):b=b.replace("$",""),e=j(a._value,b,c,!1),1>=f?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e="",f=100*a._value;return b.indexOf(" %")>-1?(e=" ",b=b.replace(" %","")):b=b.replace("%",""),d=j(f,b,c),d.indexOf(")")>-1?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.indexOf("ib")>-1?v.bytes.binary:v.bytes.decimal,i=a._value,k="";for(b.indexOf(" b")>-1||b.indexOf(" ib")>-1?(k=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===i||0===i||i>=f&&g>i){k+=h.suffixes[e],f>0&&(i/=f);break}return d=j(i,b,c),d+k}function g(a,b,c){var d,e="";return b.indexOf(" o")>-1?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=s[u.currentLocale].ordinal(a._value),d=j(a._value,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a._value||Number.isNaN(a._value)?"0e+0":a._value.toExponential(),f=e.split("e");return b=b.indexOf("e+")>-1?b.replace("e+0",""):b.replace("e-0",""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(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 j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r="",t=!1;return null===a&&(a=0),e=Math.abs(a),c.indexOf("(")>-1?(i=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(j=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(m=c.indexOf("aK")>=0,n=c.indexOf("aM")>=0,o=c.indexOf("aB")>=0,p=c.indexOf("aT")>=0,q=m||n||o||p,c.indexOf(" a")>-1&&(l=" "),c=c.replace(new RegExp(l+"a[KMBT]?"),""),e>=Math.pow(10,12)&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=Math.pow(10,12)):e=Math.pow(10,9)&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=Math.pow(10,9)):e=Math.pow(10,6)&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=Math.pow(10,6)):(e=Math.pow(10,3)&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("[.]")>-1&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.indexOf("[")>-1?(g=g.replace("]",""),g=g.split("["),r=b(a,g[0].length+g[1].length,d,g[1].length)):r=b(a,g.length,d),f=r.split(".")[0],r=r.indexOf(".")>-1?s[u.currentLocale].delimiters.decimal+r.split(".")[1]:"",k&&0===Number(r.slice(1))&&(r="")):f=b(a,null,d),f.indexOf("-")>-1&&(f=f.slice(1),t=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&t?"(":"")+(!i&&t?"-":"")+(!t&&j?"+":"")+f+r+(l?l:"")+(i&&t?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.indexOf(":")>-1)h=l(b);else if(b.indexOf("e+")>-1||b.indexOf("e-")>-1)h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.indexOf(v.bytes.decimal.suffixes[g])>-1||b.indexOf(v.bytes.binary.suffixes[g])>-1?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.indexOf("%")>-1?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.indexOf("e+")>-1?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.indexOf("e-")>-1?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.reset=function(){for(var a in t)u[a]=t[a]},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this); \ No newline at end of file +(function(){function a(a){this._value=a}function b(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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m;if(0===a._value&&null!==u.zeroFormat)k=u.zeroFormat;else if(null===a._value&&null!==u.nullFormat)k=u.nullFormat;else if(l=b.match(/(\$|%|:|ib|b|o|e\+|e-)/)){switch(l[0]){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h}k=m(a,b,c)}else k=j(a._value,b,c);return k}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i="";return b.indexOf(" $")>-1?(i=" ",b=b.replace(" $","")):b.indexOf("$ ")>-1?(i=" ",b=b.replace("$ ","")):b=b.replace("$",""),e=j(a._value,b,c,!1),1>=f?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e="",f=100*a._value;return b.indexOf(" %")>-1?(e=" ",b=b.replace(" %","")):b=b.replace("%",""),d=j(f,b,c),d.indexOf(")")>-1?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.indexOf("ib")>-1?v.bytes.binary:v.bytes.decimal,i=a._value,k="";for(b.indexOf(" b")>-1||b.indexOf(" ib")>-1?(k=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===i||0===i||i>=f&&g>i){k+=h.suffixes[e],f>0&&(i/=f);break}return d=j(i,b,c),d+k}function g(a,b,c){var d,e="";return b.indexOf(" o")>-1?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=s[u.currentLocale].ordinal(a._value),d=j(a._value,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a._value||Number.isNaN(a._value)?"0e+0":a._value.toExponential(),f=e.split("e");return b=b.indexOf("e+")>-1?b.replace("e+0",""):b.replace("e-0",""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(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 j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r="",t=!1;return null===a&&(a=0),e=Math.abs(a),c.indexOf("(")>-1?(i=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(j=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(m=c.indexOf("aK")>=0,n=c.indexOf("aM")>=0,o=c.indexOf("aB")>=0,p=c.indexOf("aT")>=0,q=m||n||o||p,c.indexOf(" a")>-1&&(l=" "),c=c.replace(new RegExp(l+"a[KMBT]?"),""),e>=Math.pow(10,12)&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=Math.pow(10,12)):e=Math.pow(10,9)&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=Math.pow(10,9)):e=Math.pow(10,6)&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=Math.pow(10,6)):(e=Math.pow(10,3)&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("[.]")>-1&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.indexOf("[")>-1?(g=g.replace("]",""),g=g.split("["),r=b(a,g[0].length+g[1].length,d,g[1].length)):r=b(a,g.length,d),f=r.split(".")[0],r=r.indexOf(".")>-1?s[u.currentLocale].delimiters.decimal+r.split(".")[1]:"",k&&0===Number(r.slice(1))&&(r="")):f=b(a,null,d),f.indexOf("-")>-1&&(f=f.slice(1),t=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&t?"(":"")+(!i&&t?"-":"")+(!t&&j?"+":"")+f+r+(l?l:"")+(i&&t?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.indexOf(":")>-1)h=l(b);else if(b.indexOf("e+")>-1||b.indexOf("e-")>-1)h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.indexOf(v.bytes.decimal.suffixes[g])>-1||b.indexOf(v.bytes.binary.suffixes[g])>-1?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.indexOf("%")>-1?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.indexOf("e+")>-1?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.indexOf("e-")>-1?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.reset=function(){for(var a in t)u[a]=t[a]},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this); \ No newline at end of file diff --git a/numeral-with-locales.js b/numeral-with-locales.js index 191e845c..4f8444dc 100644 --- a/numeral-with-locales.js +++ b/numeral-with-locales.js @@ -93,26 +93,42 @@ // determine what type of formatting we need to do function formatNumeral(n, format, roundingFunction) { - var output; + var output, + kind, + formatFunction; if (n._value === 0 && options.zeroFormat !== null) { output = options.zeroFormat; } else if (n._value === null && options.nullFormat !== null) { output = options.nullFormat; } else { - // figure out what kind of format we are dealing with - if (format.indexOf('$') > -1) { - output = formatCurrency(n, format, roundingFunction); - } else if (format.indexOf('%') > -1) { - output = formatPercentage(n, format, roundingFunction); - } else if (format.indexOf(':') > -1) { - output = formatTime(n, format); - } else if (format.indexOf('b') > -1 || format.indexOf('ib') > -1) { - output = formatBytes(n, format, roundingFunction); - } else if (format.indexOf('o') > -1) { - output = formatOrdinal(n, format, roundingFunction); - } else if (format.indexOf('e+') > -1 || format.indexOf('e-') > -1) { - output = formatExponential(n, format, roundingFunction); + kind = format.match(/(\$|%|:|ib|b|o|e\+|e-)/); + + if (kind) { + switch (kind[0]) { + case '$': + formatFunction = formatCurrency; + break; + case '%': + formatFunction = formatPercentage; + break; + case ':': + formatFunction = formatTime; + break; + case 'b': + case 'ib': + formatFunction = formatBytes; + break; + case 'o': + formatFunction = formatOrdinal; + break; + case 'e+': + case 'e-': + formatFunction = formatExponential; + break; + } + + output = formatFunction(n, format, roundingFunction); } else { output = formatNumber(n._value, format, roundingFunction); } diff --git a/numeral.js b/numeral.js index 242b3d75..1f97a227 100644 --- a/numeral.js +++ b/numeral.js @@ -93,26 +93,42 @@ // determine what type of formatting we need to do function formatNumeral(n, format, roundingFunction) { - var output; + var output, + kind, + formatFunction; if (n._value === 0 && options.zeroFormat !== null) { output = options.zeroFormat; } else if (n._value === null && options.nullFormat !== null) { output = options.nullFormat; } else { - // figure out what kind of format we are dealing with - if (format.indexOf('$') > -1) { - output = formatCurrency(n, format, roundingFunction); - } else if (format.indexOf('%') > -1) { - output = formatPercentage(n, format, roundingFunction); - } else if (format.indexOf(':') > -1) { - output = formatTime(n, format); - } else if (format.indexOf('b') > -1 || format.indexOf('ib') > -1) { - output = formatBytes(n, format, roundingFunction); - } else if (format.indexOf('o') > -1) { - output = formatOrdinal(n, format, roundingFunction); - } else if (format.indexOf('e+') > -1 || format.indexOf('e-') > -1) { - output = formatExponential(n, format, roundingFunction); + kind = format.match(/(\$|%|:|ib|b|o|e\+|e-)/); + + if (kind) { + switch (kind[0]) { + case '$': + formatFunction = formatCurrency; + break; + case '%': + formatFunction = formatPercentage; + break; + case ':': + formatFunction = formatTime; + break; + case 'b': + case 'ib': + formatFunction = formatBytes; + break; + case 'o': + formatFunction = formatOrdinal; + break; + case 'e+': + case 'e-': + formatFunction = formatExponential; + break; + } + + output = formatFunction(n, format, roundingFunction); } else { output = formatNumber(n._value, format, roundingFunction); } From 8f4e2558d0426f06e7b0299549fb5a9757f08202 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Mon, 28 Nov 2016 22:58:40 -0800 Subject: [PATCH 078/150] lowercase all abbreviations --- min/numeral-with-locales.min.js | 2 +- min/numeral.min.js | 2 +- numeral-with-locales.js | 138 ++++++++++++++++---------------- numeral.js | 138 ++++++++++++++++---------------- tests/numeral/format.js | 11 +-- 5 files changed, 148 insertions(+), 143 deletions(-) diff --git a/min/numeral-with-locales.min.js b/min/numeral-with-locales.min.js index 4bde2b84..5df69400 100644 --- a/min/numeral-with-locales.min.js +++ b/min/numeral-with-locales.min.js @@ -5,7 +5,7 @@ * 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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m;if(0===a._value&&null!==u.zeroFormat)k=u.zeroFormat;else if(null===a._value&&null!==u.nullFormat)k=u.nullFormat;else if(l=b.match(/(\$|%|:|ib|b|o|e\+|e-)/)){switch(l[0]){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h}k=m(a,b,c)}else k=j(a._value,b,c);return k}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i="";return b.indexOf(" $")>-1?(i=" ",b=b.replace(" $","")):b.indexOf("$ ")>-1?(i=" ",b=b.replace("$ ","")):b=b.replace("$",""),e=j(a._value,b,c,!1),1>=f?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e="",f=100*a._value;return b.indexOf(" %")>-1?(e=" ",b=b.replace(" %","")):b=b.replace("%",""),d=j(f,b,c),d.indexOf(")")>-1?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.indexOf("ib")>-1?v.bytes.binary:v.bytes.decimal,i=a._value,k="";for(b.indexOf(" b")>-1||b.indexOf(" ib")>-1?(k=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===i||0===i||i>=f&&g>i){k+=h.suffixes[e],f>0&&(i/=f);break}return d=j(i,b,c),d+k}function g(a,b,c){var d,e="";return b.indexOf(" o")>-1?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=s[u.currentLocale].ordinal(a._value),d=j(a._value,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a._value||Number.isNaN(a._value)?"0e+0":a._value.toExponential(),f=e.split("e");return b=b.indexOf("e+")>-1?b.replace("e+0",""):b.replace("e-0",""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(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 j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r="",t=!1;return null===a&&(a=0),e=Math.abs(a),c.indexOf("(")>-1?(i=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(j=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(m=c.indexOf("aK")>=0,n=c.indexOf("aM")>=0,o=c.indexOf("aB")>=0,p=c.indexOf("aT")>=0,q=m||n||o||p,c.indexOf(" a")>-1&&(l=" "),c=c.replace(new RegExp(l+"a[KMBT]?"),""),e>=Math.pow(10,12)&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=Math.pow(10,12)):e=Math.pow(10,9)&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=Math.pow(10,9)):e=Math.pow(10,6)&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=Math.pow(10,6)):(e=Math.pow(10,3)&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("[.]")>-1&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.indexOf("[")>-1?(g=g.replace("]",""),g=g.split("["),r=b(a,g[0].length+g[1].length,d,g[1].length)):r=b(a,g.length,d),f=r.split(".")[0],r=r.indexOf(".")>-1?s[u.currentLocale].delimiters.decimal+r.split(".")[1]:"",k&&0===Number(r.slice(1))&&(r="")):f=b(a,null,d),f.indexOf("-")>-1&&(f=f.slice(1),t=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&t?"(":"")+(!i&&t?"-":"")+(!t&&j?"+":"")+f+r+(l?l:"")+(i&&t?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.indexOf(":")>-1)h=l(b);else if(b.indexOf("e+")>-1||b.indexOf("e-")>-1)h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.indexOf(v.bytes.decimal.suffixes[g])>-1||b.indexOf(v.bytes.binary.suffixes[g])>-1?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.indexOf("%")>-1?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.indexOf("e+")>-1?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.indexOf("e-")>-1?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.reset=function(){for(var a in t)u[a]=t[a]},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this),/*! @preserve +(function(){function a(a){this._value=a}function b(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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i="";return b.indexOf(" $")>-1?(i=" ",b=b.replace(" $","")):b.indexOf("$ ")>-1?(i=" ",b=b.replace("$ ","")):b=b.replace("$",""),e=j(a,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,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e="";return a=100*a,b.indexOf(" %")>-1?(e=" ",b=b.replace(" %","")):b=b.replace("%",""),d=j(a,b,c),d.indexOf(")")>-1?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.indexOf("ib")>-1?v.bytes.binary:v.bytes.decimal,i="";for(b.indexOf(" b")>-1||b.indexOf(" ib")>-1?(i=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e="";return b.indexOf(" o")>-1?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.indexOf("e+")>-1?b.replace("e+0",""):b.replace("e-0",""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r=1e12,t=1e9,v=1e6,w=1e3,x="",y=!1;return a=a||0,e=Math.abs(a),c.indexOf("(")>-1?(i=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(j=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(m=c.indexOf("ak")>-1,n=c.indexOf("am")>-1,o=c.indexOf("ab")>-1,p=c.indexOf("at")>-1,q=m||n||o||p,c.indexOf(" a")>-1&&(l=" "),c=c.replace(new RegExp(l+"a[kmbt]?"),""),e>=r&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=r):r>e&&e>=t&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=t):t>e&&e>=v&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=v):(v>e&&e>=w&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=w)),c.indexOf("[.]")>-1&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.indexOf("[")>-1?(g=g.replace("]",""),g=g.split("["),x=b(a,g[0].length+g[1].length,d,g[1].length)):x=b(a,g.length,d),f=x.split(".")[0],x=x.indexOf(".")>-1?s[u.currentLocale].delimiters.decimal+x.split(".")[1]:"",k&&0===Number(x.slice(1))&&(x="")):f=b(a,null,d),f.indexOf("-")>-1&&(f=f.slice(1),y=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&y?"(":"")+(!i&&y?"-":"")+(!y&&j?"+":"")+f+x+(l?l:"")+(i&&y?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.indexOf(":")>-1)h=l(b);else if(b.indexOf("e+")>-1||b.indexOf("e-")>-1)h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.indexOf(v.bytes.decimal.suffixes[g])>-1||b.indexOf(v.bytes.binary.suffixes[g])>-1?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.indexOf("%")>-1?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.indexOf("e+")>-1?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.indexOf("e-")>-1?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.reset=function(){for(var a in t)u[a]=t[a]},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this),/*! @preserve * numeral.js locale configuration * locale : belgium-dutch (be-nl) * author : Dieter Luypaert : https://github.com/moeriki diff --git a/min/numeral.min.js b/min/numeral.min.js index fcd62f7e..37efac31 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * 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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m;if(0===a._value&&null!==u.zeroFormat)k=u.zeroFormat;else if(null===a._value&&null!==u.nullFormat)k=u.nullFormat;else if(l=b.match(/(\$|%|:|ib|b|o|e\+|e-)/)){switch(l[0]){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h}k=m(a,b,c)}else k=j(a._value,b,c);return k}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i="";return b.indexOf(" $")>-1?(i=" ",b=b.replace(" $","")):b.indexOf("$ ")>-1?(i=" ",b=b.replace("$ ","")):b=b.replace("$",""),e=j(a._value,b,c,!1),1>=f?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e="",f=100*a._value;return b.indexOf(" %")>-1?(e=" ",b=b.replace(" %","")):b=b.replace("%",""),d=j(f,b,c),d.indexOf(")")>-1?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.indexOf("ib")>-1?v.bytes.binary:v.bytes.decimal,i=a._value,k="";for(b.indexOf(" b")>-1||b.indexOf(" ib")>-1?(k=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===i||0===i||i>=f&&g>i){k+=h.suffixes[e],f>0&&(i/=f);break}return d=j(i,b,c),d+k}function g(a,b,c){var d,e="";return b.indexOf(" o")>-1?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=s[u.currentLocale].ordinal(a._value),d=j(a._value,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a._value||Number.isNaN(a._value)?"0e+0":a._value.toExponential(),f=e.split("e");return b=b.indexOf("e+")>-1?b.replace("e+0",""):b.replace("e-0",""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(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 j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r="",t=!1;return null===a&&(a=0),e=Math.abs(a),c.indexOf("(")>-1?(i=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(j=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(m=c.indexOf("aK")>=0,n=c.indexOf("aM")>=0,o=c.indexOf("aB")>=0,p=c.indexOf("aT")>=0,q=m||n||o||p,c.indexOf(" a")>-1&&(l=" "),c=c.replace(new RegExp(l+"a[KMBT]?"),""),e>=Math.pow(10,12)&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=Math.pow(10,12)):e=Math.pow(10,9)&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=Math.pow(10,9)):e=Math.pow(10,6)&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=Math.pow(10,6)):(e=Math.pow(10,3)&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("[.]")>-1&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.indexOf("[")>-1?(g=g.replace("]",""),g=g.split("["),r=b(a,g[0].length+g[1].length,d,g[1].length)):r=b(a,g.length,d),f=r.split(".")[0],r=r.indexOf(".")>-1?s[u.currentLocale].delimiters.decimal+r.split(".")[1]:"",k&&0===Number(r.slice(1))&&(r="")):f=b(a,null,d),f.indexOf("-")>-1&&(f=f.slice(1),t=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&t?"(":"")+(!i&&t?"-":"")+(!t&&j?"+":"")+f+r+(l?l:"")+(i&&t?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.indexOf(":")>-1)h=l(b);else if(b.indexOf("e+")>-1||b.indexOf("e-")>-1)h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.indexOf(v.bytes.decimal.suffixes[g])>-1||b.indexOf(v.bytes.binary.suffixes[g])>-1?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.indexOf("%")>-1?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.indexOf("e+")>-1?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.indexOf("e-")>-1?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.reset=function(){for(var a in t)u[a]=t[a]},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this); \ No newline at end of file +(function(){function a(a){this._value=a}function b(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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i="";return b.indexOf(" $")>-1?(i=" ",b=b.replace(" $","")):b.indexOf("$ ")>-1?(i=" ",b=b.replace("$ ","")):b=b.replace("$",""),e=j(a,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,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e="";return a=100*a,b.indexOf(" %")>-1?(e=" ",b=b.replace(" %","")):b=b.replace("%",""),d=j(a,b,c),d.indexOf(")")>-1?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.indexOf("ib")>-1?v.bytes.binary:v.bytes.decimal,i="";for(b.indexOf(" b")>-1||b.indexOf(" ib")>-1?(i=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e="";return b.indexOf(" o")>-1?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.indexOf("e+")>-1?b.replace("e+0",""):b.replace("e-0",""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r=1e12,t=1e9,v=1e6,w=1e3,x="",y=!1;return a=a||0,e=Math.abs(a),c.indexOf("(")>-1?(i=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(j=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(m=c.indexOf("ak")>-1,n=c.indexOf("am")>-1,o=c.indexOf("ab")>-1,p=c.indexOf("at")>-1,q=m||n||o||p,c.indexOf(" a")>-1&&(l=" "),c=c.replace(new RegExp(l+"a[kmbt]?"),""),e>=r&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=r):r>e&&e>=t&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=t):t>e&&e>=v&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=v):(v>e&&e>=w&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=w)),c.indexOf("[.]")>-1&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.indexOf("[")>-1?(g=g.replace("]",""),g=g.split("["),x=b(a,g[0].length+g[1].length,d,g[1].length)):x=b(a,g.length,d),f=x.split(".")[0],x=x.indexOf(".")>-1?s[u.currentLocale].delimiters.decimal+x.split(".")[1]:"",k&&0===Number(x.slice(1))&&(x="")):f=b(a,null,d),f.indexOf("-")>-1&&(f=f.slice(1),y=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&y?"(":"")+(!i&&y?"-":"")+(!y&&j?"+":"")+f+x+(l?l:"")+(i&&y?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.indexOf(":")>-1)h=l(b);else if(b.indexOf("e+")>-1||b.indexOf("e-")>-1)h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.indexOf(v.bytes.decimal.suffixes[g])>-1||b.indexOf(v.bytes.binary.suffixes[g])>-1?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.indexOf("%")>-1?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.indexOf("e+")>-1?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.indexOf("e-")>-1?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.reset=function(){for(var a in t)u[a]=t[a]},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this); \ No newline at end of file diff --git a/numeral-with-locales.js b/numeral-with-locales.js index 4f8444dc..1c29484c 100644 --- a/numeral-with-locales.js +++ b/numeral-with-locales.js @@ -93,51 +93,50 @@ // determine what type of formatting we need to do function formatNumeral(n, format, roundingFunction) { - var output, + var value = n._value, kind, + output, formatFunction; - if (n._value === 0 && options.zeroFormat !== null) { + if (value === 0 && options.zeroFormat !== null) { output = options.zeroFormat; - } else if (n._value === null && options.nullFormat !== null) { + } else if (value === null && options.nullFormat !== null) { output = options.nullFormat; } else { - kind = format.match(/(\$|%|:|ib|b|o|e\+|e-)/); - - if (kind) { - switch (kind[0]) { - case '$': - formatFunction = formatCurrency; - break; - case '%': - formatFunction = formatPercentage; - break; - case ':': - formatFunction = formatTime; - break; - case 'b': - case 'ib': - formatFunction = formatBytes; - break; - case 'o': - formatFunction = formatOrdinal; - break; - case 'e+': - case 'e-': - formatFunction = formatExponential; - break; - } - - output = formatFunction(n, format, roundingFunction); - } else { - output = formatNumber(n._value, format, roundingFunction); + kind = format.match(/(\$|%|:|[ai]?b|o|e\+|e-)/); + + switch (kind ? kind[0] : '') { + case '$': + formatFunction = formatCurrency; + break; + case '%': + formatFunction = formatPercentage; + break; + case ':': + formatFunction = formatTime; + break; + case 'b': + case 'ib': + formatFunction = formatBytes; + break; + case 'o': + formatFunction = formatOrdinal; + break; + case 'e+': + case 'e-': + formatFunction = formatExponential; + break; + default: + formatFunction = formatNumber; } + + output = formatFunction(value, format, roundingFunction); } return output; } - function formatCurrency(n, format, roundingFunction) { + function formatCurrency(value, format, roundingFunction) { var symbolIndex = format.indexOf('$'), openParenIndex = format.indexOf('('), minusSignIndex = format.indexOf('-'), @@ -157,7 +156,7 @@ } // format the number - output = formatNumber(n._value, format, roundingFunction, false); + output = formatNumber(value, format, roundingFunction); // position the symbol if (symbolIndex <= 1) { @@ -186,10 +185,11 @@ return output; } - function formatPercentage(n, format, roundingFunction) { + function formatPercentage(value, format, roundingFunction) { var space = '', - output, - value = n._value * 100; + output; + + value = value * 100; // check for space before % if (format.indexOf(' %') > -1) { @@ -212,10 +212,9 @@ return output; } - function formatBytes(n, format, roundingFunction) { + function formatBytes(value, format, roundingFunction) { var output, bytes = format.indexOf('ib') > -1 ? config.bytes.binary : config.bytes.decimal, - value = n._value, suffix = '', power, min, @@ -249,7 +248,7 @@ return output + suffix; } - function formatOrdinal(n, format, roundingFunction) { + function formatOrdinal(value, format, roundingFunction) { var output, ordinal = ''; @@ -261,16 +260,16 @@ format = format.replace('o', ''); } - ordinal += locales[options.currentLocale].ordinal(n._value); + ordinal += locales[options.currentLocale].ordinal(value); - output = formatNumber(n._value, format, roundingFunction); + output = formatNumber(value, format, roundingFunction); return output + ordinal; } - function formatExponential(n, format, roundingFunction) { + function formatExponential(value, format, roundingFunction) { var output, - exponential = typeof n._value === 'number' && !Number.isNaN(n._value) ? n._value.toExponential() : '0e+0', + exponential = typeof value === 'number' && !Number.isNaN(value) ? value.toExponential() : '0e+0', parts = exponential.split('e'); format = format.indexOf('e+') > -1 ? format.replace('e+0', '') : format.replace('e-0', ''); @@ -280,10 +279,10 @@ return output + 'e' + parts[1]; } - 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)); + function formatTime(value) { + 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); } @@ -298,6 +297,10 @@ abbrB = false, // force abbreviation to billions abbrT = false, // force abbreviation to trillions abbrForce = false, // force abbreviation + trillion = 1000000000000, + billion = 1000000000, + million = 1000000, + thousand = 1000, abs, min, max, @@ -308,9 +311,8 @@ d = '', neg = false; - if (value === null) { - value = 0; - } + // make sure we never format a null value + value = value || 0; abs = Math.abs(value); @@ -327,10 +329,10 @@ // 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; + abbrK = format.indexOf('ak') > -1; + abbrM = format.indexOf('am') > -1; + abbrB = format.indexOf('ab') > -1; + abbrT = format.indexOf('at') > -1; abbrForce = abbrK || abbrM || abbrB || abbrT; // check for space before abbreviation @@ -338,24 +340,24 @@ abbr = ' '; } - format = format.replace(new RegExp(abbr + 'a[KMBT]?'), ''); + format = format.replace(new RegExp(abbr + 'a[kmbt]?'), ''); - if (abs >= Math.pow(10, 12) && !abbrForce || abbrT) { + if (abs >= trillion && !abbrForce || abbrT) { // trillion - abbr = abbr + locales[options.currentLocale].abbreviations.trillion; - value = value / Math.pow(10, 12); - } else if (abs < Math.pow(10, 12) && abs >= Math.pow(10, 9) && !abbrForce || abbrB) { + abbr += locales[options.currentLocale].abbreviations.trillion; + value = value / trillion; + } else if (abs < trillion && abs >= billion && !abbrForce || abbrB) { // billion - abbr = abbr + locales[options.currentLocale].abbreviations.billion; - value = value / Math.pow(10, 9); - } else if (abs < Math.pow(10, 9) && abs >= Math.pow(10, 6) && !abbrForce || abbrM) { + abbr += locales[options.currentLocale].abbreviations.billion; + value = value / billion; + } else if (abs < billion && abs >= million && !abbrForce || abbrM) { // million - abbr = abbr + locales[options.currentLocale].abbreviations.million; - value = value / Math.pow(10, 6); - } else if (abs < Math.pow(10, 6) && abs >= Math.pow(10, 3) && !abbrForce || abbrK) { + abbr += locales[options.currentLocale].abbreviations.million; + value = value / million; + } else if (abs < million && abs >= thousand && !abbrForce || abbrK) { // thousand - abbr = abbr + locales[options.currentLocale].abbreviations.thousand; - value = value / Math.pow(10, 3); + abbr += locales[options.currentLocale].abbreviations.thousand; + value = value / thousand; } } diff --git a/numeral.js b/numeral.js index 1f97a227..06d5963b 100644 --- a/numeral.js +++ b/numeral.js @@ -93,51 +93,50 @@ // determine what type of formatting we need to do function formatNumeral(n, format, roundingFunction) { - var output, + var value = n._value, kind, + output, formatFunction; - if (n._value === 0 && options.zeroFormat !== null) { + if (value === 0 && options.zeroFormat !== null) { output = options.zeroFormat; - } else if (n._value === null && options.nullFormat !== null) { + } else if (value === null && options.nullFormat !== null) { output = options.nullFormat; } else { - kind = format.match(/(\$|%|:|ib|b|o|e\+|e-)/); - - if (kind) { - switch (kind[0]) { - case '$': - formatFunction = formatCurrency; - break; - case '%': - formatFunction = formatPercentage; - break; - case ':': - formatFunction = formatTime; - break; - case 'b': - case 'ib': - formatFunction = formatBytes; - break; - case 'o': - formatFunction = formatOrdinal; - break; - case 'e+': - case 'e-': - formatFunction = formatExponential; - break; - } - - output = formatFunction(n, format, roundingFunction); - } else { - output = formatNumber(n._value, format, roundingFunction); + kind = format.match(/(\$|%|:|[ai]?b|o|e\+|e-)/); + + switch (kind ? kind[0] : '') { + case '$': + formatFunction = formatCurrency; + break; + case '%': + formatFunction = formatPercentage; + break; + case ':': + formatFunction = formatTime; + break; + case 'b': + case 'ib': + formatFunction = formatBytes; + break; + case 'o': + formatFunction = formatOrdinal; + break; + case 'e+': + case 'e-': + formatFunction = formatExponential; + break; + default: + formatFunction = formatNumber; } + + output = formatFunction(value, format, roundingFunction); } return output; } - function formatCurrency(n, format, roundingFunction) { + function formatCurrency(value, format, roundingFunction) { var symbolIndex = format.indexOf('$'), openParenIndex = format.indexOf('('), minusSignIndex = format.indexOf('-'), @@ -157,7 +156,7 @@ } // format the number - output = formatNumber(n._value, format, roundingFunction, false); + output = formatNumber(value, format, roundingFunction); // position the symbol if (symbolIndex <= 1) { @@ -186,10 +185,11 @@ return output; } - function formatPercentage(n, format, roundingFunction) { + function formatPercentage(value, format, roundingFunction) { var space = '', - output, - value = n._value * 100; + output; + + value = value * 100; // check for space before % if (format.indexOf(' %') > -1) { @@ -212,10 +212,9 @@ return output; } - function formatBytes(n, format, roundingFunction) { + function formatBytes(value, format, roundingFunction) { var output, bytes = format.indexOf('ib') > -1 ? config.bytes.binary : config.bytes.decimal, - value = n._value, suffix = '', power, min, @@ -249,7 +248,7 @@ return output + suffix; } - function formatOrdinal(n, format, roundingFunction) { + function formatOrdinal(value, format, roundingFunction) { var output, ordinal = ''; @@ -261,16 +260,16 @@ format = format.replace('o', ''); } - ordinal += locales[options.currentLocale].ordinal(n._value); + ordinal += locales[options.currentLocale].ordinal(value); - output = formatNumber(n._value, format, roundingFunction); + output = formatNumber(value, format, roundingFunction); return output + ordinal; } - function formatExponential(n, format, roundingFunction) { + function formatExponential(value, format, roundingFunction) { var output, - exponential = typeof n._value === 'number' && !Number.isNaN(n._value) ? n._value.toExponential() : '0e+0', + exponential = typeof value === 'number' && !Number.isNaN(value) ? value.toExponential() : '0e+0', parts = exponential.split('e'); format = format.indexOf('e+') > -1 ? format.replace('e+0', '') : format.replace('e-0', ''); @@ -280,10 +279,10 @@ return output + 'e' + parts[1]; } - 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)); + function formatTime(value) { + 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); } @@ -298,6 +297,10 @@ abbrB = false, // force abbreviation to billions abbrT = false, // force abbreviation to trillions abbrForce = false, // force abbreviation + trillion = 1000000000000, + billion = 1000000000, + million = 1000000, + thousand = 1000, abs, min, max, @@ -308,9 +311,8 @@ d = '', neg = false; - if (value === null) { - value = 0; - } + // make sure we never format a null value + value = value || 0; abs = Math.abs(value); @@ -327,10 +329,10 @@ // 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; + abbrK = format.indexOf('ak') > -1; + abbrM = format.indexOf('am') > -1; + abbrB = format.indexOf('ab') > -1; + abbrT = format.indexOf('at') > -1; abbrForce = abbrK || abbrM || abbrB || abbrT; // check for space before abbreviation @@ -338,24 +340,24 @@ abbr = ' '; } - format = format.replace(new RegExp(abbr + 'a[KMBT]?'), ''); + format = format.replace(new RegExp(abbr + 'a[kmbt]?'), ''); - if (abs >= Math.pow(10, 12) && !abbrForce || abbrT) { + if (abs >= trillion && !abbrForce || abbrT) { // trillion - abbr = abbr + locales[options.currentLocale].abbreviations.trillion; - value = value / Math.pow(10, 12); - } else if (abs < Math.pow(10, 12) && abs >= Math.pow(10, 9) && !abbrForce || abbrB) { + abbr += locales[options.currentLocale].abbreviations.trillion; + value = value / trillion; + } else if (abs < trillion && abs >= billion && !abbrForce || abbrB) { // billion - abbr = abbr + locales[options.currentLocale].abbreviations.billion; - value = value / Math.pow(10, 9); - } else if (abs < Math.pow(10, 9) && abs >= Math.pow(10, 6) && !abbrForce || abbrM) { + abbr += locales[options.currentLocale].abbreviations.billion; + value = value / billion; + } else if (abs < billion && abs >= million && !abbrForce || abbrM) { // million - abbr = abbr + locales[options.currentLocale].abbreviations.million; - value = value / Math.pow(10, 6); - } else if (abs < Math.pow(10, 6) && abs >= Math.pow(10, 3) && !abbrForce || abbrK) { + abbr += locales[options.currentLocale].abbreviations.million; + value = value / million; + } else if (abs < million && abs >= thousand && !abbrForce || abbrK) { // thousand - abbr = abbr + locales[options.currentLocale].abbreviations.thousand; - value = value / Math.pow(10, 3); + abbr += locales[options.currentLocale].abbreviations.thousand; + value = value / thousand; } } diff --git a/tests/numeral/format.js b/tests/numeral/format.js index c9c48b78..6f66dd96 100644 --- a/tests/numeral/format.js +++ b/tests/numeral/format.js @@ -63,11 +63,12 @@ describe('Format', function() { [1460,'0a','1k'], [-104000,'0 a','-104 k'], // 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'] + [-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, From bc6cd6608117a64f2d1779aa842580e9d9dade37 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Mon, 28 Nov 2016 23:09:37 -0800 Subject: [PATCH 079/150] includes polyfill --- min/numeral-with-locales.min.js | 2 +- min/numeral.min.js | 2 +- numeral-with-locales.js | 63 ++++++++++++++++++--------------- numeral.js | 63 ++++++++++++++++++--------------- 4 files changed, 72 insertions(+), 58 deletions(-) diff --git a/min/numeral-with-locales.min.js b/min/numeral-with-locales.min.js index 5df69400..c60a0f73 100644 --- a/min/numeral-with-locales.min.js +++ b/min/numeral-with-locales.min.js @@ -5,7 +5,7 @@ * 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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i="";return b.indexOf(" $")>-1?(i=" ",b=b.replace(" $","")):b.indexOf("$ ")>-1?(i=" ",b=b.replace("$ ","")):b=b.replace("$",""),e=j(a,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,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e="";return a=100*a,b.indexOf(" %")>-1?(e=" ",b=b.replace(" %","")):b=b.replace("%",""),d=j(a,b,c),d.indexOf(")")>-1?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.indexOf("ib")>-1?v.bytes.binary:v.bytes.decimal,i="";for(b.indexOf(" b")>-1||b.indexOf(" ib")>-1?(i=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e="";return b.indexOf(" o")>-1?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.indexOf("e+")>-1?b.replace("e+0",""):b.replace("e-0",""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r=1e12,t=1e9,v=1e6,w=1e3,x="",y=!1;return a=a||0,e=Math.abs(a),c.indexOf("(")>-1?(i=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(j=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(m=c.indexOf("ak")>-1,n=c.indexOf("am")>-1,o=c.indexOf("ab")>-1,p=c.indexOf("at")>-1,q=m||n||o||p,c.indexOf(" a")>-1&&(l=" "),c=c.replace(new RegExp(l+"a[kmbt]?"),""),e>=r&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=r):r>e&&e>=t&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=t):t>e&&e>=v&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=v):(v>e&&e>=w&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=w)),c.indexOf("[.]")>-1&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.indexOf("[")>-1?(g=g.replace("]",""),g=g.split("["),x=b(a,g[0].length+g[1].length,d,g[1].length)):x=b(a,g.length,d),f=x.split(".")[0],x=x.indexOf(".")>-1?s[u.currentLocale].delimiters.decimal+x.split(".")[1]:"",k&&0===Number(x.slice(1))&&(x="")):f=b(a,null,d),f.indexOf("-")>-1&&(f=f.slice(1),y=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&y?"(":"")+(!i&&y?"-":"")+(!y&&j?"+":"")+f+x+(l?l:"")+(i&&y?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.indexOf(":")>-1)h=l(b);else if(b.indexOf("e+")>-1||b.indexOf("e-")>-1)h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.indexOf(v.bytes.decimal.suffixes[g])>-1||b.indexOf(v.bytes.binary.suffixes[g])>-1?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.indexOf("%")>-1?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.indexOf("e+")>-1?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.indexOf("e-")>-1?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.reset=function(){for(var a in t)u[a]=t[a]},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this),/*! @preserve +(function(){function a(a){this._value=a}function b(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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i="";return b.includes(" $")?(i=" ",b=b.replace(" $","")):b.includes("$ ")?(i=" ",b=b.replace("$ ","")):b=b.replace("$",""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e="";return a=100*a,b.includes(" %")?(e=" ",b=b.replace(" %","")):b=b.replace("%",""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i="";for(b.includes(" b")||b.includes(" ib")?(i=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e="";return b.includes(" o")?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.includes("e+")?b.replace("e+0",""):b.replace("e-0",""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r=1e12,t=1e9,v=1e6,w=1e3,x="",y=!1;return a=a||0,e=Math.abs(a),c.includes("(")?(i=!0,c=c.slice(1,-1)):c.includes("+")&&(j=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(m=c.includes("ak"),n=c.includes("am"),o=c.includes("ab"),p=c.includes("at"),q=m||n||o||p,c.includes(" a")&&(l=" "),c=c.replace(new RegExp(l+"a[kmbt]?"),""),e>=r&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=r):r>e&&e>=t&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=t):t>e&&e>=v&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=v):(v>e&&e>=w&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=w)),c.includes("[.]")&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.includes("[")?(g=g.replace("]",""),g=g.split("["),x=b(a,g[0].length+g[1].length,d,g[1].length)):x=b(a,g.length,d),f=x.split(".")[0],x=x.includes(".")?s[u.currentLocale].delimiters.decimal+x.split(".")[1]:"",k&&0===Number(x.slice(1))&&(x="")):f=b(a,null,d),f.includes("-")&&(f=f.slice(1),y=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&y?"(":"")+(!i&&y?"-":"")+(!y&&j?"+":"")+f+x+(l?l:"")+(i&&y?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.reset=function(){for(var a in t)u[a]=t[a]},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes||(String.prototype.includes=function(a,b){return-1!==this.indexOf(a,b)}),Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this),/*! @preserve * numeral.js locale configuration * locale : belgium-dutch (be-nl) * author : Dieter Luypaert : https://github.com/moeriki diff --git a/min/numeral.min.js b/min/numeral.min.js index 37efac31..31d84f45 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * 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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i="";return b.indexOf(" $")>-1?(i=" ",b=b.replace(" $","")):b.indexOf("$ ")>-1?(i=" ",b=b.replace("$ ","")):b=b.replace("$",""),e=j(a,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,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e="";return a=100*a,b.indexOf(" %")>-1?(e=" ",b=b.replace(" %","")):b=b.replace("%",""),d=j(a,b,c),d.indexOf(")")>-1?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.indexOf("ib")>-1?v.bytes.binary:v.bytes.decimal,i="";for(b.indexOf(" b")>-1||b.indexOf(" ib")>-1?(i=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e="";return b.indexOf(" o")>-1?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.indexOf("e+")>-1?b.replace("e+0",""):b.replace("e-0",""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r=1e12,t=1e9,v=1e6,w=1e3,x="",y=!1;return a=a||0,e=Math.abs(a),c.indexOf("(")>-1?(i=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(j=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(m=c.indexOf("ak")>-1,n=c.indexOf("am")>-1,o=c.indexOf("ab")>-1,p=c.indexOf("at")>-1,q=m||n||o||p,c.indexOf(" a")>-1&&(l=" "),c=c.replace(new RegExp(l+"a[kmbt]?"),""),e>=r&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=r):r>e&&e>=t&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=t):t>e&&e>=v&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=v):(v>e&&e>=w&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=w)),c.indexOf("[.]")>-1&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.indexOf("[")>-1?(g=g.replace("]",""),g=g.split("["),x=b(a,g[0].length+g[1].length,d,g[1].length)):x=b(a,g.length,d),f=x.split(".")[0],x=x.indexOf(".")>-1?s[u.currentLocale].delimiters.decimal+x.split(".")[1]:"",k&&0===Number(x.slice(1))&&(x="")):f=b(a,null,d),f.indexOf("-")>-1&&(f=f.slice(1),y=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&y?"(":"")+(!i&&y?"-":"")+(!y&&j?"+":"")+f+x+(l?l:"")+(i&&y?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.indexOf(":")>-1)h=l(b);else if(b.indexOf("e+")>-1||b.indexOf("e-")>-1)h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.indexOf(v.bytes.decimal.suffixes[g])>-1||b.indexOf(v.bytes.binary.suffixes[g])>-1?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.indexOf("%")>-1?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.indexOf("e+")>-1?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.indexOf("e-")>-1?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.reset=function(){for(var a in t)u[a]=t[a]},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this); \ No newline at end of file +(function(){function a(a){this._value=a}function b(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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i="";return b.includes(" $")?(i=" ",b=b.replace(" $","")):b.includes("$ ")?(i=" ",b=b.replace("$ ","")):b=b.replace("$",""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e="";return a=100*a,b.includes(" %")?(e=" ",b=b.replace(" %","")):b=b.replace("%",""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i="";for(b.includes(" b")||b.includes(" ib")?(i=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e="";return b.includes(" o")?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.includes("e+")?b.replace("e+0",""):b.replace("e-0",""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r=1e12,t=1e9,v=1e6,w=1e3,x="",y=!1;return a=a||0,e=Math.abs(a),c.includes("(")?(i=!0,c=c.slice(1,-1)):c.includes("+")&&(j=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(m=c.includes("ak"),n=c.includes("am"),o=c.includes("ab"),p=c.includes("at"),q=m||n||o||p,c.includes(" a")&&(l=" "),c=c.replace(new RegExp(l+"a[kmbt]?"),""),e>=r&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=r):r>e&&e>=t&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=t):t>e&&e>=v&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=v):(v>e&&e>=w&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=w)),c.includes("[.]")&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.includes("[")?(g=g.replace("]",""),g=g.split("["),x=b(a,g[0].length+g[1].length,d,g[1].length)):x=b(a,g.length,d),f=x.split(".")[0],x=x.includes(".")?s[u.currentLocale].delimiters.decimal+x.split(".")[1]:"",k&&0===Number(x.slice(1))&&(x="")):f=b(a,null,d),f.includes("-")&&(f=f.slice(1),y=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&y?"(":"")+(!i&&y?"-":"")+(!y&&j?"+":"")+f+x+(l?l:"")+(i&&y?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.reset=function(){for(var a in t)u[a]=t[a]},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes||(String.prototype.includes=function(a,b){return-1!==this.indexOf(a,b)}),Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this); \ No newline at end of file diff --git a/numeral-with-locales.js b/numeral-with-locales.js index 1c29484c..314bbd23 100644 --- a/numeral-with-locales.js +++ b/numeral-with-locales.js @@ -145,10 +145,10 @@ output; // check for space before or after currency - if (format.indexOf(' $') > -1) { + if (format.includes(' $')) { space = ' '; format = format.replace(' $', ''); - } else if (format.indexOf('$ ') > -1) { + } else if (format.includes('$ ')) { space = ' '; format = format.replace('$ ', ''); } else { @@ -160,7 +160,7 @@ // position the symbol if (symbolIndex <= 1) { - if (output.indexOf('(') > -1 || output.indexOf('-') > -1) { + if (output.includes('(') || output.includes('-')) { output = output.split(''); spliceIndex = 1; if (symbolIndex < openParenIndex || symbolIndex < minusSignIndex) { @@ -173,7 +173,7 @@ output = locales[options.currentLocale].currency.symbol + space + output; } } else { - if (output.indexOf(')') > -1) { + if (output.includes(')')) { output = output.split(''); output.splice(-1, 0, space + locales[options.currentLocale].currency.symbol); output = output.join(''); @@ -192,7 +192,7 @@ value = value * 100; // check for space before % - if (format.indexOf(' %') > -1) { + if (format.includes(' %')) { space = ' '; format = format.replace(' %', ''); } else { @@ -201,7 +201,7 @@ output = formatNumber(value, format, roundingFunction); - if (output.indexOf(')') > -1) { + if (output.includes(')')) { output = output.split(''); output.splice(-1, 0, space + '%'); output = output.join(''); @@ -214,14 +214,14 @@ function formatBytes(value, format, roundingFunction) { var output, - bytes = format.indexOf('ib') > -1 ? config.bytes.binary : config.bytes.decimal, + bytes = format.includes('ib') ? config.bytes.binary : config.bytes.decimal, suffix = '', power, min, max; // check for space before - if (format.indexOf(' b') > -1 || format.indexOf(' ib') > -1) { + if (format.includes(' b') || format.includes(' ib')) { suffix = ' '; format = format.replace(' ib', '').replace(' b', ''); } else { @@ -253,7 +253,7 @@ ordinal = ''; // check for space before - if (format.indexOf(' o') > -1) { + if (format.includes(' o')) { ordinal = ' '; format = format.replace(' o', ''); } else { @@ -272,7 +272,7 @@ exponential = typeof value === 'number' && !Number.isNaN(value) ? value.toExponential() : '0e+0', parts = exponential.split('e'); - format = format.indexOf('e+') > -1 ? format.replace('e+0', '') : format.replace('e-0', ''); + format = format.includes('e+') ? format.replace('e+0', '') : format.replace('e-0', ''); output = formatNumber(Number(parts[0]), format, roundingFunction); @@ -318,25 +318,25 @@ // 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 (format.includes('(')) { negP = true; format = format.slice(1, -1); - } else if (format.indexOf('+') > -1) { + } else if (format.includes('+')) { signed = true; format = format.replace(/\+/g, ''); } // see if abbreviation is wanted - if (format.indexOf('a') > -1) { + if (format.includes('a')) { // check if abbreviation is specified - abbrK = format.indexOf('ak') > -1; - abbrM = format.indexOf('am') > -1; - abbrB = format.indexOf('ab') > -1; - abbrT = format.indexOf('at') > -1; + abbrK = format.includes('ak'); + abbrM = format.includes('am'); + abbrB = format.includes('ab'); + abbrT = format.includes('at'); abbrForce = abbrK || abbrM || abbrB || abbrT; // check for space before abbreviation - if (format.indexOf(' a') > -1) { + if (format.includes(' a')) { abbr = ' '; } @@ -362,7 +362,7 @@ } - if (format.indexOf('[.]') > -1) { + if (format.includes('[.]')) { optDec = true; format = format.replace('[.]', '.'); } @@ -372,7 +372,7 @@ thousands = format.indexOf(','); if (precision) { - if (precision.indexOf('[') > -1) { + if (precision.includes('[')) { precision = precision.replace(']', ''); precision = precision.split('['); d = toFixed(value, (precision[0].length + precision[1].length), roundingFunction, precision[1].length); @@ -382,7 +382,7 @@ w = d.split('.')[0]; - if (d.indexOf('.') > -1) { + if (d.includes('.')) { d = locales[options.currentLocale].delimiters.decimal + d.split('.')[1]; } else { d = ''; @@ -396,7 +396,7 @@ } // format number - if (w.indexOf('-') > -1) { + if (w.includes('-')) { w = w.slice(1); neg = true; } @@ -428,9 +428,9 @@ power, value; - if (string.indexOf(':') > -1) { + if (string.includes(':')) { value = unformatTime(string); - } else if (string.indexOf('e+') > -1 || string.indexOf('e-') > -1) { + } else if (string.includes('e+') || string.includes('e-')) { value = unformatExponential(string); } else { if (string === options.zeroFormat || string === options.nullFormat) { @@ -448,7 +448,7 @@ // see if bytes are there so that we can multiply to the correct number for (power = 1; power <= config.bytes.decimal.suffixes.length; power++) { - bytesMultiplier = ((string.indexOf(config.bytes.decimal.suffixes[power]) > -1) || (string.indexOf(config.bytes.binary.suffixes[power]) > -1))? Math.pow(1024, power) : false; + bytesMultiplier = ((string.includes(config.bytes.decimal.suffixes[power])) || (string.includes(config.bytes.binary.suffixes[power])))? Math.pow(1024, power) : false; if (bytesMultiplier) { break; @@ -462,7 +462,7 @@ value *= stringOriginal.match(billionRegExp) ? Math.pow(10, 9) : 1; value *= stringOriginal.match(trillionRegExp) ? Math.pow(10, 12) : 1; // check for percentage - value *= string.indexOf('%') > -1 ? 0.01 : 1; + value *= string.includes('%') ? 0.01 : 1; // check for negative number value *= (string.split('-').length + Math.min(string.split('(').length - 1, string.split(')').length - 1)) % 2 ? 1 : -1; // remove non numbers @@ -498,11 +498,11 @@ } function unformatExponential(string) { - var parts = string.indexOf('e+') > -1 ? string.split('e+') : string.split('e-'), + var parts = string.includes('e+') ? string.split('e+') : string.split('e-'), value = Number(parts[0]), power = Number(parts[1]); - power = string.indexOf('e-') > -1 ? power *= -1 : power; + power = string.includes('e-') ? power *= -1 : power; function cback(accum, curr, currI, O) { var corrFactor = correctionFactor(accum, curr), @@ -729,6 +729,13 @@ return typeof value === 'number' && isNaN(value); }; + // String includes polyfill + if (!String.prototype.includes) { + String.prototype.includes = function(search, start) { + return this.indexOf(search, start) !== -1; + }; + } + // Production steps of ECMA-262, Edition 5, 15.4.4.21 // Reference: http://es5.github.io/#x15.4.4.21 if (!Array.prototype.reduce) { diff --git a/numeral.js b/numeral.js index 06d5963b..fb2b8853 100644 --- a/numeral.js +++ b/numeral.js @@ -145,10 +145,10 @@ output; // check for space before or after currency - if (format.indexOf(' $') > -1) { + if (format.includes(' $')) { space = ' '; format = format.replace(' $', ''); - } else if (format.indexOf('$ ') > -1) { + } else if (format.includes('$ ')) { space = ' '; format = format.replace('$ ', ''); } else { @@ -160,7 +160,7 @@ // position the symbol if (symbolIndex <= 1) { - if (output.indexOf('(') > -1 || output.indexOf('-') > -1) { + if (output.includes('(') || output.includes('-')) { output = output.split(''); spliceIndex = 1; if (symbolIndex < openParenIndex || symbolIndex < minusSignIndex) { @@ -173,7 +173,7 @@ output = locales[options.currentLocale].currency.symbol + space + output; } } else { - if (output.indexOf(')') > -1) { + if (output.includes(')')) { output = output.split(''); output.splice(-1, 0, space + locales[options.currentLocale].currency.symbol); output = output.join(''); @@ -192,7 +192,7 @@ value = value * 100; // check for space before % - if (format.indexOf(' %') > -1) { + if (format.includes(' %')) { space = ' '; format = format.replace(' %', ''); } else { @@ -201,7 +201,7 @@ output = formatNumber(value, format, roundingFunction); - if (output.indexOf(')') > -1) { + if (output.includes(')')) { output = output.split(''); output.splice(-1, 0, space + '%'); output = output.join(''); @@ -214,14 +214,14 @@ function formatBytes(value, format, roundingFunction) { var output, - bytes = format.indexOf('ib') > -1 ? config.bytes.binary : config.bytes.decimal, + bytes = format.includes('ib') ? config.bytes.binary : config.bytes.decimal, suffix = '', power, min, max; // check for space before - if (format.indexOf(' b') > -1 || format.indexOf(' ib') > -1) { + if (format.includes(' b') || format.includes(' ib')) { suffix = ' '; format = format.replace(' ib', '').replace(' b', ''); } else { @@ -253,7 +253,7 @@ ordinal = ''; // check for space before - if (format.indexOf(' o') > -1) { + if (format.includes(' o')) { ordinal = ' '; format = format.replace(' o', ''); } else { @@ -272,7 +272,7 @@ exponential = typeof value === 'number' && !Number.isNaN(value) ? value.toExponential() : '0e+0', parts = exponential.split('e'); - format = format.indexOf('e+') > -1 ? format.replace('e+0', '') : format.replace('e-0', ''); + format = format.includes('e+') ? format.replace('e+0', '') : format.replace('e-0', ''); output = formatNumber(Number(parts[0]), format, roundingFunction); @@ -318,25 +318,25 @@ // 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 (format.includes('(')) { negP = true; format = format.slice(1, -1); - } else if (format.indexOf('+') > -1) { + } else if (format.includes('+')) { signed = true; format = format.replace(/\+/g, ''); } // see if abbreviation is wanted - if (format.indexOf('a') > -1) { + if (format.includes('a')) { // check if abbreviation is specified - abbrK = format.indexOf('ak') > -1; - abbrM = format.indexOf('am') > -1; - abbrB = format.indexOf('ab') > -1; - abbrT = format.indexOf('at') > -1; + abbrK = format.includes('ak'); + abbrM = format.includes('am'); + abbrB = format.includes('ab'); + abbrT = format.includes('at'); abbrForce = abbrK || abbrM || abbrB || abbrT; // check for space before abbreviation - if (format.indexOf(' a') > -1) { + if (format.includes(' a')) { abbr = ' '; } @@ -362,7 +362,7 @@ } - if (format.indexOf('[.]') > -1) { + if (format.includes('[.]')) { optDec = true; format = format.replace('[.]', '.'); } @@ -372,7 +372,7 @@ thousands = format.indexOf(','); if (precision) { - if (precision.indexOf('[') > -1) { + if (precision.includes('[')) { precision = precision.replace(']', ''); precision = precision.split('['); d = toFixed(value, (precision[0].length + precision[1].length), roundingFunction, precision[1].length); @@ -382,7 +382,7 @@ w = d.split('.')[0]; - if (d.indexOf('.') > -1) { + if (d.includes('.')) { d = locales[options.currentLocale].delimiters.decimal + d.split('.')[1]; } else { d = ''; @@ -396,7 +396,7 @@ } // format number - if (w.indexOf('-') > -1) { + if (w.includes('-')) { w = w.slice(1); neg = true; } @@ -428,9 +428,9 @@ power, value; - if (string.indexOf(':') > -1) { + if (string.includes(':')) { value = unformatTime(string); - } else if (string.indexOf('e+') > -1 || string.indexOf('e-') > -1) { + } else if (string.includes('e+') || string.includes('e-')) { value = unformatExponential(string); } else { if (string === options.zeroFormat || string === options.nullFormat) { @@ -448,7 +448,7 @@ // see if bytes are there so that we can multiply to the correct number for (power = 1; power <= config.bytes.decimal.suffixes.length; power++) { - bytesMultiplier = ((string.indexOf(config.bytes.decimal.suffixes[power]) > -1) || (string.indexOf(config.bytes.binary.suffixes[power]) > -1))? Math.pow(1024, power) : false; + bytesMultiplier = ((string.includes(config.bytes.decimal.suffixes[power])) || (string.includes(config.bytes.binary.suffixes[power])))? Math.pow(1024, power) : false; if (bytesMultiplier) { break; @@ -462,7 +462,7 @@ value *= stringOriginal.match(billionRegExp) ? Math.pow(10, 9) : 1; value *= stringOriginal.match(trillionRegExp) ? Math.pow(10, 12) : 1; // check for percentage - value *= string.indexOf('%') > -1 ? 0.01 : 1; + value *= string.includes('%') ? 0.01 : 1; // check for negative number value *= (string.split('-').length + Math.min(string.split('(').length - 1, string.split(')').length - 1)) % 2 ? 1 : -1; // remove non numbers @@ -498,11 +498,11 @@ } function unformatExponential(string) { - var parts = string.indexOf('e+') > -1 ? string.split('e+') : string.split('e-'), + var parts = string.includes('e+') ? string.split('e+') : string.split('e-'), value = Number(parts[0]), power = Number(parts[1]); - power = string.indexOf('e-') > -1 ? power *= -1 : power; + power = string.includes('e-') ? power *= -1 : power; function cback(accum, curr, currI, O) { var corrFactor = correctionFactor(accum, curr), @@ -729,6 +729,13 @@ return typeof value === 'number' && isNaN(value); }; + // String includes polyfill + if (!String.prototype.includes) { + String.prototype.includes = function(search, start) { + return this.indexOf(search, start) !== -1; + }; + } + // Production steps of ECMA-262, Edition 5, 15.4.4.21 // Reference: http://es5.github.io/#x15.4.4.21 if (!Array.prototype.reduce) { From 67dcaafcec290ed0467b77b4dc73b39daa207d6b Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Mon, 28 Nov 2016 23:11:36 -0800 Subject: [PATCH 080/150] shorten polyfill --- min/numeral-with-locales.min.js | 2 +- min/numeral.min.js | 2 +- numeral-with-locales.js | 8 +++----- numeral.js | 8 +++----- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/min/numeral-with-locales.min.js b/min/numeral-with-locales.min.js index c60a0f73..f2379ad0 100644 --- a/min/numeral-with-locales.min.js +++ b/min/numeral-with-locales.min.js @@ -5,7 +5,7 @@ * 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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i="";return b.includes(" $")?(i=" ",b=b.replace(" $","")):b.includes("$ ")?(i=" ",b=b.replace("$ ","")):b=b.replace("$",""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e="";return a=100*a,b.includes(" %")?(e=" ",b=b.replace(" %","")):b=b.replace("%",""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i="";for(b.includes(" b")||b.includes(" ib")?(i=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e="";return b.includes(" o")?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.includes("e+")?b.replace("e+0",""):b.replace("e-0",""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r=1e12,t=1e9,v=1e6,w=1e3,x="",y=!1;return a=a||0,e=Math.abs(a),c.includes("(")?(i=!0,c=c.slice(1,-1)):c.includes("+")&&(j=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(m=c.includes("ak"),n=c.includes("am"),o=c.includes("ab"),p=c.includes("at"),q=m||n||o||p,c.includes(" a")&&(l=" "),c=c.replace(new RegExp(l+"a[kmbt]?"),""),e>=r&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=r):r>e&&e>=t&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=t):t>e&&e>=v&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=v):(v>e&&e>=w&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=w)),c.includes("[.]")&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.includes("[")?(g=g.replace("]",""),g=g.split("["),x=b(a,g[0].length+g[1].length,d,g[1].length)):x=b(a,g.length,d),f=x.split(".")[0],x=x.includes(".")?s[u.currentLocale].delimiters.decimal+x.split(".")[1]:"",k&&0===Number(x.slice(1))&&(x="")):f=b(a,null,d),f.includes("-")&&(f=f.slice(1),y=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&y?"(":"")+(!i&&y?"-":"")+(!y&&j?"+":"")+f+x+(l?l:"")+(i&&y?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.reset=function(){for(var a in t)u[a]=t[a]},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes||(String.prototype.includes=function(a,b){return-1!==this.indexOf(a,b)}),Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this),/*! @preserve +(function(){function a(a){this._value=a}function b(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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i="";return b.includes(" $")?(i=" ",b=b.replace(" $","")):b.includes("$ ")?(i=" ",b=b.replace("$ ","")):b=b.replace("$",""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e="";return a=100*a,b.includes(" %")?(e=" ",b=b.replace(" %","")):b=b.replace("%",""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i="";for(b.includes(" b")||b.includes(" ib")?(i=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e="";return b.includes(" o")?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.includes("e+")?b.replace("e+0",""):b.replace("e-0",""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r=1e12,t=1e9,v=1e6,w=1e3,x="",y=!1;return a=a||0,e=Math.abs(a),c.includes("(")?(i=!0,c=c.slice(1,-1)):c.includes("+")&&(j=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(m=c.includes("ak"),n=c.includes("am"),o=c.includes("ab"),p=c.includes("at"),q=m||n||o||p,c.includes(" a")&&(l=" "),c=c.replace(new RegExp(l+"a[kmbt]?"),""),e>=r&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=r):r>e&&e>=t&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=t):t>e&&e>=v&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=v):(v>e&&e>=w&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=w)),c.includes("[.]")&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.includes("[")?(g=g.replace("]",""),g=g.split("["),x=b(a,g[0].length+g[1].length,d,g[1].length)):x=b(a,g.length,d),f=x.split(".")[0],x=x.includes(".")?s[u.currentLocale].delimiters.decimal+x.split(".")[1]:"",k&&0===Number(x.slice(1))&&(x="")):f=b(a,null,d),f.includes("-")&&(f=f.slice(1),y=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&y?"(":"")+(!i&&y?"-":"")+(!y&&j?"+":"")+f+x+(l?l:"")+(i&&y?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.reset=function(){for(var a in t)u[a]=t[a]},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes=String.prototype.includes||function(a,b){return-1!==this.indexOf(a,b)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this),/*! @preserve * numeral.js locale configuration * locale : belgium-dutch (be-nl) * author : Dieter Luypaert : https://github.com/moeriki diff --git a/min/numeral.min.js b/min/numeral.min.js index 31d84f45..3d20ff68 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * 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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i="";return b.includes(" $")?(i=" ",b=b.replace(" $","")):b.includes("$ ")?(i=" ",b=b.replace("$ ","")):b=b.replace("$",""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e="";return a=100*a,b.includes(" %")?(e=" ",b=b.replace(" %","")):b=b.replace("%",""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i="";for(b.includes(" b")||b.includes(" ib")?(i=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e="";return b.includes(" o")?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.includes("e+")?b.replace("e+0",""):b.replace("e-0",""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r=1e12,t=1e9,v=1e6,w=1e3,x="",y=!1;return a=a||0,e=Math.abs(a),c.includes("(")?(i=!0,c=c.slice(1,-1)):c.includes("+")&&(j=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(m=c.includes("ak"),n=c.includes("am"),o=c.includes("ab"),p=c.includes("at"),q=m||n||o||p,c.includes(" a")&&(l=" "),c=c.replace(new RegExp(l+"a[kmbt]?"),""),e>=r&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=r):r>e&&e>=t&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=t):t>e&&e>=v&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=v):(v>e&&e>=w&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=w)),c.includes("[.]")&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.includes("[")?(g=g.replace("]",""),g=g.split("["),x=b(a,g[0].length+g[1].length,d,g[1].length)):x=b(a,g.length,d),f=x.split(".")[0],x=x.includes(".")?s[u.currentLocale].delimiters.decimal+x.split(".")[1]:"",k&&0===Number(x.slice(1))&&(x="")):f=b(a,null,d),f.includes("-")&&(f=f.slice(1),y=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&y?"(":"")+(!i&&y?"-":"")+(!y&&j?"+":"")+f+x+(l?l:"")+(i&&y?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.reset=function(){for(var a in t)u[a]=t[a]},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes||(String.prototype.includes=function(a,b){return-1!==this.indexOf(a,b)}),Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this); \ No newline at end of file +(function(){function a(a){this._value=a}function b(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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i="";return b.includes(" $")?(i=" ",b=b.replace(" $","")):b.includes("$ ")?(i=" ",b=b.replace("$ ","")):b=b.replace("$",""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e="";return a=100*a,b.includes(" %")?(e=" ",b=b.replace(" %","")):b=b.replace("%",""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i="";for(b.includes(" b")||b.includes(" ib")?(i=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e="";return b.includes(" o")?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.includes("e+")?b.replace("e+0",""):b.replace("e-0",""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r=1e12,t=1e9,v=1e6,w=1e3,x="",y=!1;return a=a||0,e=Math.abs(a),c.includes("(")?(i=!0,c=c.slice(1,-1)):c.includes("+")&&(j=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(m=c.includes("ak"),n=c.includes("am"),o=c.includes("ab"),p=c.includes("at"),q=m||n||o||p,c.includes(" a")&&(l=" "),c=c.replace(new RegExp(l+"a[kmbt]?"),""),e>=r&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=r):r>e&&e>=t&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=t):t>e&&e>=v&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=v):(v>e&&e>=w&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=w)),c.includes("[.]")&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.includes("[")?(g=g.replace("]",""),g=g.split("["),x=b(a,g[0].length+g[1].length,d,g[1].length)):x=b(a,g.length,d),f=x.split(".")[0],x=x.includes(".")?s[u.currentLocale].delimiters.decimal+x.split(".")[1]:"",k&&0===Number(x.slice(1))&&(x="")):f=b(a,null,d),f.includes("-")&&(f=f.slice(1),y=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&y?"(":"")+(!i&&y?"-":"")+(!y&&j?"+":"")+f+x+(l?l:"")+(i&&y?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.reset=function(){for(var a in t)u[a]=t[a]},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes=String.prototype.includes||function(a,b){return-1!==this.indexOf(a,b)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this); \ No newline at end of file diff --git a/numeral-with-locales.js b/numeral-with-locales.js index 314bbd23..d2c6fd04 100644 --- a/numeral-with-locales.js +++ b/numeral-with-locales.js @@ -730,11 +730,9 @@ }; // String includes polyfill - if (!String.prototype.includes) { - String.prototype.includes = function(search, start) { - return this.indexOf(search, start) !== -1; - }; - } + String.prototype.includes = String.prototype.includes || function(search, start) { + return this.indexOf(search, start) !== -1; + }; // Production steps of ECMA-262, Edition 5, 15.4.4.21 // Reference: http://es5.github.io/#x15.4.4.21 diff --git a/numeral.js b/numeral.js index fb2b8853..1324c7fe 100644 --- a/numeral.js +++ b/numeral.js @@ -730,11 +730,9 @@ }; // String includes polyfill - if (!String.prototype.includes) { - String.prototype.includes = function(search, start) { - return this.indexOf(search, start) !== -1; - }; - } + String.prototype.includes = String.prototype.includes || function(search, start) { + return this.indexOf(search, start) !== -1; + }; // Production steps of ECMA-262, Edition 5, 15.4.4.21 // Reference: http://es5.github.io/#x15.4.4.21 From cc021f1c07f89daf8e0b975d792a3bfbb5a7765c Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Mon, 28 Nov 2016 23:45:52 -0800 Subject: [PATCH 081/150] regex for spaces --- min/numeral-with-locales.min.js | 2 +- min/numeral.min.js | 2 +- numeral-with-locales.js | 39 +++++++-------------------------- numeral.js | 39 +++++++-------------------------- 4 files changed, 18 insertions(+), 64 deletions(-) diff --git a/min/numeral-with-locales.min.js b/min/numeral-with-locales.min.js index f2379ad0..d33c04e2 100644 --- a/min/numeral-with-locales.min.js +++ b/min/numeral-with-locales.min.js @@ -5,7 +5,7 @@ * 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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i="";return b.includes(" $")?(i=" ",b=b.replace(" $","")):b.includes("$ ")?(i=" ",b=b.replace("$ ","")):b=b.replace("$",""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e="";return a=100*a,b.includes(" %")?(e=" ",b=b.replace(" %","")):b=b.replace("%",""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i="";for(b.includes(" b")||b.includes(" ib")?(i=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e="";return b.includes(" o")?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.includes("e+")?b.replace("e+0",""):b.replace("e-0",""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r=1e12,t=1e9,v=1e6,w=1e3,x="",y=!1;return a=a||0,e=Math.abs(a),c.includes("(")?(i=!0,c=c.slice(1,-1)):c.includes("+")&&(j=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(m=c.includes("ak"),n=c.includes("am"),o=c.includes("ab"),p=c.includes("at"),q=m||n||o||p,c.includes(" a")&&(l=" "),c=c.replace(new RegExp(l+"a[kmbt]?"),""),e>=r&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=r):r>e&&e>=t&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=t):t>e&&e>=v&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=v):(v>e&&e>=w&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=w)),c.includes("[.]")&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.includes("[")?(g=g.replace("]",""),g=g.split("["),x=b(a,g[0].length+g[1].length,d,g[1].length)):x=b(a,g.length,d),f=x.split(".")[0],x=x.includes(".")?s[u.currentLocale].delimiters.decimal+x.split(".")[1]:"",k&&0===Number(x.slice(1))&&(x="")):f=b(a,null,d),f.includes("-")&&(f=f.slice(1),y=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&y?"(":"")+(!i&&y?"-":"")+(!y&&j?"+":"")+f+x+(l?l:"")+(i&&y?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.reset=function(){for(var a in t)u[a]=t[a]},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes=String.prototype.includes||function(a,b){return-1!==this.indexOf(a,b)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this),/*! @preserve +(function(){function a(a){this._value=a}function b(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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i=b.includes(" $")||b.includes("$ ")?" ":"";return b=b.replace(/\s?\$\s?/,""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e=b.includes(" %")?" ":"";return a=100*a,b=b.replace(/\s?\%/,""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i=b.includes(" b")||b.includes(" ib")?" ":"";for(b=b.replace(/\s?i?b/,""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e=b.includes(" o")?" ":"";return b=b.replace(/\s?o/,""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.includes("e+")?b.replace("e+0",""):b.replace("e-0",""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r=1e12,t=1e9,v=1e6,w=1e3,x="",y=!1;return a=a||0,e=Math.abs(a),c.includes("(")?(i=!0,c=c.slice(1,-1)):c.includes("+")&&(j=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(m=c.includes("ak"),n=c.includes("am"),o=c.includes("ab"),p=c.includes("at"),q=m||n||o||p,c.includes(" a")&&(l=" "),c=c.replace(new RegExp(l+"a[kmbt]?"),""),e>=r&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=r):r>e&&e>=t&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=t):t>e&&e>=v&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=v):(v>e&&e>=w&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=w)),c.includes("[.]")&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.includes("[")?(g=g.replace("]",""),g=g.split("["),x=b(a,g[0].length+g[1].length,d,g[1].length)):x=b(a,g.length,d),f=x.split(".")[0],x=x.includes(".")?s[u.currentLocale].delimiters.decimal+x.split(".")[1]:"",k&&0===Number(x.slice(1))&&(x="")):f=b(a,null,d),f.includes("-")&&(f=f.slice(1),y=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&y?"(":"")+(!i&&y?"-":"")+(!y&&j?"+":"")+f+x+(l?l:"")+(i&&y?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.reset=function(){for(var a in t)u[a]=t[a]},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes=String.prototype.includes||function(a,b){return-1!==this.indexOf(a,b)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this),/*! @preserve * numeral.js locale configuration * locale : belgium-dutch (be-nl) * author : Dieter Luypaert : https://github.com/moeriki diff --git a/min/numeral.min.js b/min/numeral.min.js index 3d20ff68..bacbc84e 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * 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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i="";return b.includes(" $")?(i=" ",b=b.replace(" $","")):b.includes("$ ")?(i=" ",b=b.replace("$ ","")):b=b.replace("$",""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e="";return a=100*a,b.includes(" %")?(e=" ",b=b.replace(" %","")):b=b.replace("%",""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i="";for(b.includes(" b")||b.includes(" ib")?(i=" ",b=b.replace(" ib","").replace(" b","")):b=b.replace("ib","").replace("b",""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e="";return b.includes(" o")?(e=" ",b=b.replace(" o","")):b=b.replace("o",""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.includes("e+")?b.replace("e+0",""):b.replace("e-0",""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r=1e12,t=1e9,v=1e6,w=1e3,x="",y=!1;return a=a||0,e=Math.abs(a),c.includes("(")?(i=!0,c=c.slice(1,-1)):c.includes("+")&&(j=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(m=c.includes("ak"),n=c.includes("am"),o=c.includes("ab"),p=c.includes("at"),q=m||n||o||p,c.includes(" a")&&(l=" "),c=c.replace(new RegExp(l+"a[kmbt]?"),""),e>=r&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=r):r>e&&e>=t&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=t):t>e&&e>=v&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=v):(v>e&&e>=w&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=w)),c.includes("[.]")&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.includes("[")?(g=g.replace("]",""),g=g.split("["),x=b(a,g[0].length+g[1].length,d,g[1].length)):x=b(a,g.length,d),f=x.split(".")[0],x=x.includes(".")?s[u.currentLocale].delimiters.decimal+x.split(".")[1]:"",k&&0===Number(x.slice(1))&&(x="")):f=b(a,null,d),f.includes("-")&&(f=f.slice(1),y=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&y?"(":"")+(!i&&y?"-":"")+(!y&&j?"+":"")+f+x+(l?l:"")+(i&&y?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.reset=function(){for(var a in t)u[a]=t[a]},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes=String.prototype.includes||function(a,b){return-1!==this.indexOf(a,b)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this); \ No newline at end of file +(function(){function a(a){this._value=a}function b(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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i=b.includes(" $")||b.includes("$ ")?" ":"";return b=b.replace(/\s?\$\s?/,""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e=b.includes(" %")?" ":"";return a=100*a,b=b.replace(/\s?\%/,""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i=b.includes(" b")||b.includes(" ib")?" ":"";for(b=b.replace(/\s?i?b/,""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e=b.includes(" o")?" ":"";return b=b.replace(/\s?o/,""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.includes("e+")?b.replace("e+0",""):b.replace("e-0",""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r=1e12,t=1e9,v=1e6,w=1e3,x="",y=!1;return a=a||0,e=Math.abs(a),c.includes("(")?(i=!0,c=c.slice(1,-1)):c.includes("+")&&(j=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(m=c.includes("ak"),n=c.includes("am"),o=c.includes("ab"),p=c.includes("at"),q=m||n||o||p,c.includes(" a")&&(l=" "),c=c.replace(new RegExp(l+"a[kmbt]?"),""),e>=r&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=r):r>e&&e>=t&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=t):t>e&&e>=v&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=v):(v>e&&e>=w&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=w)),c.includes("[.]")&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.includes("[")?(g=g.replace("]",""),g=g.split("["),x=b(a,g[0].length+g[1].length,d,g[1].length)):x=b(a,g.length,d),f=x.split(".")[0],x=x.includes(".")?s[u.currentLocale].delimiters.decimal+x.split(".")[1]:"",k&&0===Number(x.slice(1))&&(x="")):f=b(a,null,d),f.includes("-")&&(f=f.slice(1),y=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&y?"(":"")+(!i&&y?"-":"")+(!y&&j?"+":"")+f+x+(l?l:"")+(i&&y?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.reset=function(){for(var a in t)u[a]=t[a]},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes=String.prototype.includes||function(a,b){return-1!==this.indexOf(a,b)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this); \ No newline at end of file diff --git a/numeral-with-locales.js b/numeral-with-locales.js index d2c6fd04..f01f53fc 100644 --- a/numeral-with-locales.js +++ b/numeral-with-locales.js @@ -140,20 +140,12 @@ var symbolIndex = format.indexOf('$'), openParenIndex = format.indexOf('('), minusSignIndex = format.indexOf('-'), - space = '', + space = format.includes(' $') || format.includes('$ ') ? ' ' : '', spliceIndex, output; // check for space before or after currency - if (format.includes(' $')) { - space = ' '; - format = format.replace(' $', ''); - } else if (format.includes('$ ')) { - space = ' '; - format = format.replace('$ ', ''); - } else { - format = format.replace('$', ''); - } + format = format.replace(/\s?\$\s?/, ''); // format the number output = formatNumber(value, format, roundingFunction); @@ -186,18 +178,13 @@ } function formatPercentage(value, format, roundingFunction) { - var space = '', + var space = format.includes(' %') ? ' ' : '', output; value = value * 100; // check for space before % - if (format.includes(' %')) { - space = ' '; - format = format.replace(' %', ''); - } else { - format = format.replace('%', ''); - } + format = format.replace(/\s?\%/, ''); output = formatNumber(value, format, roundingFunction); @@ -215,18 +202,13 @@ function formatBytes(value, format, roundingFunction) { var output, bytes = format.includes('ib') ? config.bytes.binary : config.bytes.decimal, - suffix = '', + suffix = format.includes(' b') || format.includes(' ib') ? ' ' : '', power, min, max; // check for space before - if (format.includes(' b') || format.includes(' ib')) { - suffix = ' '; - format = format.replace(' ib', '').replace(' b', ''); - } else { - format = format.replace('ib', '').replace('b', ''); - } + format = format.replace(/\s?i?b/, ''); for (power = 0; power <= bytes.suffixes.length; power++) { min = Math.pow(bytes.base, power); @@ -250,15 +232,10 @@ function formatOrdinal(value, format, roundingFunction) { var output, - ordinal = ''; + ordinal = format.includes(' o') ? ' ' : ''; // check for space before - if (format.includes(' o')) { - ordinal = ' '; - format = format.replace(' o', ''); - } else { - format = format.replace('o', ''); - } + format = format.replace(/\s?o/, ''); ordinal += locales[options.currentLocale].ordinal(value); diff --git a/numeral.js b/numeral.js index 1324c7fe..243aaefa 100644 --- a/numeral.js +++ b/numeral.js @@ -140,20 +140,12 @@ var symbolIndex = format.indexOf('$'), openParenIndex = format.indexOf('('), minusSignIndex = format.indexOf('-'), - space = '', + space = format.includes(' $') || format.includes('$ ') ? ' ' : '', spliceIndex, output; // check for space before or after currency - if (format.includes(' $')) { - space = ' '; - format = format.replace(' $', ''); - } else if (format.includes('$ ')) { - space = ' '; - format = format.replace('$ ', ''); - } else { - format = format.replace('$', ''); - } + format = format.replace(/\s?\$\s?/, ''); // format the number output = formatNumber(value, format, roundingFunction); @@ -186,18 +178,13 @@ } function formatPercentage(value, format, roundingFunction) { - var space = '', + var space = format.includes(' %') ? ' ' : '', output; value = value * 100; // check for space before % - if (format.includes(' %')) { - space = ' '; - format = format.replace(' %', ''); - } else { - format = format.replace('%', ''); - } + format = format.replace(/\s?\%/, ''); output = formatNumber(value, format, roundingFunction); @@ -215,18 +202,13 @@ function formatBytes(value, format, roundingFunction) { var output, bytes = format.includes('ib') ? config.bytes.binary : config.bytes.decimal, - suffix = '', + suffix = format.includes(' b') || format.includes(' ib') ? ' ' : '', power, min, max; // check for space before - if (format.includes(' b') || format.includes(' ib')) { - suffix = ' '; - format = format.replace(' ib', '').replace(' b', ''); - } else { - format = format.replace('ib', '').replace('b', ''); - } + format = format.replace(/\s?i?b/, ''); for (power = 0; power <= bytes.suffixes.length; power++) { min = Math.pow(bytes.base, power); @@ -250,15 +232,10 @@ function formatOrdinal(value, format, roundingFunction) { var output, - ordinal = ''; + ordinal = format.includes(' o') ? ' ' : ''; // check for space before - if (format.includes(' o')) { - ordinal = ' '; - format = format.replace(' o', ''); - } else { - format = format.replace('o', ''); - } + format = format.replace(/\s?o/, ''); ordinal += locales[options.currentLocale].ordinal(value); From b9b63836106bc824ea8bac0178efe2ab7ff3d5c1 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Mon, 28 Nov 2016 23:48:34 -0800 Subject: [PATCH 082/150] regex for exponential format --- min/numeral-with-locales.min.js | 2 +- min/numeral.min.js | 2 +- numeral-with-locales.js | 2 +- numeral.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/min/numeral-with-locales.min.js b/min/numeral-with-locales.min.js index d33c04e2..c9ff4522 100644 --- a/min/numeral-with-locales.min.js +++ b/min/numeral-with-locales.min.js @@ -5,7 +5,7 @@ * 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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i=b.includes(" $")||b.includes("$ ")?" ":"";return b=b.replace(/\s?\$\s?/,""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e=b.includes(" %")?" ":"";return a=100*a,b=b.replace(/\s?\%/,""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i=b.includes(" b")||b.includes(" ib")?" ":"";for(b=b.replace(/\s?i?b/,""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e=b.includes(" o")?" ":"";return b=b.replace(/\s?o/,""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.includes("e+")?b.replace("e+0",""):b.replace("e-0",""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r=1e12,t=1e9,v=1e6,w=1e3,x="",y=!1;return a=a||0,e=Math.abs(a),c.includes("(")?(i=!0,c=c.slice(1,-1)):c.includes("+")&&(j=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(m=c.includes("ak"),n=c.includes("am"),o=c.includes("ab"),p=c.includes("at"),q=m||n||o||p,c.includes(" a")&&(l=" "),c=c.replace(new RegExp(l+"a[kmbt]?"),""),e>=r&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=r):r>e&&e>=t&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=t):t>e&&e>=v&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=v):(v>e&&e>=w&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=w)),c.includes("[.]")&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.includes("[")?(g=g.replace("]",""),g=g.split("["),x=b(a,g[0].length+g[1].length,d,g[1].length)):x=b(a,g.length,d),f=x.split(".")[0],x=x.includes(".")?s[u.currentLocale].delimiters.decimal+x.split(".")[1]:"",k&&0===Number(x.slice(1))&&(x="")):f=b(a,null,d),f.includes("-")&&(f=f.slice(1),y=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&y?"(":"")+(!i&&y?"-":"")+(!y&&j?"+":"")+f+x+(l?l:"")+(i&&y?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.reset=function(){for(var a in t)u[a]=t[a]},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes=String.prototype.includes||function(a,b){return-1!==this.indexOf(a,b)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this),/*! @preserve +(function(){function a(a){this._value=a}function b(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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i=b.includes(" $")||b.includes("$ ")?" ":"";return b=b.replace(/\s?\$\s?/,""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e=b.includes(" %")?" ":"";return a=100*a,b=b.replace(/\s?\%/,""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i=b.includes(" b")||b.includes(" ib")?" ":"";for(b=b.replace(/\s?i?b/,""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e=b.includes(" o")?" ":"";return b=b.replace(/\s?o/,""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.replace(/e[\+|\-]{1}0/,""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r=1e12,t=1e9,v=1e6,w=1e3,x="",y=!1;return a=a||0,e=Math.abs(a),c.includes("(")?(i=!0,c=c.slice(1,-1)):c.includes("+")&&(j=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(m=c.includes("ak"),n=c.includes("am"),o=c.includes("ab"),p=c.includes("at"),q=m||n||o||p,c.includes(" a")&&(l=" "),c=c.replace(new RegExp(l+"a[kmbt]?"),""),e>=r&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=r):r>e&&e>=t&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=t):t>e&&e>=v&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=v):(v>e&&e>=w&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=w)),c.includes("[.]")&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.includes("[")?(g=g.replace("]",""),g=g.split("["),x=b(a,g[0].length+g[1].length,d,g[1].length)):x=b(a,g.length,d),f=x.split(".")[0],x=x.includes(".")?s[u.currentLocale].delimiters.decimal+x.split(".")[1]:"",k&&0===Number(x.slice(1))&&(x="")):f=b(a,null,d),f.includes("-")&&(f=f.slice(1),y=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&y?"(":"")+(!i&&y?"-":"")+(!y&&j?"+":"")+f+x+(l?l:"")+(i&&y?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.reset=function(){for(var a in t)u[a]=t[a]},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes=String.prototype.includes||function(a,b){return-1!==this.indexOf(a,b)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this),/*! @preserve * numeral.js locale configuration * locale : belgium-dutch (be-nl) * author : Dieter Luypaert : https://github.com/moeriki diff --git a/min/numeral.min.js b/min/numeral.min.js index bacbc84e..53f6391a 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * 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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i=b.includes(" $")||b.includes("$ ")?" ":"";return b=b.replace(/\s?\$\s?/,""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e=b.includes(" %")?" ":"";return a=100*a,b=b.replace(/\s?\%/,""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i=b.includes(" b")||b.includes(" ib")?" ":"";for(b=b.replace(/\s?i?b/,""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e=b.includes(" o")?" ":"";return b=b.replace(/\s?o/,""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.includes("e+")?b.replace("e+0",""):b.replace("e-0",""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r=1e12,t=1e9,v=1e6,w=1e3,x="",y=!1;return a=a||0,e=Math.abs(a),c.includes("(")?(i=!0,c=c.slice(1,-1)):c.includes("+")&&(j=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(m=c.includes("ak"),n=c.includes("am"),o=c.includes("ab"),p=c.includes("at"),q=m||n||o||p,c.includes(" a")&&(l=" "),c=c.replace(new RegExp(l+"a[kmbt]?"),""),e>=r&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=r):r>e&&e>=t&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=t):t>e&&e>=v&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=v):(v>e&&e>=w&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=w)),c.includes("[.]")&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.includes("[")?(g=g.replace("]",""),g=g.split("["),x=b(a,g[0].length+g[1].length,d,g[1].length)):x=b(a,g.length,d),f=x.split(".")[0],x=x.includes(".")?s[u.currentLocale].delimiters.decimal+x.split(".")[1]:"",k&&0===Number(x.slice(1))&&(x="")):f=b(a,null,d),f.includes("-")&&(f=f.slice(1),y=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&y?"(":"")+(!i&&y?"-":"")+(!y&&j?"+":"")+f+x+(l?l:"")+(i&&y?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.reset=function(){for(var a in t)u[a]=t[a]},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes=String.prototype.includes||function(a,b){return-1!==this.indexOf(a,b)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this); \ No newline at end of file +(function(){function a(a){this._value=a}function b(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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i=b.includes(" $")||b.includes("$ ")?" ":"";return b=b.replace(/\s?\$\s?/,""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e=b.includes(" %")?" ":"";return a=100*a,b=b.replace(/\s?\%/,""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i=b.includes(" b")||b.includes(" ib")?" ":"";for(b=b.replace(/\s?i?b/,""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e=b.includes(" o")?" ":"";return b=b.replace(/\s?o/,""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.replace(/e[\+|\-]{1}0/,""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r=1e12,t=1e9,v=1e6,w=1e3,x="",y=!1;return a=a||0,e=Math.abs(a),c.includes("(")?(i=!0,c=c.slice(1,-1)):c.includes("+")&&(j=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(m=c.includes("ak"),n=c.includes("am"),o=c.includes("ab"),p=c.includes("at"),q=m||n||o||p,c.includes(" a")&&(l=" "),c=c.replace(new RegExp(l+"a[kmbt]?"),""),e>=r&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=r):r>e&&e>=t&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=t):t>e&&e>=v&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=v):(v>e&&e>=w&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=w)),c.includes("[.]")&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.includes("[")?(g=g.replace("]",""),g=g.split("["),x=b(a,g[0].length+g[1].length,d,g[1].length)):x=b(a,g.length,d),f=x.split(".")[0],x=x.includes(".")?s[u.currentLocale].delimiters.decimal+x.split(".")[1]:"",k&&0===Number(x.slice(1))&&(x="")):f=b(a,null,d),f.includes("-")&&(f=f.slice(1),y=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&y?"(":"")+(!i&&y?"-":"")+(!y&&j?"+":"")+f+x+(l?l:"")+(i&&y?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.reset=function(){for(var a in t)u[a]=t[a]},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes=String.prototype.includes||function(a,b){return-1!==this.indexOf(a,b)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this); \ No newline at end of file diff --git a/numeral-with-locales.js b/numeral-with-locales.js index f01f53fc..c8b6b70c 100644 --- a/numeral-with-locales.js +++ b/numeral-with-locales.js @@ -249,7 +249,7 @@ exponential = typeof value === 'number' && !Number.isNaN(value) ? value.toExponential() : '0e+0', parts = exponential.split('e'); - format = format.includes('e+') ? format.replace('e+0', '') : format.replace('e-0', ''); + format = format.replace(/e[\+|\-]{1}0/, ''); output = formatNumber(Number(parts[0]), format, roundingFunction); diff --git a/numeral.js b/numeral.js index 243aaefa..44b5d014 100644 --- a/numeral.js +++ b/numeral.js @@ -249,7 +249,7 @@ exponential = typeof value === 'number' && !Number.isNaN(value) ? value.toExponential() : '0e+0', parts = exponential.split('e'); - format = format.includes('e+') ? format.replace('e+0', '') : format.replace('e-0', ''); + format = format.replace(/e[\+|\-]{1}0/, ''); output = formatNumber(Number(parts[0]), format, roundingFunction); From d1ace8c915ea0e9a35d607ef92744467c4a5de19 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Tue, 29 Nov 2016 09:41:40 -0800 Subject: [PATCH 083/150] return options if now values sent --- numeral.js | 73 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 31 deletions(-) diff --git a/numeral.js b/numeral.js index 44b5d014..7a3824e2 100644 --- a/numeral.js +++ b/numeral.js @@ -144,7 +144,7 @@ spliceIndex, output; - // check for space before or after currency + // strip format of spaces and $ format = format.replace(/\s?\$\s?/, ''); // format the number @@ -154,12 +154,11 @@ if (symbolIndex <= 1) { if (output.includes('(') || output.includes('-')) { output = output.split(''); - spliceIndex = 1; - if (symbolIndex < openParenIndex || symbolIndex < minusSignIndex) { - // the symbol appears before the "(" or "-" - spliceIndex = 0; - } + + spliceIndex = symbolIndex < openParenIndex || symbolIndex < minusSignIndex ? 0 : 1; + output.splice(spliceIndex, 0, locales[options.currentLocale].currency.symbol + space); + output = output.join(''); } else { output = locales[options.currentLocale].currency.symbol + space + output; @@ -167,7 +166,9 @@ } else { if (output.includes(')')) { output = output.split(''); + output.splice(-1, 0, space + locales[options.currentLocale].currency.symbol); + output = output.join(''); } else { output = output + space + locales[options.currentLocale].currency.symbol; @@ -190,7 +191,9 @@ if (output.includes(')')) { output = output.split(''); + output.splice(-1, 0, space + '%'); + output = output.join(''); } else { output = output + space + '%'; @@ -261,7 +264,7 @@ 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); + return hours + ':' + (minutes < 10 ? '0' + minutes : minutes) + ':' + (seconds < 10 ? '0' + seconds : seconds); } function formatNumber(value, format, roundingFunction) { @@ -490,7 +493,6 @@ return [value, Math.pow(10, power)].reduce(cback, 1); } - /************************************ Top Level Functions ************************************/ @@ -546,12 +548,6 @@ return numeral; }; - numeral.reset = function() { - for (var property in defaults) { - options[property] = defaults[property]; - } - }; - // This function provides access to the loaded locale data. If // no arguments are passed in, it will simply return the current // global locale object. @@ -592,15 +588,33 @@ } }); + numeral.reset = function() { + for (var property in defaults) { + options[property] = defaults[property]; + } + }; + numeral.zeroFormat = function(format) { + if (!format) { + return options.zeroFormat; + } + options.zeroFormat = typeof(format) === 'string' ? format : null; }; numeral.nullFormat = function (format) { + if (!format) { + return options.nullFormat; + } + options.nullFormat = typeof(format) === 'string' ? format : null; }; numeral.defaultFormat = function(format) { + if (!format) { + return options.defaultFormat; + } + options.defaultFormat = typeof(format) === 'string' ? format : '0.0'; }; @@ -617,6 +631,7 @@ //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); } @@ -626,7 +641,7 @@ val = val.trim(); //if val is just digits return true - if ( !! val.match(/^\d+$/)) { + if (!!val.match(/^\d+$/)) { return true; } @@ -755,10 +770,8 @@ */ function multiplier(x) { var parts = x.toString().split('.'); - if (parts.length < 2) { - return 1; - } - return Math.pow(10, parts[1].length); + + return parts.length < 2 ? 1 : Math.pow(10, parts[1].length); } /** @@ -768,6 +781,7 @@ */ function correctionFactor() { var args = Array.prototype.slice.call(arguments); + return args.reduce(function(accum, next) { var mn = multiplier(next); return accum > mn ? accum : mn; @@ -781,18 +795,15 @@ numeral.fn = Numeral.prototype = { - clone: function() { return numeral(this); }, - format: function (inputString, roundingFunction) { return formatNumeral(this, inputString ? inputString : options.defaultFormat, roundingFunction !== undefined ? roundingFunction : Math.round ); }, - unformat: function (inputString) { if (Object.prototype.toString.call(inputString) === '[object Number]') { return inputString; @@ -800,62 +811,62 @@ return unformatNumeral(this, inputString ? inputString : options.defaultFormat); }, - value: function() { return this._value; }, - valueOf: function() { return this._value; }, - 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 = [this._value, value].reduce(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 = [value].reduce(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 = [this._value, value].reduce(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 = [this._value, value].reduce(cback); + return this; }, - difference: function(value) { return Math.abs(numeral(this._value).subtract(value).value()); } - }; /************************************ From 18e31af8d924eff814eeb072f6306b97df3f4216 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Tue, 29 Nov 2016 09:41:53 -0800 Subject: [PATCH 084/150] build --- min/numeral-with-locales.min.js | 2 +- min/numeral.min.js | 2 +- numeral-with-locales.js | 73 +++++++++++++++++++-------------- 3 files changed, 44 insertions(+), 33 deletions(-) diff --git a/min/numeral-with-locales.min.js b/min/numeral-with-locales.min.js index c9ff4522..dec3d0a8 100644 --- a/min/numeral-with-locales.min.js +++ b/min/numeral-with-locales.min.js @@ -5,7 +5,7 @@ * 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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i=b.includes(" $")||b.includes("$ ")?" ":"";return b=b.replace(/\s?\$\s?/,""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e=b.includes(" %")?" ":"";return a=100*a,b=b.replace(/\s?\%/,""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i=b.includes(" b")||b.includes(" ib")?" ":"";for(b=b.replace(/\s?i?b/,""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e=b.includes(" o")?" ":"";return b=b.replace(/\s?o/,""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.replace(/e[\+|\-]{1}0/,""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r=1e12,t=1e9,v=1e6,w=1e3,x="",y=!1;return a=a||0,e=Math.abs(a),c.includes("(")?(i=!0,c=c.slice(1,-1)):c.includes("+")&&(j=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(m=c.includes("ak"),n=c.includes("am"),o=c.includes("ab"),p=c.includes("at"),q=m||n||o||p,c.includes(" a")&&(l=" "),c=c.replace(new RegExp(l+"a[kmbt]?"),""),e>=r&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=r):r>e&&e>=t&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=t):t>e&&e>=v&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=v):(v>e&&e>=w&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=w)),c.includes("[.]")&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.includes("[")?(g=g.replace("]",""),g=g.split("["),x=b(a,g[0].length+g[1].length,d,g[1].length)):x=b(a,g.length,d),f=x.split(".")[0],x=x.includes(".")?s[u.currentLocale].delimiters.decimal+x.split(".")[1]:"",k&&0===Number(x.slice(1))&&(x="")):f=b(a,null,d),f.includes("-")&&(f=f.slice(1),y=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&y?"(":"")+(!i&&y?"-":"")+(!y&&j?"+":"")+f+x+(l?l:"")+(i&&y?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.reset=function(){for(var a in t)u[a]=t[a]},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes=String.prototype.includes||function(a,b){return-1!==this.indexOf(a,b)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this),/*! @preserve +(function(){function a(a){this._value=a}function b(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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i=b.includes(" $")||b.includes("$ ")?" ":"";return b=b.replace(/\s?\$\s?/,""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=g>f||h>f?0:1,e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e=b.includes(" %")?" ":"";return a=100*a,b=b.replace(/\s?\%/,""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i=b.includes(" b")||b.includes(" ib")?" ":"";for(b=b.replace(/\s?i?b/,""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e=b.includes(" o")?" ":"";return b=b.replace(/\s?o/,""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.replace(/e[\+|\-]{1}0/,""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r=1e12,t=1e9,v=1e6,w=1e3,x="",y=!1;return a=a||0,e=Math.abs(a),c.includes("(")?(i=!0,c=c.slice(1,-1)):c.includes("+")&&(j=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(m=c.includes("ak"),n=c.includes("am"),o=c.includes("ab"),p=c.includes("at"),q=m||n||o||p,c.includes(" a")&&(l=" "),c=c.replace(new RegExp(l+"a[kmbt]?"),""),e>=r&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=r):r>e&&e>=t&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=t):t>e&&e>=v&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=v):(v>e&&e>=w&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=w)),c.includes("[.]")&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.includes("[")?(g=g.replace("]",""),g=g.split("["),x=b(a,g[0].length+g[1].length,d,g[1].length)):x=b(a,g.length,d),f=x.split(".")[0],x=x.includes(".")?s[u.currentLocale].delimiters.decimal+x.split(".")[1]:"",k&&0===Number(x.slice(1))&&(x="")):f=b(a,null,d),f.includes("-")&&(f=f.slice(1),y=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&y?"(":"")+(!i&&y?"-":"")+(!y&&j?"+":"")+f+x+(l?l:"")+(i&&y?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.reset=function(){for(var a in t)u[a]=t[a]},q.zeroFormat=function(a){return a?void(u.zeroFormat="string"==typeof a?a:null):u.zeroFormat},q.nullFormat=function(a){return a?void(u.nullFormat="string"==typeof a?a:null):u.nullFormat},q.defaultFormat=function(a){return a?void(u.defaultFormat="string"==typeof a?a:"0.0"):u.defaultFormat},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes=String.prototype.includes||function(a,b){return-1!==this.indexOf(a,b)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this),/*! @preserve * numeral.js locale configuration * locale : belgium-dutch (be-nl) * author : Dieter Luypaert : https://github.com/moeriki diff --git a/min/numeral.min.js b/min/numeral.min.js index 53f6391a..3ff08db7 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * 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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i=b.includes(" $")||b.includes("$ ")?" ":"";return b=b.replace(/\s?\$\s?/,""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e=b.includes(" %")?" ":"";return a=100*a,b=b.replace(/\s?\%/,""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i=b.includes(" b")||b.includes(" ib")?" ":"";for(b=b.replace(/\s?i?b/,""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e=b.includes(" o")?" ":"";return b=b.replace(/\s?o/,""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.replace(/e[\+|\-]{1}0/,""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r=1e12,t=1e9,v=1e6,w=1e3,x="",y=!1;return a=a||0,e=Math.abs(a),c.includes("(")?(i=!0,c=c.slice(1,-1)):c.includes("+")&&(j=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(m=c.includes("ak"),n=c.includes("am"),o=c.includes("ab"),p=c.includes("at"),q=m||n||o||p,c.includes(" a")&&(l=" "),c=c.replace(new RegExp(l+"a[kmbt]?"),""),e>=r&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=r):r>e&&e>=t&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=t):t>e&&e>=v&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=v):(v>e&&e>=w&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=w)),c.includes("[.]")&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.includes("[")?(g=g.replace("]",""),g=g.split("["),x=b(a,g[0].length+g[1].length,d,g[1].length)):x=b(a,g.length,d),f=x.split(".")[0],x=x.includes(".")?s[u.currentLocale].delimiters.decimal+x.split(".")[1]:"",k&&0===Number(x.slice(1))&&(x="")):f=b(a,null,d),f.includes("-")&&(f=f.slice(1),y=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&y?"(":"")+(!i&&y?"-":"")+(!y&&j?"+":"")+f+x+(l?l:"")+(i&&y?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.reset=function(){for(var a in t)u[a]=t[a]},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes=String.prototype.includes||function(a,b){return-1!==this.indexOf(a,b)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this); \ No newline at end of file +(function(){function a(a){this._value=a}function b(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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i=b.includes(" $")||b.includes("$ ")?" ":"";return b=b.replace(/\s?\$\s?/,""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=g>f||h>f?0:1,e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e=b.includes(" %")?" ":"";return a=100*a,b=b.replace(/\s?\%/,""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i=b.includes(" b")||b.includes(" ib")?" ":"";for(b=b.replace(/\s?i?b/,""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e=b.includes(" o")?" ":"";return b=b.replace(/\s?o/,""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.replace(/e[\+|\-]{1}0/,""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r=1e12,t=1e9,v=1e6,w=1e3,x="",y=!1;return a=a||0,e=Math.abs(a),c.includes("(")?(i=!0,c=c.slice(1,-1)):c.includes("+")&&(j=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(m=c.includes("ak"),n=c.includes("am"),o=c.includes("ab"),p=c.includes("at"),q=m||n||o||p,c.includes(" a")&&(l=" "),c=c.replace(new RegExp(l+"a[kmbt]?"),""),e>=r&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=r):r>e&&e>=t&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=t):t>e&&e>=v&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=v):(v>e&&e>=w&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=w)),c.includes("[.]")&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.includes("[")?(g=g.replace("]",""),g=g.split("["),x=b(a,g[0].length+g[1].length,d,g[1].length)):x=b(a,g.length,d),f=x.split(".")[0],x=x.includes(".")?s[u.currentLocale].delimiters.decimal+x.split(".")[1]:"",k&&0===Number(x.slice(1))&&(x="")):f=b(a,null,d),f.includes("-")&&(f=f.slice(1),y=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&y?"(":"")+(!i&&y?"-":"")+(!y&&j?"+":"")+f+x+(l?l:"")+(i&&y?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.reset=function(){for(var a in t)u[a]=t[a]},q.zeroFormat=function(a){return a?void(u.zeroFormat="string"==typeof a?a:null):u.zeroFormat},q.nullFormat=function(a){return a?void(u.nullFormat="string"==typeof a?a:null):u.nullFormat},q.defaultFormat=function(a){return a?void(u.defaultFormat="string"==typeof a?a:"0.0"):u.defaultFormat},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes=String.prototype.includes||function(a,b){return-1!==this.indexOf(a,b)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this); \ No newline at end of file diff --git a/numeral-with-locales.js b/numeral-with-locales.js index c8b6b70c..ccae4724 100644 --- a/numeral-with-locales.js +++ b/numeral-with-locales.js @@ -144,7 +144,7 @@ spliceIndex, output; - // check for space before or after currency + // strip format of spaces and $ format = format.replace(/\s?\$\s?/, ''); // format the number @@ -154,12 +154,11 @@ if (symbolIndex <= 1) { if (output.includes('(') || output.includes('-')) { output = output.split(''); - spliceIndex = 1; - if (symbolIndex < openParenIndex || symbolIndex < minusSignIndex) { - // the symbol appears before the "(" or "-" - spliceIndex = 0; - } + + spliceIndex = symbolIndex < openParenIndex || symbolIndex < minusSignIndex ? 0 : 1; + output.splice(spliceIndex, 0, locales[options.currentLocale].currency.symbol + space); + output = output.join(''); } else { output = locales[options.currentLocale].currency.symbol + space + output; @@ -167,7 +166,9 @@ } else { if (output.includes(')')) { output = output.split(''); + output.splice(-1, 0, space + locales[options.currentLocale].currency.symbol); + output = output.join(''); } else { output = output + space + locales[options.currentLocale].currency.symbol; @@ -190,7 +191,9 @@ if (output.includes(')')) { output = output.split(''); + output.splice(-1, 0, space + '%'); + output = output.join(''); } else { output = output + space + '%'; @@ -261,7 +264,7 @@ 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); + return hours + ':' + (minutes < 10 ? '0' + minutes : minutes) + ':' + (seconds < 10 ? '0' + seconds : seconds); } function formatNumber(value, format, roundingFunction) { @@ -490,7 +493,6 @@ return [value, Math.pow(10, power)].reduce(cback, 1); } - /************************************ Top Level Functions ************************************/ @@ -546,12 +548,6 @@ return numeral; }; - numeral.reset = function() { - for (var property in defaults) { - options[property] = defaults[property]; - } - }; - // This function provides access to the loaded locale data. If // no arguments are passed in, it will simply return the current // global locale object. @@ -592,15 +588,33 @@ } }); + numeral.reset = function() { + for (var property in defaults) { + options[property] = defaults[property]; + } + }; + numeral.zeroFormat = function(format) { + if (!format) { + return options.zeroFormat; + } + options.zeroFormat = typeof(format) === 'string' ? format : null; }; numeral.nullFormat = function (format) { + if (!format) { + return options.nullFormat; + } + options.nullFormat = typeof(format) === 'string' ? format : null; }; numeral.defaultFormat = function(format) { + if (!format) { + return options.defaultFormat; + } + options.defaultFormat = typeof(format) === 'string' ? format : '0.0'; }; @@ -617,6 +631,7 @@ //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); } @@ -626,7 +641,7 @@ val = val.trim(); //if val is just digits return true - if ( !! val.match(/^\d+$/)) { + if (!!val.match(/^\d+$/)) { return true; } @@ -755,10 +770,8 @@ */ function multiplier(x) { var parts = x.toString().split('.'); - if (parts.length < 2) { - return 1; - } - return Math.pow(10, parts[1].length); + + return parts.length < 2 ? 1 : Math.pow(10, parts[1].length); } /** @@ -768,6 +781,7 @@ */ function correctionFactor() { var args = Array.prototype.slice.call(arguments); + return args.reduce(function(accum, next) { var mn = multiplier(next); return accum > mn ? accum : mn; @@ -781,18 +795,15 @@ numeral.fn = Numeral.prototype = { - clone: function() { return numeral(this); }, - format: function (inputString, roundingFunction) { return formatNumeral(this, inputString ? inputString : options.defaultFormat, roundingFunction !== undefined ? roundingFunction : Math.round ); }, - unformat: function (inputString) { if (Object.prototype.toString.call(inputString) === '[object Number]') { return inputString; @@ -800,62 +811,62 @@ return unformatNumeral(this, inputString ? inputString : options.defaultFormat); }, - value: function() { return this._value; }, - valueOf: function() { return this._value; }, - 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 = [this._value, value].reduce(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 = [value].reduce(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 = [this._value, value].reduce(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 = [this._value, value].reduce(cback); + return this; }, - difference: function(value) { return Math.abs(numeral(this._value).subtract(value).value()); } - }; /************************************ From bca520f0a5e4a46c9f814f8da7e2ee09981c87b1 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Tue, 29 Nov 2016 23:15:39 -0800 Subject: [PATCH 085/150] clearer var names --- min/numeral-with-locales.min.js | 2 +- min/numeral.min.js | 2 +- numeral-with-locales.js | 46 ++++++++++++--------------------- numeral.js | 46 ++++++++++++--------------------- 4 files changed, 36 insertions(+), 60 deletions(-) diff --git a/min/numeral-with-locales.min.js b/min/numeral-with-locales.min.js index dec3d0a8..6c978e20 100644 --- a/min/numeral-with-locales.min.js +++ b/min/numeral-with-locales.min.js @@ -5,7 +5,7 @@ * 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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i=b.includes(" $")||b.includes("$ ")?" ":"";return b=b.replace(/\s?\$\s?/,""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=g>f||h>f?0:1,e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e=b.includes(" %")?" ":"";return a=100*a,b=b.replace(/\s?\%/,""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i=b.includes(" b")||b.includes(" ib")?" ":"";for(b=b.replace(/\s?i?b/,""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e=b.includes(" o")?" ":"";return b=b.replace(/\s?o/,""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.replace(/e[\+|\-]{1}0/,""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r=1e12,t=1e9,v=1e6,w=1e3,x="",y=!1;return a=a||0,e=Math.abs(a),c.includes("(")?(i=!0,c=c.slice(1,-1)):c.includes("+")&&(j=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(m=c.includes("ak"),n=c.includes("am"),o=c.includes("ab"),p=c.includes("at"),q=m||n||o||p,c.includes(" a")&&(l=" "),c=c.replace(new RegExp(l+"a[kmbt]?"),""),e>=r&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=r):r>e&&e>=t&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=t):t>e&&e>=v&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=v):(v>e&&e>=w&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=w)),c.includes("[.]")&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.includes("[")?(g=g.replace("]",""),g=g.split("["),x=b(a,g[0].length+g[1].length,d,g[1].length)):x=b(a,g.length,d),f=x.split(".")[0],x=x.includes(".")?s[u.currentLocale].delimiters.decimal+x.split(".")[1]:"",k&&0===Number(x.slice(1))&&(x="")):f=b(a,null,d),f.includes("-")&&(f=f.slice(1),y=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&y?"(":"")+(!i&&y?"-":"")+(!y&&j?"+":"")+f+x+(l?l:"")+(i&&y?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.reset=function(){for(var a in t)u[a]=t[a]},q.zeroFormat=function(a){return a?void(u.zeroFormat="string"==typeof a?a:null):u.zeroFormat},q.nullFormat=function(a){return a?void(u.nullFormat="string"==typeof a?a:null):u.nullFormat},q.defaultFormat=function(a){return a?void(u.defaultFormat="string"==typeof a?a:"0.0"):u.defaultFormat},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes=String.prototype.includes||function(a,b){return-1!==this.indexOf(a,b)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this),/*! @preserve +(function(){function a(a){this._value=a}function b(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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i=b.includes(" $")||b.includes("$ ")?" ":"";return b=b.replace(/\s?\$\s?/,""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=g>f||h>f?0:1,e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e=b.includes(" %")?" ":"";return a=100*a,b=b.replace(/\s?\%/,""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i=b.includes(" b")||b.includes(" ib")?" ":"";for(b=b.replace(/\s?i?b/,""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e=b.includes(" o")?" ":"";return b=b.replace(/\s?o/,""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.replace(/e[\+|\-]{1}0/,""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r=1e12,t=1e9,v=1e6,w=1e3,x="",y=!1;return a=a||0,e=Math.abs(a),c.includes("(")?(i=!0,c=c.slice(1,-1)):c.includes("+")&&(j=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(m=c.includes("ak"),n=c.includes("am"),o=c.includes("ab"),p=c.includes("at"),q=m||n||o||p,c.includes(" a")&&(l=" "),c=c.replace(new RegExp(l+"a[kmbt]?"),""),e>=r&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=r):r>e&&e>=t&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=t):t>e&&e>=v&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=v):(v>e&&e>=w&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=w)),c.includes("[.]")&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.includes("[")?(g=g.replace("]",""),g=g.split("["),x=b(a,g[0].length+g[1].length,d,g[1].length)):x=b(a,g.length,d),f=x.split(".")[0],x=x.includes(".")?s[u.currentLocale].delimiters.decimal+x.split(".")[1]:"",k&&0===Number(x.slice(1))&&(x="")):f=b(a,null,d),f.includes("-")&&(f=f.slice(1),y=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&y?"(":"")+(!i&&y?"-":"")+(!y&&j?"+":"")+f+x+(l?l:"")+(i&&y?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.reset=function(){for(var a in t)u[a]=t[a]},q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes=String.prototype.includes||function(a,b){return-1!==this.indexOf(a,b)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this),/*! @preserve * numeral.js locale configuration * locale : belgium-dutch (be-nl) * author : Dieter Luypaert : https://github.com/moeriki diff --git a/min/numeral.min.js b/min/numeral.min.js index 3ff08db7..b2f24096 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * 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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i=b.includes(" $")||b.includes("$ ")?" ":"";return b=b.replace(/\s?\$\s?/,""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=g>f||h>f?0:1,e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e=b.includes(" %")?" ":"";return a=100*a,b=b.replace(/\s?\%/,""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i=b.includes(" b")||b.includes(" ib")?" ":"";for(b=b.replace(/\s?i?b/,""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e=b.includes(" o")?" ":"";return b=b.replace(/\s?o/,""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.replace(/e[\+|\-]{1}0/,""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r=1e12,t=1e9,v=1e6,w=1e3,x="",y=!1;return a=a||0,e=Math.abs(a),c.includes("(")?(i=!0,c=c.slice(1,-1)):c.includes("+")&&(j=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(m=c.includes("ak"),n=c.includes("am"),o=c.includes("ab"),p=c.includes("at"),q=m||n||o||p,c.includes(" a")&&(l=" "),c=c.replace(new RegExp(l+"a[kmbt]?"),""),e>=r&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=r):r>e&&e>=t&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=t):t>e&&e>=v&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=v):(v>e&&e>=w&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=w)),c.includes("[.]")&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.includes("[")?(g=g.replace("]",""),g=g.split("["),x=b(a,g[0].length+g[1].length,d,g[1].length)):x=b(a,g.length,d),f=x.split(".")[0],x=x.includes(".")?s[u.currentLocale].delimiters.decimal+x.split(".")[1]:"",k&&0===Number(x.slice(1))&&(x="")):f=b(a,null,d),f.includes("-")&&(f=f.slice(1),y=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&y?"(":"")+(!i&&y?"-":"")+(!y&&j?"+":"")+f+x+(l?l:"")+(i&&y?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.reset=function(){for(var a in t)u[a]=t[a]},q.zeroFormat=function(a){return a?void(u.zeroFormat="string"==typeof a?a:null):u.zeroFormat},q.nullFormat=function(a){return a?void(u.nullFormat="string"==typeof a?a:null):u.nullFormat},q.defaultFormat=function(a){return a?void(u.defaultFormat="string"==typeof a?a:"0.0"):u.defaultFormat},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes=String.prototype.includes||function(a,b){return-1!==this.indexOf(a,b)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this); \ No newline at end of file +(function(){function a(a){this._value=a}function b(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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i=b.includes(" $")||b.includes("$ ")?" ":"";return b=b.replace(/\s?\$\s?/,""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=g>f||h>f?0:1,e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e=b.includes(" %")?" ":"";return a=100*a,b=b.replace(/\s?\%/,""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i=b.includes(" b")||b.includes(" ib")?" ":"";for(b=b.replace(/\s?i?b/,""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e=b.includes(" o")?" ":"";return b=b.replace(/\s?o/,""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.replace(/e[\+|\-]{1}0/,""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r=1e12,t=1e9,v=1e6,w=1e3,x="",y=!1;return a=a||0,e=Math.abs(a),c.includes("(")?(i=!0,c=c.slice(1,-1)):c.includes("+")&&(j=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(m=c.includes("ak"),n=c.includes("am"),o=c.includes("ab"),p=c.includes("at"),q=m||n||o||p,c.includes(" a")&&(l=" "),c=c.replace(new RegExp(l+"a[kmbt]?"),""),e>=r&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=r):r>e&&e>=t&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=t):t>e&&e>=v&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=v):(v>e&&e>=w&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=w)),c.includes("[.]")&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.includes("[")?(g=g.replace("]",""),g=g.split("["),x=b(a,g[0].length+g[1].length,d,g[1].length)):x=b(a,g.length,d),f=x.split(".")[0],x=x.includes(".")?s[u.currentLocale].delimiters.decimal+x.split(".")[1]:"",k&&0===Number(x.slice(1))&&(x="")):f=b(a,null,d),f.includes("-")&&(f=f.slice(1),y=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&y?"(":"")+(!i&&y?"-":"")+(!y&&j?"+":"")+f+x+(l?l:"")+(i&&y?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.reset=function(){for(var a in t)u[a]=t[a]},q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes=String.prototype.includes||function(a,b){return-1!==this.indexOf(a,b)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this); \ No newline at end of file diff --git a/numeral-with-locales.js b/numeral-with-locales.js index ccae4724..c40985a3 100644 --- a/numeral-with-locales.js +++ b/numeral-with-locales.js @@ -285,10 +285,10 @@ min, max, power, - w, + int, precision, thousands, - d = '', + decimal = '', neg = false; // make sure we never format a null value @@ -347,7 +347,7 @@ format = format.replace('[.]', '.'); } - w = value.toString().split('.')[0]; + int = value.toString().split('.')[0]; precision = format.split('.')[1]; thousands = format.indexOf(','); @@ -355,41 +355,41 @@ if (precision.includes('[')) { precision = precision.replace(']', ''); precision = precision.split('['); - d = toFixed(value, (precision[0].length + precision[1].length), roundingFunction, precision[1].length); + decimal = toFixed(value, (precision[0].length + precision[1].length), roundingFunction, precision[1].length); } else { - d = toFixed(value, precision.length, roundingFunction); + decimal = toFixed(value, precision.length, roundingFunction); } - w = d.split('.')[0]; + int = decimal.split('.')[0]; - if (d.includes('.')) { - d = locales[options.currentLocale].delimiters.decimal + d.split('.')[1]; + if (decimal.includes('.')) { + decimal = locales[options.currentLocale].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 = toFixed(value, null, roundingFunction); } // format number - if (w.includes('-')) { - w = w.slice(1); + if (int.includes('-')) { + int = int.slice(1); neg = true; } if (thousands > -1) { - w = w.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + locales[options.currentLocale].delimiters.thousands); + int = int.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + locales[options.currentLocale].delimiters.thousands); } if (format.indexOf('.') === 0) { - w = ''; + int = ''; } - return ((negP && neg) ? '(' : '') + ((!negP && neg) ? '-' : '') + ((!neg && signed) ? '+' : '') + w + d + ((abbr) ? abbr : '') + ((negP && neg) ? ')' : ''); + return (negP && neg ? '(' : '') + (!negP && neg ? '-' : '') + (!neg && signed ? '+' : '') + int + decimal + (abbr ? abbr : '') + (negP && neg ? ')' : ''); } @@ -595,26 +595,14 @@ }; numeral.zeroFormat = function(format) { - if (!format) { - return options.zeroFormat; - } - options.zeroFormat = typeof(format) === 'string' ? format : null; }; numeral.nullFormat = function (format) { - if (!format) { - return options.nullFormat; - } - options.nullFormat = typeof(format) === 'string' ? format : null; }; numeral.defaultFormat = function(format) { - if (!format) { - return options.defaultFormat; - } - options.defaultFormat = typeof(format) === 'string' ? format : '0.0'; }; diff --git a/numeral.js b/numeral.js index 7a3824e2..6ad0af92 100644 --- a/numeral.js +++ b/numeral.js @@ -285,10 +285,10 @@ min, max, power, - w, + int, precision, thousands, - d = '', + decimal = '', neg = false; // make sure we never format a null value @@ -347,7 +347,7 @@ format = format.replace('[.]', '.'); } - w = value.toString().split('.')[0]; + int = value.toString().split('.')[0]; precision = format.split('.')[1]; thousands = format.indexOf(','); @@ -355,41 +355,41 @@ if (precision.includes('[')) { precision = precision.replace(']', ''); precision = precision.split('['); - d = toFixed(value, (precision[0].length + precision[1].length), roundingFunction, precision[1].length); + decimal = toFixed(value, (precision[0].length + precision[1].length), roundingFunction, precision[1].length); } else { - d = toFixed(value, precision.length, roundingFunction); + decimal = toFixed(value, precision.length, roundingFunction); } - w = d.split('.')[0]; + int = decimal.split('.')[0]; - if (d.includes('.')) { - d = locales[options.currentLocale].delimiters.decimal + d.split('.')[1]; + if (decimal.includes('.')) { + decimal = locales[options.currentLocale].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 = toFixed(value, null, roundingFunction); } // format number - if (w.includes('-')) { - w = w.slice(1); + if (int.includes('-')) { + int = int.slice(1); neg = true; } if (thousands > -1) { - w = w.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + locales[options.currentLocale].delimiters.thousands); + int = int.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + locales[options.currentLocale].delimiters.thousands); } if (format.indexOf('.') === 0) { - w = ''; + int = ''; } - return ((negP && neg) ? '(' : '') + ((!negP && neg) ? '-' : '') + ((!neg && signed) ? '+' : '') + w + d + ((abbr) ? abbr : '') + ((negP && neg) ? ')' : ''); + return (negP && neg ? '(' : '') + (!negP && neg ? '-' : '') + (!neg && signed ? '+' : '') + int + decimal + (abbr ? abbr : '') + (negP && neg ? ')' : ''); } @@ -595,26 +595,14 @@ }; numeral.zeroFormat = function(format) { - if (!format) { - return options.zeroFormat; - } - options.zeroFormat = typeof(format) === 'string' ? format : null; }; numeral.nullFormat = function (format) { - if (!format) { - return options.nullFormat; - } - options.nullFormat = typeof(format) === 'string' ? format : null; }; numeral.defaultFormat = function(format) { - if (!format) { - return options.defaultFormat; - } - options.defaultFormat = typeof(format) === 'string' ? format : '0.0'; }; From d2563605c52e30e4fb3266da194efc6224461060 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Tue, 29 Nov 2016 23:24:15 -0800 Subject: [PATCH 086/150] add edge version --- numeral.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/numeral.js b/numeral.js index 6ad0af92..424cbf3b 100644 --- a/numeral.js +++ b/numeral.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js - * version : 1.5.6 + * version : Edge * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ @@ -13,7 +13,7 @@ ************************************/ var numeral, - VERSION = '1.5.6', + VERSION = 'Edge', // internal storage for locale config files locales = {}, defaults = { From f73585adae59d57ce33fdbe1769de2a11c3cb896 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Tue, 29 Nov 2016 23:39:16 -0800 Subject: [PATCH 087/150] use regex for force abbr --- min/numeral-with-locales.min.js | 4 ++-- min/numeral.min.js | 4 ++-- numeral-with-locales.js | 27 ++++++++++----------------- numeral.js | 23 ++++++++--------------- 4 files changed, 22 insertions(+), 36 deletions(-) diff --git a/min/numeral-with-locales.min.js b/min/numeral-with-locales.min.js index 6c978e20..442cf3d6 100644 --- a/min/numeral-with-locales.min.js +++ b/min/numeral-with-locales.min.js @@ -1,11 +1,11 @@ /*! @preserve * numeral.js - * version : 1.5.6 + * version : Edge * 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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i=b.includes(" $")||b.includes("$ ")?" ":"";return b=b.replace(/\s?\$\s?/,""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=g>f||h>f?0:1,e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e=b.includes(" %")?" ":"";return a=100*a,b=b.replace(/\s?\%/,""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i=b.includes(" b")||b.includes(" ib")?" ":"";for(b=b.replace(/\s?i?b/,""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e=b.includes(" o")?" ":"";return b=b.replace(/\s?o/,""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.replace(/e[\+|\-]{1}0/,""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r=1e12,t=1e9,v=1e6,w=1e3,x="",y=!1;return a=a||0,e=Math.abs(a),c.includes("(")?(i=!0,c=c.slice(1,-1)):c.includes("+")&&(j=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(m=c.includes("ak"),n=c.includes("am"),o=c.includes("ab"),p=c.includes("at"),q=m||n||o||p,c.includes(" a")&&(l=" "),c=c.replace(new RegExp(l+"a[kmbt]?"),""),e>=r&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=r):r>e&&e>=t&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=t):t>e&&e>=v&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=v):(v>e&&e>=w&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=w)),c.includes("[.]")&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.includes("[")?(g=g.replace("]",""),g=g.split("["),x=b(a,g[0].length+g[1].length,d,g[1].length)):x=b(a,g.length,d),f=x.split(".")[0],x=x.includes(".")?s[u.currentLocale].delimiters.decimal+x.split(".")[1]:"",k&&0===Number(x.slice(1))&&(x="")):f=b(a,null,d),f.includes("-")&&(f=f.slice(1),y=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&y?"(":"")+(!i&&y?"-":"")+(!y&&j?"+":"")+f+x+(l?l:"")+(i&&y?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.reset=function(){for(var a in t)u[a]=t[a]},q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes=String.prototype.includes||function(a,b){return-1!==this.indexOf(a,b)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this),/*! @preserve +(function(){function a(a){this._value=a}function b(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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i=b.includes(" $")||b.includes("$ ")?" ":"";return b=b.replace(/\s?\$\s?/,""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=g>f||h>f?0:1,e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e=b.includes(" %")?" ":"";return a=100*a,b=b.replace(/\s?\%/,""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i=b.includes(" b")||b.includes(" ib")?" ":"";for(b=b.replace(/\s?i?b/,""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e=b.includes(" o")?" ":"";return b=b.replace(/\s?o/,""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.replace(/e[\+|\-]{1}0/,""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i,j=!1,k=!1,l=!1,m="",n=1e12,o=1e9,p=1e6,q=1e3,r="",t=!1;return a=a||0,f=Math.abs(a),c.includes("(")?(j=!0,c=c.slice(1,-1)):c.includes("+")&&(k=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(e=c.match(/a(k|m|b|t)?/),e=e?e[1]:!1,c.includes(" a")&&(m=" "),c=c.replace(new RegExp(m+"a[kmbt]?"),""),f>=n&&!e||"t"===e?(m+=s[u.currentLocale].abbreviations.trillion,a/=n):n>f&&f>=o&&!e||"b"===e?(m+=s[u.currentLocale].abbreviations.billion,a/=o):o>f&&f>=p&&!e||"m"===e?(m+=s[u.currentLocale].abbreviations.million,a/=p):(p>f&&f>=q&&!e||"k"===e)&&(m+=s[u.currentLocale].abbreviations.thousand,a/=q)),c.includes("[.]")&&(l=!0,c=c.replace("[.]",".")),g=a.toString().split(".")[0],h=c.split(".")[1],i=c.indexOf(","),h?(h.includes("[")?(h=h.replace("]",""),h=h.split("["),r=b(a,h[0].length+h[1].length,d,h[1].length)):r=b(a,h.length,d),g=r.split(".")[0],r=r.includes(".")?s[u.currentLocale].delimiters.decimal+r.split(".")[1]:"",l&&0===Number(r.slice(1))&&(r="")):g=b(a,null,d),g.includes("-")&&(g=g.slice(1),t=!0),i>-1&&(g=g.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(g=""),(j&&t?"(":"")+(!j&&t?"-":"")+(!t&&k?"+":"")+g+r+(m?m:"")+(j&&t?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="Edge",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.reset=function(){for(var a in t)u[a]=t[a]},q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes=String.prototype.includes||function(a,b){return-1!==this.indexOf(a,b)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this),/*! @preserve * numeral.js locale configuration * locale : belgium-dutch (be-nl) * author : Dieter Luypaert : https://github.com/moeriki diff --git a/min/numeral.min.js b/min/numeral.min.js index b2f24096..ad752619 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -1,8 +1,8 @@ /*! @preserve * numeral.js - * version : 1.5.6 + * version : Edge * 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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i=b.includes(" $")||b.includes("$ ")?" ":"";return b=b.replace(/\s?\$\s?/,""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=g>f||h>f?0:1,e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e=b.includes(" %")?" ":"";return a=100*a,b=b.replace(/\s?\%/,""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i=b.includes(" b")||b.includes(" ib")?" ":"";for(b=b.replace(/\s?i?b/,""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e=b.includes(" o")?" ":"";return b=b.replace(/\s?o/,""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.replace(/e[\+|\-]{1}0/,""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i=!1,j=!1,k=!1,l="",m=!1,n=!1,o=!1,p=!1,q=!1,r=1e12,t=1e9,v=1e6,w=1e3,x="",y=!1;return a=a||0,e=Math.abs(a),c.includes("(")?(i=!0,c=c.slice(1,-1)):c.includes("+")&&(j=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(m=c.includes("ak"),n=c.includes("am"),o=c.includes("ab"),p=c.includes("at"),q=m||n||o||p,c.includes(" a")&&(l=" "),c=c.replace(new RegExp(l+"a[kmbt]?"),""),e>=r&&!q||p?(l+=s[u.currentLocale].abbreviations.trillion,a/=r):r>e&&e>=t&&!q||o?(l+=s[u.currentLocale].abbreviations.billion,a/=t):t>e&&e>=v&&!q||n?(l+=s[u.currentLocale].abbreviations.million,a/=v):(v>e&&e>=w&&!q||m)&&(l+=s[u.currentLocale].abbreviations.thousand,a/=w)),c.includes("[.]")&&(k=!0,c=c.replace("[.]",".")),f=a.toString().split(".")[0],g=c.split(".")[1],h=c.indexOf(","),g?(g.includes("[")?(g=g.replace("]",""),g=g.split("["),x=b(a,g[0].length+g[1].length,d,g[1].length)):x=b(a,g.length,d),f=x.split(".")[0],x=x.includes(".")?s[u.currentLocale].delimiters.decimal+x.split(".")[1]:"",k&&0===Number(x.slice(1))&&(x="")):f=b(a,null,d),f.includes("-")&&(f=f.slice(1),y=!0),h>-1&&(f=f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(f=""),(i&&y?"(":"")+(!i&&y?"-":"")+(!y&&j?"+":"")+f+x+(l?l:"")+(i&&y?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="1.5.6",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.reset=function(){for(var a in t)u[a]=t[a]},q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes=String.prototype.includes||function(a,b){return-1!==this.indexOf(a,b)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this); \ No newline at end of file +(function(){function a(a){this._value=a}function b(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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i=b.includes(" $")||b.includes("$ ")?" ":"";return b=b.replace(/\s?\$\s?/,""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=g>f||h>f?0:1,e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e=b.includes(" %")?" ":"";return a=100*a,b=b.replace(/\s?\%/,""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i=b.includes(" b")||b.includes(" ib")?" ":"";for(b=b.replace(/\s?i?b/,""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e=b.includes(" o")?" ":"";return b=b.replace(/\s?o/,""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.replace(/e[\+|\-]{1}0/,""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i,j=!1,k=!1,l=!1,m="",n=1e12,o=1e9,p=1e6,q=1e3,r="",t=!1;return a=a||0,f=Math.abs(a),c.includes("(")?(j=!0,c=c.slice(1,-1)):c.includes("+")&&(k=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(e=c.match(/a(k|m|b|t)?/),e=e?e[1]:!1,c.includes(" a")&&(m=" "),c=c.replace(new RegExp(m+"a[kmbt]?"),""),f>=n&&!e||"t"===e?(m+=s[u.currentLocale].abbreviations.trillion,a/=n):n>f&&f>=o&&!e||"b"===e?(m+=s[u.currentLocale].abbreviations.billion,a/=o):o>f&&f>=p&&!e||"m"===e?(m+=s[u.currentLocale].abbreviations.million,a/=p):(p>f&&f>=q&&!e||"k"===e)&&(m+=s[u.currentLocale].abbreviations.thousand,a/=q)),c.includes("[.]")&&(l=!0,c=c.replace("[.]",".")),g=a.toString().split(".")[0],h=c.split(".")[1],i=c.indexOf(","),h?(h.includes("[")?(h=h.replace("]",""),h=h.split("["),r=b(a,h[0].length+h[1].length,d,h[1].length)):r=b(a,h.length,d),g=r.split(".")[0],r=r.includes(".")?s[u.currentLocale].delimiters.decimal+r.split(".")[1]:"",l&&0===Number(r.slice(1))&&(r="")):g=b(a,null,d),g.includes("-")&&(g=g.slice(1),t=!0),i>-1&&(g=g.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(g=""),(j&&t?"(":"")+(!j&&t?"-":"")+(!t&&k?"+":"")+g+r+(m?m:"")+(j&&t?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="Edge",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.reset=function(){for(var a in t)u[a]=t[a]},q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes=String.prototype.includes||function(a,b){return-1!==this.indexOf(a,b)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this); \ No newline at end of file diff --git a/numeral-with-locales.js b/numeral-with-locales.js index c40985a3..4404e666 100644 --- a/numeral-with-locales.js +++ b/numeral-with-locales.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js - * version : 1.5.6 + * version : Edge * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ @@ -13,7 +13,7 @@ ************************************/ var numeral, - VERSION = '1.5.6', + VERSION = 'Edge', // internal storage for locale config files locales = {}, defaults = { @@ -272,15 +272,11 @@ 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 trillion = 1000000000000, billion = 1000000000, million = 1000000, thousand = 1000, + abbrForce, // force abbreviation abs, min, max, @@ -308,12 +304,9 @@ // see if abbreviation is wanted if (format.includes('a')) { - // check if abbreviation is specified - abbrK = format.includes('ak'); - abbrM = format.includes('am'); - abbrB = format.includes('ab'); - abbrT = format.includes('at'); - abbrForce = abbrK || abbrM || abbrB || abbrT; + abbrForce = format.match(/a(k|m|b|t)?/); + + abbrForce = abbrForce ? abbrForce[1] : false; // check for space before abbreviation if (format.includes(' a')) { @@ -322,19 +315,19 @@ format = format.replace(new RegExp(abbr + 'a[kmbt]?'), ''); - if (abs >= trillion && !abbrForce || abbrT) { + if (abs >= trillion && !abbrForce || abbrForce === 't') { // trillion abbr += locales[options.currentLocale].abbreviations.trillion; value = value / trillion; - } else if (abs < trillion && abs >= billion && !abbrForce || abbrB) { + } else if (abs < trillion && abs >= billion && !abbrForce || abbrForce === 'b') { // billion abbr += locales[options.currentLocale].abbreviations.billion; value = value / billion; - } else if (abs < billion && abs >= million && !abbrForce || abbrM) { + } else if (abs < billion && abs >= million && !abbrForce || abbrForce === 'm') { // million abbr += locales[options.currentLocale].abbreviations.million; value = value / million; - } else if (abs < million && abs >= thousand && !abbrForce || abbrK) { + } else if (abs < million && abs >= thousand && !abbrForce || abbrForce === 'k') { // thousand abbr += locales[options.currentLocale].abbreviations.thousand; value = value / thousand; diff --git a/numeral.js b/numeral.js index 424cbf3b..00cc7086 100644 --- a/numeral.js +++ b/numeral.js @@ -272,15 +272,11 @@ 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 trillion = 1000000000000, billion = 1000000000, million = 1000000, thousand = 1000, + abbrForce, // force abbreviation abs, min, max, @@ -308,12 +304,9 @@ // see if abbreviation is wanted if (format.includes('a')) { - // check if abbreviation is specified - abbrK = format.includes('ak'); - abbrM = format.includes('am'); - abbrB = format.includes('ab'); - abbrT = format.includes('at'); - abbrForce = abbrK || abbrM || abbrB || abbrT; + abbrForce = format.match(/a(k|m|b|t)?/); + + abbrForce = abbrForce ? abbrForce[1] : false; // check for space before abbreviation if (format.includes(' a')) { @@ -322,19 +315,19 @@ format = format.replace(new RegExp(abbr + 'a[kmbt]?'), ''); - if (abs >= trillion && !abbrForce || abbrT) { + if (abs >= trillion && !abbrForce || abbrForce === 't') { // trillion abbr += locales[options.currentLocale].abbreviations.trillion; value = value / trillion; - } else if (abs < trillion && abs >= billion && !abbrForce || abbrB) { + } else if (abs < trillion && abs >= billion && !abbrForce || abbrForce === 'b') { // billion abbr += locales[options.currentLocale].abbreviations.billion; value = value / billion; - } else if (abs < billion && abs >= million && !abbrForce || abbrM) { + } else if (abs < billion && abs >= million && !abbrForce || abbrForce === 'm') { // million abbr += locales[options.currentLocale].abbreviations.million; value = value / million; - } else if (abs < million && abs >= thousand && !abbrForce || abbrK) { + } else if (abs < million && abs >= thousand && !abbrForce || abbrForce === 'k') { // thousand abbr += locales[options.currentLocale].abbreviations.thousand; value = value / thousand; From 3dd091ff4805c4b57fd723fe73d8c0e78e604def Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Wed, 30 Nov 2016 22:14:24 -0800 Subject: [PATCH 088/150] move files to src directory --- Gruntfile.js | 23 +- locales.js | 63 ++- min/locales.min.js | 155 +----- min/locales/be-nl.min.js | 5 - min/locales/bg.min.js | 5 - min/locales/chs.min.js | 5 - min/locales/cs.min.js | 5 - min/locales/da-dk.min.js | 5 - min/locales/de-ch.min.js | 5 - min/locales/de.min.js | 5 - min/locales/en-au.min.js | 5 - min/locales/en-gb.min.js | 5 - min/locales/en-za.min.js | 5 - min/locales/es-ES.min.js | 5 - min/locales/es.min.js | 5 - min/locales/et.min.js | 8 - min/locales/fi.min.js | 5 - min/locales/fr-CA.min.js | 5 - min/locales/fr-ch.min.js | 5 - min/locales/fr.min.js | 5 - min/locales/hu.min.js | 5 - min/locales/it.min.js | 5 - min/locales/ja.min.js | 5 - min/locales/lv.min.js | 5 - min/locales/nl-nl.min.js | 5 - min/locales/no.min.js | 5 - min/locales/pl.min.js | 5 - min/locales/pt-br.min.js | 5 - min/locales/pt-pt.min.js | 5 - min/locales/ru.min.js | 5 - min/locales/sk.min.js | 5 - min/locales/th.min.js | 5 - min/locales/tr.min.js | 5 - min/numeral-with-locales.min.js | 155 +----- numeral-with-locales.js | 63 ++- {locales => src/locales}/be-nl.js | 2 +- {locales => src/locales}/bg.js | 2 +- {locales => src/locales}/chs.js | 2 +- {locales => src/locales}/cs.js | 2 +- {locales => src/locales}/da-dk.js | 2 +- {locales => src/locales}/de-ch.js | 2 +- {locales => src/locales}/de.js | 2 +- {locales => src/locales}/en-au.js | 2 +- {locales => src/locales}/en-gb.js | 2 +- {locales => src/locales}/en-za.js | 4 +- {locales => src/locales}/es-es.js | 2 +- {locales => src/locales}/es.js | 2 +- {locales => src/locales}/et.js | 2 +- {locales => src/locales}/fi.js | 2 +- {locales => src/locales}/fr-ca.js | 4 +- {locales => src/locales}/fr-ch.js | 2 +- {locales => src/locales}/fr.js | 2 +- {locales => src/locales}/hu.js | 2 +- {locales => src/locales}/it.js | 2 +- {locales => src/locales}/ja.js | 2 +- {locales => src/locales}/lv.js | 2 +- {locales => src/locales}/nl-nl.js | 2 +- {locales => src/locales}/no.js | 4 +- {locales => src/locales}/pl.js | 2 +- {locales => src/locales}/pt-br.js | 2 +- {locales => src/locales}/pt-pt.js | 2 +- {locales => src/locales}/ru-ua.js | 0 {locales => src/locales}/ru.js | 2 +- {locales => src/locales}/sk.js | 2 +- {locales => src/locales}/th.js | 2 +- {locales => src/locales}/tr.js | 2 +- {locales => src/locales}/uk-ua.js | 0 src/numeral.js | 876 ++++++++++++++++++++++++++++++ tests/locales/be-nl.js | 4 +- tests/locales/bg.js | 4 +- tests/locales/chs.js | 4 +- tests/locales/cs.js | 4 +- tests/locales/da-dk.js | 4 +- tests/locales/de-ch.js | 4 +- tests/locales/de.js | 4 +- tests/locales/en-au.js | 4 +- tests/locales/en-gb.js | 4 +- tests/locales/en-za.js | 4 +- tests/locales/en.js | 2 +- tests/locales/es-es.js | 4 +- tests/locales/es.js | 4 +- tests/locales/et.js | 4 +- tests/locales/fi.js | 4 +- tests/locales/fr-ca.js | 4 +- tests/locales/fr-ch.js | 4 +- tests/locales/fr.js | 4 +- tests/locales/hu.js | 4 +- tests/locales/it.js | 4 +- tests/locales/ja.js | 4 +- tests/locales/lv.js | 4 +- tests/locales/nl-nl.js | 4 +- tests/locales/no.js | 4 +- tests/locales/pl.js | 4 +- tests/locales/pt-br.js | 4 +- tests/locales/pt-pt.js | 4 +- tests/locales/ru-ua.js | 4 +- tests/locales/ru.js | 4 +- tests/locales/sk.js | 4 +- tests/locales/th.js | 4 +- tests/locales/tr.js | 4 +- tests/locales/uk-ua.js | 4 +- tests/numeral/format.js | 2 +- tests/numeral/manipulate.js | 2 +- tests/numeral/misc.js | 2 +- tests/numeral/unformat.js | 2 +- tests/numeral/validate.js | 2 +- 106 files changed, 1061 insertions(+), 633 deletions(-) rename {locales => src/locales}/be-nl.js (98%) rename {locales => src/locales}/bg.js (98%) rename {locales => src/locales}/chs.js (94%) rename {locales => src/locales}/cs.js (98%) rename {locales => src/locales}/da-dk.js (98%) rename {locales => src/locales}/de-ch.js (98%) rename {locales => src/locales}/de.js (98%) rename {locales => src/locales}/en-au.js (98%) rename {locales => src/locales}/en-gb.js (98%) rename {locales => src/locales}/en-za.js (99%) rename {locales => src/locales}/es-es.js (98%) rename {locales => src/locales}/es.js (98%) rename {locales => src/locales}/et.js (98%) rename {locales => src/locales}/fi.js (98%) rename {locales => src/locales}/fr-ca.js (97%) rename {locales => src/locales}/fr-ch.js (98%) rename {locales => src/locales}/fr.js (98%) rename {locales => src/locales}/hu.js (98%) rename {locales => src/locales}/it.js (98%) rename {locales => src/locales}/ja.js (98%) rename {locales => src/locales}/lv.js (98%) rename {locales => src/locales}/nl-nl.js (98%) rename {locales => src/locales}/no.js (98%) rename {locales => src/locales}/pl.js (98%) rename {locales => src/locales}/pt-br.js (98%) rename {locales => src/locales}/pt-pt.js (98%) rename {locales => src/locales}/ru-ua.js (100%) rename {locales => src/locales}/ru.js (98%) rename {locales => src/locales}/sk.js (98%) rename {locales => src/locales}/th.js (98%) rename {locales => src/locales}/tr.js (99%) rename {locales => src/locales}/uk-ua.js (100%) create mode 100644 src/numeral.js diff --git a/Gruntfile.js b/Gruntfile.js index 96702826..29bdc8d4 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -15,10 +15,10 @@ module.exports = function(grunt) { }; // all the lang files need to be added manually - fs.readdirSync('./locales').forEach(function (path) { + fs.readdirSync('./src/locales').forEach(function (path) { var file = path.slice(0, -3), destination = 'min/locales/' + file + '.min.js', - src = ['locales/' + path]; + src = ['src/locales/' + path]; minifiedFiles[destination] = src; }); @@ -33,8 +33,8 @@ module.exports = function(grunt) { karma: { options: { files: [ - 'numeral.js', - 'locales/*.js', + 'src/numeral.js', + 'src/locales/*.js', 'tests/numeral/*.js', 'tests/locales/*.js' ], @@ -64,16 +64,22 @@ module.exports = function(grunt) { } }, concat: { + numeral: { + src: [ + 'src/numeral.js' + ], + dest: 'numeral.js' + }, locales: { src: [ - 'locales/*.js' + 'src/locales/*.js' ], dest: 'locales.js' }, numeralWithLocales: { src: [ - 'numeral.js', - 'locales/*.js' + 'src/numeral.js', + 'src/locales/*.js' ], dest: 'numeral-with-locales.js' } @@ -81,8 +87,7 @@ module.exports = function(grunt) { jshint: { all: [ 'Gruntfile.js', - 'numeral.js', - 'locales/*.js' + 'src/**/*.js' ], options: { 'node': true, diff --git a/locales.js b/locales.js index dfae29a3..dfea3008 100644 --- a/locales.js +++ b/locales.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * numeral.js locale configuration * locale : belgium-dutch (be-nl) * author : Dieter Luypaert : https://github.com/moeriki @@ -34,7 +34,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : Bulgarian * author : Don Vince : https://github.com/donvince/ @@ -77,7 +77,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : simplified chinese * author : badplum : https://github.com/badplum @@ -112,7 +112,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : czech (cs) * author : Anatoli Papirovski : https://github.com/apapirovski @@ -147,7 +147,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : danish denmark (dk) * author : Michael Storgaard : https://github.com/mstorgaard @@ -181,7 +181,7 @@ this.numeral.locale('da-dk', locale); } }()); -/*! @preserve +/* * 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) @@ -215,7 +215,7 @@ this.numeral.locale('de-ch', locale); } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium * author : Marco Krage : https://github.com/sinky @@ -249,7 +249,7 @@ this.numeral.locale('de', locale); } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : English Australia * author : Don Vince : https://github.com/donvince/ @@ -288,7 +288,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : english united kingdom (uk) * author : Dan Ristic : https://github.com/dristic @@ -326,7 +326,7 @@ this.numeral.locale('en-gb', locale); } }()); -/*! +/* * numeral.js locale configuration * locale : english south africa (uk) * author : Etienne Boshoff : etienne@zailab.com @@ -364,7 +364,8 @@ this.numeral.locale('en-za', locale); } }()); -/*! @preserve + +/* * numeral.js locale configuration * locale : spanish Spain * author : Hernan Garcia : https://github.com/hgarcia @@ -404,7 +405,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : spanish * author : Hernan Garcia : https://github.com/hgarcia @@ -444,7 +445,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : Estonian * author : Illimar Tambek : https://github.com/ragulka @@ -482,7 +483,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : Finnish * author : Sami Saada : https://github.com/samitheberber @@ -517,7 +518,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : french (Canada) (fr-ca) * author : Léo Renaud-Allaire : https://github.com/renaudleo @@ -551,7 +552,8 @@ this.numeral.locale('fr-ca', locale); } }()); -/*! @preserve + +/* * numeral.js locale configuration * locale : french (fr-ch) * author : Adam Draper : https://github.com/adamwdraper @@ -586,7 +588,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : french (fr) * author : Adam Draper : https://github.com/adamwdraper @@ -620,7 +622,7 @@ this.numeral.locale('fr', locale); } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : Hungarian (hu) * author : Peter Bakondy : https://github.com/pbakondy @@ -654,7 +656,7 @@ this.numeral.locale('hu', locale); } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : italian Italy (it) * author : Giacomo Trombi : http://cinquepunti.it @@ -688,7 +690,7 @@ this.numeral.locale('it', locale); } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : japanese * author : teppeis : https://github.com/teppeis @@ -723,7 +725,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : Latvian (lv) * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks @@ -757,7 +759,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : netherlands-dutch (nl-nl) * author : Dave Clayton : https://github.com/davedx @@ -792,7 +794,7 @@ this.numeral.locale('nl-nl', locale); } }()); -/*! +/* * numeral.js locale configuration * locale : norwegian (bokmål) * author : Ove Andersen : https://github.com/azzlack @@ -830,7 +832,8 @@ this.numeral.locale('nn', locale); } }()); -/*! @preserve + +/* * numeral.js locale configuration * locale : polish (pl) * author : Dominik Bulaj : https://github.com/dominikbulaj @@ -864,7 +867,7 @@ this.numeral.locale('pl', locale); } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : portuguese brazil (pt-br) * author : Ramiro Varandas Jr : https://github.com/ramirovjr @@ -898,7 +901,7 @@ this.numeral.locale('pt-br', locale); } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : portuguese (pt-pt) * author : Diogo Resende : https://github.com/dresende @@ -969,7 +972,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : russian (ru) * author : Anatoli Papirovski : https://github.com/apapirovski @@ -1007,7 +1010,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : slovak (sk) * author : Ahmed Al Hafoudh : http://www.freevision.sk @@ -1042,7 +1045,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : thai (th) * author : Sathit Jittanupat : https://github.com/jojosati @@ -1077,7 +1080,7 @@ } }()); -/*! @preserve +/* * 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 diff --git a/min/locales.min.js b/min/locales.min.js index 33f4dde8..aa8e858f 100644 --- a/min/locales.min.js +++ b/min/locales.min.js @@ -1,154 +1 @@ -/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("be-nl",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : Bulgarian - * author : Don Vince : https://github.com/donvince/ - */ -function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("bg",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : simplified chinese - * author : badplum : https://github.com/badplum - */ -function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("chs",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("cs",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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(a){return"."},currency:{symbol:"DKK"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("da-dk",a)}(),/*! @preserve - * 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(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"CHF"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de-ch",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : English Australia - * author : Don Vince : https://github.com/donvince/ - */ -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.locale&&this.numeral.locale("en-au",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("en-gb",a)}(),/*! - * numeral.js locale configuration - * locale : english south africa (uk) - * author : Etienne Boshoff : etienne@zailab.com - */ -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:"R"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("en-za",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("es-es",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("es",a)}(),/*! @preserve - * 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(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("et",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("fi",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("fr-ca",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("fr-ch",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("fr",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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(a){return"."},currency:{symbol:" Ft"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("hu",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("it",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : japanese - * author : teppeis : https://github.com/teppeis - */ -function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("ja",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : Latvian (lv) - * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks - */ -function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("lv",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("nl-nl",a)}(),/*! - * numeral.js locale configuration - * locale : norwegian (bokmål) - * author : Ove Andersen : https://github.com/azzlack - */ -function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&(this.numeral.locale("nb-no",a),this.numeral.locale("nn-no",a),this.numeral.locale("no",a),this.numeral.locale("nb",a),this.numeral.locale("nn",a))}(),/*! @preserve - * numeral.js locale configuration - * locale : 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(a){return"."},currency:{symbol:"PLN"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pl",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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(a){return"º"},currency:{symbol:"R$"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pt-br",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("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.locale&&this.numeral.locale("ru-ua",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : russian (ru) - * author : Anatoli Papirovski : https://github.com/apapirovski - */ -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.locale&&this.numeral.locale("ru",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("sk",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : thai (th) - * author : Sathit Jittanupat : https://github.com/jojosati - */ -function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("th",a)}(),/*! @preserve - * 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(){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.locale&&this.numeral.locale("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.locale&&this.numeral.locale("uk-ua",a)}(); \ No newline at end of file +!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.locale&&this.numeral.locale("be-nl",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("bg",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("chs",a)}(),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.locale&&this.numeral.locale("cs",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mia",trillion:"b"},ordinal:function(a){return"."},currency:{symbol:"DKK"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("da-dk",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"CHF"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de-ch",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de",a)}(),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.locale&&this.numeral.locale("en-au",a)}(),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.locale&&this.numeral.locale("en-gb",a)}(),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:"R"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("en-za",a)}(),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.locale&&this.numeral.locale("es-es",a)}(),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.locale&&this.numeral.locale("es",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("et",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("fi",a)}(),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.locale&&this.numeral.locale("fr-ca",a)}(),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.locale&&this.numeral.locale("fr-ch",a)}(),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.locale&&this.numeral.locale("fr",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("hu",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("it",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("ja",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("lv",a)}(),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.locale&&this.numeral.locale("nl-nl",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&(this.numeral.locale("nb-no",a),this.numeral.locale("nn-no",a),this.numeral.locale("no",a),this.numeral.locale("nb",a),this.numeral.locale("nn",a))}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pl",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mil",million:"milhões",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"R$"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pt-br",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("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.locale&&this.numeral.locale("ru-ua",a)}(),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.locale&&this.numeral.locale("ru",a)}(),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.locale&&this.numeral.locale("sk",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("th",a)}(),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.locale&&this.numeral.locale("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.locale&&this.numeral.locale("uk-ua",a)}(); \ No newline at end of file diff --git a/min/locales/be-nl.min.js b/min/locales/be-nl.min.js index 45b353bc..87291407 100644 --- a/min/locales/be-nl.min.js +++ b/min/locales/be-nl.min.js @@ -1,6 +1 @@ -/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("be-nl",a)}(); \ No newline at end of file diff --git a/min/locales/bg.min.js b/min/locales/bg.min.js index 138bdb6d..c46f1c6e 100644 --- a/min/locales/bg.min.js +++ b/min/locales/bg.min.js @@ -1,6 +1 @@ -/*! @preserve - * numeral.js locale configuration - * locale : Bulgarian - * author : Don Vince : https://github.com/donvince/ - */ !function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("bg",a)}(); \ No newline at end of file diff --git a/min/locales/chs.min.js b/min/locales/chs.min.js index 532af4de..d529790e 100644 --- a/min/locales/chs.min.js +++ b/min/locales/chs.min.js @@ -1,6 +1 @@ -/*! @preserve - * numeral.js locale configuration - * locale : simplified chinese - * author : badplum : https://github.com/badplum - */ !function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("chs",a)}(); \ No newline at end of file diff --git a/min/locales/cs.min.js b/min/locales/cs.min.js index ff93d158..8021da66 100644 --- a/min/locales/cs.min.js +++ b/min/locales/cs.min.js @@ -1,6 +1 @@ -/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("cs",a)}(); \ No newline at end of file diff --git a/min/locales/da-dk.min.js b/min/locales/da-dk.min.js index d12df301..6b7f5ab0 100644 --- a/min/locales/da-dk.min.js +++ b/min/locales/da-dk.min.js @@ -1,6 +1 @@ -/*! @preserve - * numeral.js locale configuration - * locale : 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(a){return"."},currency:{symbol:"DKK"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("da-dk",a)}(); \ No newline at end of file diff --git a/min/locales/de-ch.min.js b/min/locales/de-ch.min.js index 90e0bd13..0dfcb5ff 100644 --- a/min/locales/de-ch.min.js +++ b/min/locales/de-ch.min.js @@ -1,6 +1 @@ -/*! @preserve - * 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(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"CHF"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de-ch",a)}(); \ No newline at end of file diff --git a/min/locales/de.min.js b/min/locales/de.min.js index 9506a501..7cae51bb 100644 --- a/min/locales/de.min.js +++ b/min/locales/de.min.js @@ -1,6 +1 @@ -/*! @preserve - * numeral.js locale configuration - * locale : 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(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de",a)}(); \ No newline at end of file diff --git a/min/locales/en-au.min.js b/min/locales/en-au.min.js index f08c5627..8ae0d458 100644 --- a/min/locales/en-au.min.js +++ b/min/locales/en-au.min.js @@ -1,6 +1 @@ -/*! @preserve - * numeral.js locale configuration - * locale : English Australia - * author : Don Vince : https://github.com/donvince/ - */ !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.locale&&this.numeral.locale("en-au",a)}(); \ No newline at end of file diff --git a/min/locales/en-gb.min.js b/min/locales/en-gb.min.js index 7ed000f5..3f3acffc 100644 --- a/min/locales/en-gb.min.js +++ b/min/locales/en-gb.min.js @@ -1,6 +1 @@ -/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("en-gb",a)}(); \ No newline at end of file diff --git a/min/locales/en-za.min.js b/min/locales/en-za.min.js index df38b31c..2f3f771c 100644 --- a/min/locales/en-za.min.js +++ b/min/locales/en-za.min.js @@ -1,6 +1 @@ -/*! - * numeral.js locale configuration - * locale : english south africa (uk) - * author : Etienne Boshoff : etienne@zailab.com - */ !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:"R"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("en-za",a)}(); \ No newline at end of file diff --git a/min/locales/es-ES.min.js b/min/locales/es-ES.min.js index 67e0f971..f47c2c4d 100644 --- a/min/locales/es-ES.min.js +++ b/min/locales/es-ES.min.js @@ -1,6 +1 @@ -/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("es-es",a)}(); \ No newline at end of file diff --git a/min/locales/es.min.js b/min/locales/es.min.js index 028cca7e..e6a21a83 100644 --- a/min/locales/es.min.js +++ b/min/locales/es.min.js @@ -1,6 +1 @@ -/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("es",a)}(); \ No newline at end of file diff --git a/min/locales/et.min.js b/min/locales/et.min.js index ad2e5f99..94fdcc9c 100644 --- a/min/locales/et.min.js +++ b/min/locales/et.min.js @@ -1,9 +1 @@ -/*! @preserve - * 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(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("et",a)}(); \ No newline at end of file diff --git a/min/locales/fi.min.js b/min/locales/fi.min.js index a68e2bf0..db07a409 100644 --- a/min/locales/fi.min.js +++ b/min/locales/fi.min.js @@ -1,6 +1 @@ -/*! @preserve - * numeral.js locale configuration - * locale : 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(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("fi",a)}(); \ No newline at end of file diff --git a/min/locales/fr-CA.min.js b/min/locales/fr-CA.min.js index 9e5326db..f997402f 100644 --- a/min/locales/fr-CA.min.js +++ b/min/locales/fr-CA.min.js @@ -1,6 +1 @@ -/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("fr-ca",a)}(); \ No newline at end of file diff --git a/min/locales/fr-ch.min.js b/min/locales/fr-ch.min.js index 946a7322..17076eee 100644 --- a/min/locales/fr-ch.min.js +++ b/min/locales/fr-ch.min.js @@ -1,6 +1 @@ -/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("fr-ch",a)}(); \ No newline at end of file diff --git a/min/locales/fr.min.js b/min/locales/fr.min.js index 620e00d5..0a427c1b 100644 --- a/min/locales/fr.min.js +++ b/min/locales/fr.min.js @@ -1,6 +1 @@ -/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("fr",a)}(); \ No newline at end of file diff --git a/min/locales/hu.min.js b/min/locales/hu.min.js index 78cca6a4..42fc9eba 100644 --- a/min/locales/hu.min.js +++ b/min/locales/hu.min.js @@ -1,6 +1 @@ -/*! @preserve - * numeral.js locale configuration - * locale : 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(a){return"."},currency:{symbol:" Ft"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("hu",a)}(); \ No newline at end of file diff --git a/min/locales/it.min.js b/min/locales/it.min.js index 452d6920..c8e57856 100644 --- a/min/locales/it.min.js +++ b/min/locales/it.min.js @@ -1,6 +1 @@ -/*! @preserve - * numeral.js locale configuration - * locale : 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(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("it",a)}(); \ No newline at end of file diff --git a/min/locales/ja.min.js b/min/locales/ja.min.js index a30c0cf3..02878485 100644 --- a/min/locales/ja.min.js +++ b/min/locales/ja.min.js @@ -1,6 +1 @@ -/*! @preserve - * numeral.js locale configuration - * locale : japanese - * author : teppeis : https://github.com/teppeis - */ !function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("ja",a)}(); \ No newline at end of file diff --git a/min/locales/lv.min.js b/min/locales/lv.min.js index 9b986e48..0d28a73a 100644 --- a/min/locales/lv.min.js +++ b/min/locales/lv.min.js @@ -1,6 +1 @@ -/*! @preserve - * numeral.js locale configuration - * locale : Latvian (lv) - * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks - */ !function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("lv",a)}(); \ No newline at end of file diff --git a/min/locales/nl-nl.min.js b/min/locales/nl-nl.min.js index d5a17aeb..cd1e7a7b 100644 --- a/min/locales/nl-nl.min.js +++ b/min/locales/nl-nl.min.js @@ -1,6 +1 @@ -/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("nl-nl",a)}(); \ No newline at end of file diff --git a/min/locales/no.min.js b/min/locales/no.min.js index 73b752f2..f6ed94e4 100644 --- a/min/locales/no.min.js +++ b/min/locales/no.min.js @@ -1,6 +1 @@ -/*! - * numeral.js locale configuration - * locale : norwegian (bokmål) - * author : Ove Andersen : https://github.com/azzlack - */ !function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&(this.numeral.locale("nb-no",a),this.numeral.locale("nn-no",a),this.numeral.locale("no",a),this.numeral.locale("nb",a),this.numeral.locale("nn",a))}(); \ No newline at end of file diff --git a/min/locales/pl.min.js b/min/locales/pl.min.js index 3368afbf..72c4addc 100644 --- a/min/locales/pl.min.js +++ b/min/locales/pl.min.js @@ -1,6 +1 @@ -/*! @preserve - * numeral.js locale configuration - * locale : 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(a){return"."},currency:{symbol:"PLN"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pl",a)}(); \ No newline at end of file diff --git a/min/locales/pt-br.min.js b/min/locales/pt-br.min.js index 3f7ff464..b13dd7ea 100644 --- a/min/locales/pt-br.min.js +++ b/min/locales/pt-br.min.js @@ -1,6 +1 @@ -/*! @preserve - * numeral.js locale configuration - * locale : 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(a){return"º"},currency:{symbol:"R$"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pt-br",a)}(); \ No newline at end of file diff --git a/min/locales/pt-pt.min.js b/min/locales/pt-pt.min.js index 05f12a97..4d17163c 100644 --- a/min/locales/pt-pt.min.js +++ b/min/locales/pt-pt.min.js @@ -1,6 +1 @@ -/*! @preserve - * numeral.js locale configuration - * locale : 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(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pt-pt",a)}(); \ No newline at end of file diff --git a/min/locales/ru.min.js b/min/locales/ru.min.js index efe028c5..8659f04d 100644 --- a/min/locales/ru.min.js +++ b/min/locales/ru.min.js @@ -1,6 +1 @@ -/*! @preserve - * numeral.js locale configuration - * locale : russian (ru) - * author : Anatoli Papirovski : https://github.com/apapirovski - */ !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.locale&&this.numeral.locale("ru",a)}(); \ No newline at end of file diff --git a/min/locales/sk.min.js b/min/locales/sk.min.js index 179c2da2..8e4dfc4d 100644 --- a/min/locales/sk.min.js +++ b/min/locales/sk.min.js @@ -1,6 +1 @@ -/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("sk",a)}(); \ No newline at end of file diff --git a/min/locales/th.min.js b/min/locales/th.min.js index 7ec860e6..ebe80585 100644 --- a/min/locales/th.min.js +++ b/min/locales/th.min.js @@ -1,6 +1 @@ -/*! @preserve - * numeral.js locale configuration - * locale : thai (th) - * author : Sathit Jittanupat : https://github.com/jojosati - */ !function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("th",a)}(); \ No newline at end of file diff --git a/min/locales/tr.min.js b/min/locales/tr.min.js index 5396fee5..9a668806 100644 --- a/min/locales/tr.min.js +++ b/min/locales/tr.min.js @@ -1,6 +1 @@ -/*! @preserve - * 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(){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.locale&&this.numeral.locale("tr",b)}(); \ No newline at end of file diff --git a/min/numeral-with-locales.min.js b/min/numeral-with-locales.min.js index 442cf3d6..e34ee341 100644 --- a/min/numeral-with-locales.min.js +++ b/min/numeral-with-locales.min.js @@ -5,157 +5,4 @@ * 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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i=b.includes(" $")||b.includes("$ ")?" ":"";return b=b.replace(/\s?\$\s?/,""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=g>f||h>f?0:1,e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e=b.includes(" %")?" ":"";return a=100*a,b=b.replace(/\s?\%/,""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i=b.includes(" b")||b.includes(" ib")?" ":"";for(b=b.replace(/\s?i?b/,""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e=b.includes(" o")?" ":"";return b=b.replace(/\s?o/,""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.replace(/e[\+|\-]{1}0/,""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i,j=!1,k=!1,l=!1,m="",n=1e12,o=1e9,p=1e6,q=1e3,r="",t=!1;return a=a||0,f=Math.abs(a),c.includes("(")?(j=!0,c=c.slice(1,-1)):c.includes("+")&&(k=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(e=c.match(/a(k|m|b|t)?/),e=e?e[1]:!1,c.includes(" a")&&(m=" "),c=c.replace(new RegExp(m+"a[kmbt]?"),""),f>=n&&!e||"t"===e?(m+=s[u.currentLocale].abbreviations.trillion,a/=n):n>f&&f>=o&&!e||"b"===e?(m+=s[u.currentLocale].abbreviations.billion,a/=o):o>f&&f>=p&&!e||"m"===e?(m+=s[u.currentLocale].abbreviations.million,a/=p):(p>f&&f>=q&&!e||"k"===e)&&(m+=s[u.currentLocale].abbreviations.thousand,a/=q)),c.includes("[.]")&&(l=!0,c=c.replace("[.]",".")),g=a.toString().split(".")[0],h=c.split(".")[1],i=c.indexOf(","),h?(h.includes("[")?(h=h.replace("]",""),h=h.split("["),r=b(a,h[0].length+h[1].length,d,h[1].length)):r=b(a,h.length,d),g=r.split(".")[0],r=r.includes(".")?s[u.currentLocale].delimiters.decimal+r.split(".")[1]:"",l&&0===Number(r.slice(1))&&(r="")):g=b(a,null,d),g.includes("-")&&(g=g.slice(1),t=!0),i>-1&&(g=g.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(g=""),(j&&t?"(":"")+(!j&&t?"-":"")+(!t&&k?"+":"")+g+r+(m?m:"")+(j&&t?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="Edge",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.reset=function(){for(var a in t)u[a]=t[a]},q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes=String.prototype.includes||function(a,b){return-1!==this.indexOf(a,b)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this),/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("be-nl",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : Bulgarian - * author : Don Vince : https://github.com/donvince/ - */ -function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("bg",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : simplified chinese - * author : badplum : https://github.com/badplum - */ -function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("chs",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("cs",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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(a){return"."},currency:{symbol:"DKK"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("da-dk",a)}(),/*! @preserve - * 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(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"CHF"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de-ch",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : English Australia - * author : Don Vince : https://github.com/donvince/ - */ -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.locale&&this.numeral.locale("en-au",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("en-gb",a)}(),/*! - * numeral.js locale configuration - * locale : english south africa (uk) - * author : Etienne Boshoff : etienne@zailab.com - */ -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:"R"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("en-za",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("es-es",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("es",a)}(),/*! @preserve - * 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(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("et",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("fi",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("fr-ca",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("fr-ch",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("fr",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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(a){return"."},currency:{symbol:" Ft"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("hu",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("it",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : japanese - * author : teppeis : https://github.com/teppeis - */ -function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("ja",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : Latvian (lv) - * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks - */ -function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("lv",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("nl-nl",a)}(),/*! - * numeral.js locale configuration - * locale : norwegian (bokmål) - * author : Ove Andersen : https://github.com/azzlack - */ -function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&(this.numeral.locale("nb-no",a),this.numeral.locale("nn-no",a),this.numeral.locale("no",a),this.numeral.locale("nb",a),this.numeral.locale("nn",a))}(),/*! @preserve - * numeral.js locale configuration - * locale : 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(a){return"."},currency:{symbol:"PLN"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pl",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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(a){return"º"},currency:{symbol:"R$"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pt-br",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("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.locale&&this.numeral.locale("ru-ua",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : russian (ru) - * author : Anatoli Papirovski : https://github.com/apapirovski - */ -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.locale&&this.numeral.locale("ru",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : 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.locale&&this.numeral.locale("sk",a)}(),/*! @preserve - * numeral.js locale configuration - * locale : thai (th) - * author : Sathit Jittanupat : https://github.com/jojosati - */ -function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("th",a)}(),/*! @preserve - * 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(){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.locale&&this.numeral.locale("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.locale&&this.numeral.locale("uk-ua",a)}(); \ No newline at end of file +(function(){function a(a){this._value=a}function b(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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i=b.includes(" $")||b.includes("$ ")?" ":"";return b=b.replace(/\s?\$\s?/,""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=g>f||h>f?0:1,e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e=b.includes(" %")?" ":"";return a=100*a,b=b.replace(/\s?\%/,""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i=b.includes(" b")||b.includes(" ib")?" ":"";for(b=b.replace(/\s?i?b/,""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e=b.includes(" o")?" ":"";return b=b.replace(/\s?o/,""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.replace(/e[\+|\-]{1}0/,""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i,j=!1,k=!1,l=!1,m="",n=1e12,o=1e9,p=1e6,q=1e3,r="",t=!1;return a=a||0,f=Math.abs(a),c.includes("(")?(j=!0,c=c.slice(1,-1)):c.includes("+")&&(k=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(e=c.match(/a(k|m|b|t)?/),e=e?e[1]:!1,c.includes(" a")&&(m=" "),c=c.replace(new RegExp(m+"a[kmbt]?"),""),f>=n&&!e||"t"===e?(m+=s[u.currentLocale].abbreviations.trillion,a/=n):n>f&&f>=o&&!e||"b"===e?(m+=s[u.currentLocale].abbreviations.billion,a/=o):o>f&&f>=p&&!e||"m"===e?(m+=s[u.currentLocale].abbreviations.million,a/=p):(p>f&&f>=q&&!e||"k"===e)&&(m+=s[u.currentLocale].abbreviations.thousand,a/=q)),c.includes("[.]")&&(l=!0,c=c.replace("[.]",".")),g=a.toString().split(".")[0],h=c.split(".")[1],i=c.indexOf(","),h?(h.includes("[")?(h=h.replace("]",""),h=h.split("["),r=b(a,h[0].length+h[1].length,d,h[1].length)):r=b(a,h.length,d),g=r.split(".")[0],r=r.includes(".")?s[u.currentLocale].delimiters.decimal+r.split(".")[1]:"",l&&0===Number(r.slice(1))&&(r="")):g=b(a,null,d),g.includes("-")&&(g=g.slice(1),t=!0),i>-1&&(g=g.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(g=""),(j&&t?"(":"")+(!j&&t?"-":"")+(!t&&k?"+":"")+g+r+(m?m:"")+(j&&t?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="Edge",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.reset=function(){for(var a in t)u[a]=t[a]},q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes=String.prototype.includes||function(a,b){return-1!==this.indexOf(a,b)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this),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.locale&&this.numeral.locale("be-nl",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("bg",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("chs",a)}(),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.locale&&this.numeral.locale("cs",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mia",trillion:"b"},ordinal:function(a){return"."},currency:{symbol:"DKK"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("da-dk",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"CHF"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de-ch",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de",a)}(),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.locale&&this.numeral.locale("en-au",a)}(),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.locale&&this.numeral.locale("en-gb",a)}(),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:"R"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("en-za",a)}(),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.locale&&this.numeral.locale("es-es",a)}(),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.locale&&this.numeral.locale("es",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("et",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("fi",a)}(),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.locale&&this.numeral.locale("fr-ca",a)}(),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.locale&&this.numeral.locale("fr-ch",a)}(),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.locale&&this.numeral.locale("fr",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("hu",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("it",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("ja",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("lv",a)}(),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.locale&&this.numeral.locale("nl-nl",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&(this.numeral.locale("nb-no",a),this.numeral.locale("nn-no",a),this.numeral.locale("no",a),this.numeral.locale("nb",a),this.numeral.locale("nn",a))}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pl",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mil",million:"milhões",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"R$"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pt-br",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("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.locale&&this.numeral.locale("ru-ua",a)}(),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.locale&&this.numeral.locale("ru",a)}(),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.locale&&this.numeral.locale("sk",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("th",a)}(),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.locale&&this.numeral.locale("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.locale&&this.numeral.locale("uk-ua",a)}(); \ No newline at end of file diff --git a/numeral-with-locales.js b/numeral-with-locales.js index 4404e666..f3a04c7d 100644 --- a/numeral-with-locales.js +++ b/numeral-with-locales.js @@ -875,7 +875,7 @@ } }).call(this); -/*! @preserve +/* * numeral.js locale configuration * locale : belgium-dutch (be-nl) * author : Dieter Luypaert : https://github.com/moeriki @@ -911,7 +911,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : Bulgarian * author : Don Vince : https://github.com/donvince/ @@ -954,7 +954,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : simplified chinese * author : badplum : https://github.com/badplum @@ -989,7 +989,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : czech (cs) * author : Anatoli Papirovski : https://github.com/apapirovski @@ -1024,7 +1024,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : danish denmark (dk) * author : Michael Storgaard : https://github.com/mstorgaard @@ -1058,7 +1058,7 @@ this.numeral.locale('da-dk', locale); } }()); -/*! @preserve +/* * 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) @@ -1092,7 +1092,7 @@ this.numeral.locale('de-ch', locale); } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium * author : Marco Krage : https://github.com/sinky @@ -1126,7 +1126,7 @@ this.numeral.locale('de', locale); } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : English Australia * author : Don Vince : https://github.com/donvince/ @@ -1165,7 +1165,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : english united kingdom (uk) * author : Dan Ristic : https://github.com/dristic @@ -1203,7 +1203,7 @@ this.numeral.locale('en-gb', locale); } }()); -/*! +/* * numeral.js locale configuration * locale : english south africa (uk) * author : Etienne Boshoff : etienne@zailab.com @@ -1241,7 +1241,8 @@ this.numeral.locale('en-za', locale); } }()); -/*! @preserve + +/* * numeral.js locale configuration * locale : spanish Spain * author : Hernan Garcia : https://github.com/hgarcia @@ -1281,7 +1282,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : spanish * author : Hernan Garcia : https://github.com/hgarcia @@ -1321,7 +1322,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : Estonian * author : Illimar Tambek : https://github.com/ragulka @@ -1359,7 +1360,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : Finnish * author : Sami Saada : https://github.com/samitheberber @@ -1394,7 +1395,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : french (Canada) (fr-ca) * author : Léo Renaud-Allaire : https://github.com/renaudleo @@ -1428,7 +1429,8 @@ this.numeral.locale('fr-ca', locale); } }()); -/*! @preserve + +/* * numeral.js locale configuration * locale : french (fr-ch) * author : Adam Draper : https://github.com/adamwdraper @@ -1463,7 +1465,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : french (fr) * author : Adam Draper : https://github.com/adamwdraper @@ -1497,7 +1499,7 @@ this.numeral.locale('fr', locale); } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : Hungarian (hu) * author : Peter Bakondy : https://github.com/pbakondy @@ -1531,7 +1533,7 @@ this.numeral.locale('hu', locale); } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : italian Italy (it) * author : Giacomo Trombi : http://cinquepunti.it @@ -1565,7 +1567,7 @@ this.numeral.locale('it', locale); } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : japanese * author : teppeis : https://github.com/teppeis @@ -1600,7 +1602,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : Latvian (lv) * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks @@ -1634,7 +1636,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : netherlands-dutch (nl-nl) * author : Dave Clayton : https://github.com/davedx @@ -1669,7 +1671,7 @@ this.numeral.locale('nl-nl', locale); } }()); -/*! +/* * numeral.js locale configuration * locale : norwegian (bokmål) * author : Ove Andersen : https://github.com/azzlack @@ -1707,7 +1709,8 @@ this.numeral.locale('nn', locale); } }()); -/*! @preserve + +/* * numeral.js locale configuration * locale : polish (pl) * author : Dominik Bulaj : https://github.com/dominikbulaj @@ -1741,7 +1744,7 @@ this.numeral.locale('pl', locale); } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : portuguese brazil (pt-br) * author : Ramiro Varandas Jr : https://github.com/ramirovjr @@ -1775,7 +1778,7 @@ this.numeral.locale('pt-br', locale); } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : portuguese (pt-pt) * author : Diogo Resende : https://github.com/dresende @@ -1846,7 +1849,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : russian (ru) * author : Anatoli Papirovski : https://github.com/apapirovski @@ -1884,7 +1887,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : slovak (sk) * author : Ahmed Al Hafoudh : http://www.freevision.sk @@ -1919,7 +1922,7 @@ } }()); -/*! @preserve +/* * numeral.js locale configuration * locale : thai (th) * author : Sathit Jittanupat : https://github.com/jojosati @@ -1954,7 +1957,7 @@ } }()); -/*! @preserve +/* * 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 diff --git a/locales/be-nl.js b/src/locales/be-nl.js similarity index 98% rename from locales/be-nl.js rename to src/locales/be-nl.js index 836e50ff..b5b2ca91 100644 --- a/locales/be-nl.js +++ b/src/locales/be-nl.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * numeral.js locale configuration * locale : belgium-dutch (be-nl) * author : Dieter Luypaert : https://github.com/moeriki diff --git a/locales/bg.js b/src/locales/bg.js similarity index 98% rename from locales/bg.js rename to src/locales/bg.js index d4ed06f5..1f8ee92b 100644 --- a/locales/bg.js +++ b/src/locales/bg.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * numeral.js locale configuration * locale : Bulgarian * author : Don Vince : https://github.com/donvince/ diff --git a/locales/chs.js b/src/locales/chs.js similarity index 94% rename from locales/chs.js rename to src/locales/chs.js index 7eed3adc..ad03a279 100644 --- a/locales/chs.js +++ b/src/locales/chs.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * numeral.js locale configuration * locale : simplified chinese * author : badplum : https://github.com/badplum diff --git a/locales/cs.js b/src/locales/cs.js similarity index 98% rename from locales/cs.js rename to src/locales/cs.js index 5d3ceb2d..9856fda8 100644 --- a/locales/cs.js +++ b/src/locales/cs.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * numeral.js locale configuration * locale : czech (cs) * author : Anatoli Papirovski : https://github.com/apapirovski diff --git a/locales/da-dk.js b/src/locales/da-dk.js similarity index 98% rename from locales/da-dk.js rename to src/locales/da-dk.js index aada27c8..0f365609 100644 --- a/locales/da-dk.js +++ b/src/locales/da-dk.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * numeral.js locale configuration * locale : danish denmark (dk) * author : Michael Storgaard : https://github.com/mstorgaard diff --git a/locales/de-ch.js b/src/locales/de-ch.js similarity index 98% rename from locales/de-ch.js rename to src/locales/de-ch.js index d2b6bb64..8b92d27f 100644 --- a/locales/de-ch.js +++ b/src/locales/de-ch.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * 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) diff --git a/locales/de.js b/src/locales/de.js similarity index 98% rename from locales/de.js rename to src/locales/de.js index 20495f02..848ffb51 100644 --- a/locales/de.js +++ b/src/locales/de.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * numeral.js locale configuration * locale : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium * author : Marco Krage : https://github.com/sinky diff --git a/locales/en-au.js b/src/locales/en-au.js similarity index 98% rename from locales/en-au.js rename to src/locales/en-au.js index 5a7d1bcd..cbb1fd0a 100644 --- a/locales/en-au.js +++ b/src/locales/en-au.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * numeral.js locale configuration * locale : English Australia * author : Don Vince : https://github.com/donvince/ diff --git a/locales/en-gb.js b/src/locales/en-gb.js similarity index 98% rename from locales/en-gb.js rename to src/locales/en-gb.js index bd813462..eed6b41d 100644 --- a/locales/en-gb.js +++ b/src/locales/en-gb.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * numeral.js locale configuration * locale : english united kingdom (uk) * author : Dan Ristic : https://github.com/dristic diff --git a/locales/en-za.js b/src/locales/en-za.js similarity index 99% rename from locales/en-za.js rename to src/locales/en-za.js index 72d50450..95c0a5cb 100644 --- a/locales/en-za.js +++ b/src/locales/en-za.js @@ -1,4 +1,4 @@ -/*! +/* * numeral.js locale configuration * locale : english south africa (uk) * author : Etienne Boshoff : etienne@zailab.com @@ -35,4 +35,4 @@ if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { this.numeral.locale('en-za', locale); } -}()); \ No newline at end of file +}()); diff --git a/locales/es-es.js b/src/locales/es-es.js similarity index 98% rename from locales/es-es.js rename to src/locales/es-es.js index 839c3dc0..143ac3cc 100644 --- a/locales/es-es.js +++ b/src/locales/es-es.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * numeral.js locale configuration * locale : spanish Spain * author : Hernan Garcia : https://github.com/hgarcia diff --git a/locales/es.js b/src/locales/es.js similarity index 98% rename from locales/es.js rename to src/locales/es.js index c3276634..5059a310 100644 --- a/locales/es.js +++ b/src/locales/es.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * numeral.js locale configuration * locale : spanish * author : Hernan Garcia : https://github.com/hgarcia diff --git a/locales/et.js b/src/locales/et.js similarity index 98% rename from locales/et.js rename to src/locales/et.js index 3d5826f9..2cd953ea 100644 --- a/locales/et.js +++ b/src/locales/et.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * numeral.js locale configuration * locale : Estonian * author : Illimar Tambek : https://github.com/ragulka diff --git a/locales/fi.js b/src/locales/fi.js similarity index 98% rename from locales/fi.js rename to src/locales/fi.js index 5efac798..482e79db 100644 --- a/locales/fi.js +++ b/src/locales/fi.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * numeral.js locale configuration * locale : Finnish * author : Sami Saada : https://github.com/samitheberber diff --git a/locales/fr-ca.js b/src/locales/fr-ca.js similarity index 97% rename from locales/fr-ca.js rename to src/locales/fr-ca.js index 5116dd52..4a86e442 100644 --- a/locales/fr-ca.js +++ b/src/locales/fr-ca.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * numeral.js locale configuration * locale : french (Canada) (fr-ca) * author : Léo Renaud-Allaire : https://github.com/renaudleo @@ -31,4 +31,4 @@ if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { this.numeral.locale('fr-ca', locale); } -}()); \ No newline at end of file +}()); diff --git a/locales/fr-ch.js b/src/locales/fr-ch.js similarity index 98% rename from locales/fr-ch.js rename to src/locales/fr-ch.js index 73ff5965..71060a8b 100644 --- a/locales/fr-ch.js +++ b/src/locales/fr-ch.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * numeral.js locale configuration * locale : french (fr-ch) * author : Adam Draper : https://github.com/adamwdraper diff --git a/locales/fr.js b/src/locales/fr.js similarity index 98% rename from locales/fr.js rename to src/locales/fr.js index a6d8f474..84225e9e 100644 --- a/locales/fr.js +++ b/src/locales/fr.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * numeral.js locale configuration * locale : french (fr) * author : Adam Draper : https://github.com/adamwdraper diff --git a/locales/hu.js b/src/locales/hu.js similarity index 98% rename from locales/hu.js rename to src/locales/hu.js index e587db2c..f14fedce 100644 --- a/locales/hu.js +++ b/src/locales/hu.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * numeral.js locale configuration * locale : Hungarian (hu) * author : Peter Bakondy : https://github.com/pbakondy diff --git a/locales/it.js b/src/locales/it.js similarity index 98% rename from locales/it.js rename to src/locales/it.js index 4d5ae6a2..1d6e14e0 100644 --- a/locales/it.js +++ b/src/locales/it.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * numeral.js locale configuration * locale : italian Italy (it) * author : Giacomo Trombi : http://cinquepunti.it diff --git a/locales/ja.js b/src/locales/ja.js similarity index 98% rename from locales/ja.js rename to src/locales/ja.js index 8f008f76..12445f78 100644 --- a/locales/ja.js +++ b/src/locales/ja.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * numeral.js locale configuration * locale : japanese * author : teppeis : https://github.com/teppeis diff --git a/locales/lv.js b/src/locales/lv.js similarity index 98% rename from locales/lv.js rename to src/locales/lv.js index 0737c1ab..2eca3b09 100644 --- a/locales/lv.js +++ b/src/locales/lv.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * numeral.js locale configuration * locale : Latvian (lv) * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks diff --git a/locales/nl-nl.js b/src/locales/nl-nl.js similarity index 98% rename from locales/nl-nl.js rename to src/locales/nl-nl.js index e64702e1..96fca57e 100644 --- a/locales/nl-nl.js +++ b/src/locales/nl-nl.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * numeral.js locale configuration * locale : netherlands-dutch (nl-nl) * author : Dave Clayton : https://github.com/davedx diff --git a/locales/no.js b/src/locales/no.js similarity index 98% rename from locales/no.js rename to src/locales/no.js index fec5a39e..70922d43 100644 --- a/locales/no.js +++ b/src/locales/no.js @@ -1,4 +1,4 @@ -/*! +/* * numeral.js locale configuration * locale : norwegian (bokmål) * author : Ove Andersen : https://github.com/azzlack @@ -35,4 +35,4 @@ this.numeral.locale('nb', locale); this.numeral.locale('nn', locale); } -}()); \ No newline at end of file +}()); diff --git a/locales/pl.js b/src/locales/pl.js similarity index 98% rename from locales/pl.js rename to src/locales/pl.js index 59f5f6a2..665b0260 100644 --- a/locales/pl.js +++ b/src/locales/pl.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * numeral.js locale configuration * locale : polish (pl) * author : Dominik Bulaj : https://github.com/dominikbulaj diff --git a/locales/pt-br.js b/src/locales/pt-br.js similarity index 98% rename from locales/pt-br.js rename to src/locales/pt-br.js index 0fd6e23d..390ac09e 100644 --- a/locales/pt-br.js +++ b/src/locales/pt-br.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * numeral.js locale configuration * locale : portuguese brazil (pt-br) * author : Ramiro Varandas Jr : https://github.com/ramirovjr diff --git a/locales/pt-pt.js b/src/locales/pt-pt.js similarity index 98% rename from locales/pt-pt.js rename to src/locales/pt-pt.js index 9ad29b39..3eba2813 100644 --- a/locales/pt-pt.js +++ b/src/locales/pt-pt.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * numeral.js locale configuration * locale : portuguese (pt-pt) * author : Diogo Resende : https://github.com/dresende diff --git a/locales/ru-ua.js b/src/locales/ru-ua.js similarity index 100% rename from locales/ru-ua.js rename to src/locales/ru-ua.js diff --git a/locales/ru.js b/src/locales/ru.js similarity index 98% rename from locales/ru.js rename to src/locales/ru.js index 9f94dfa1..afc9ee5c 100644 --- a/locales/ru.js +++ b/src/locales/ru.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * numeral.js locale configuration * locale : russian (ru) * author : Anatoli Papirovski : https://github.com/apapirovski diff --git a/locales/sk.js b/src/locales/sk.js similarity index 98% rename from locales/sk.js rename to src/locales/sk.js index 72f846a2..f0f0d3ba 100644 --- a/locales/sk.js +++ b/src/locales/sk.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * numeral.js locale configuration * locale : slovak (sk) * author : Ahmed Al Hafoudh : http://www.freevision.sk diff --git a/locales/th.js b/src/locales/th.js similarity index 98% rename from locales/th.js rename to src/locales/th.js index 9203051d..423cae15 100644 --- a/locales/th.js +++ b/src/locales/th.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * numeral.js locale configuration * locale : thai (th) * author : Sathit Jittanupat : https://github.com/jojosati diff --git a/locales/tr.js b/src/locales/tr.js similarity index 99% rename from locales/tr.js rename to src/locales/tr.js index 8f58b9b5..4e06f196 100644 --- a/locales/tr.js +++ b/src/locales/tr.js @@ -1,4 +1,4 @@ -/*! @preserve +/* * 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 diff --git a/locales/uk-ua.js b/src/locales/uk-ua.js similarity index 100% rename from locales/uk-ua.js rename to src/locales/uk-ua.js diff --git a/src/numeral.js b/src/numeral.js new file mode 100644 index 00000000..00cc7086 --- /dev/null +++ b/src/numeral.js @@ -0,0 +1,876 @@ +/*! @preserve + * numeral.js + * version : Edge + * author : Adam Draper + * license : MIT + * http://adamwdraper.github.com/Numeral-js/ + */ + +(function() { + + /************************************ + Variables + ************************************/ + + var numeral, + VERSION = 'Edge', + // internal storage for locale config files + locales = {}, + defaults = { + currentLocale: 'en', + zeroFormat: null, + nullFormat: null, + defaultFormat: '0,0' + }, + options = { + currentLocale: defaults.currentLocale, + zeroFormat: defaults.zeroFormat, + nullFormat: defaults.nullFormat, + defaultFormat: defaults.defaultFormat + }, + config = { + bytes: { + 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'] + } + } + }; + + + /************************************ + 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, 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); + + //roundingFunction = (roundingFunction !== undefined ? roundingFunction : Math.round); + // Multiply up by precision, round accurately, then divide and use native toFixed(): + output = (roundingFunction(value * power) / power).toFixed(boundedPrecision); + + if (optionals > maxDecimals - boundedPrecision) { + optionalsRegExp = new RegExp('\\.?0{1,' + (optionals - (maxDecimals - boundedPrecision)) + '}$'); + output = output.replace(optionalsRegExp, ''); + } + + return output; + } + + /************************************ + Formatting + ************************************/ + + // determine what type of formatting we need to do + function formatNumeral(n, format, roundingFunction) { + var value = n._value, + kind, + output, + formatFunction; + + if (value === 0 && options.zeroFormat !== null) { + output = options.zeroFormat; + } else if (value === null && options.nullFormat !== null) { + output = options.nullFormat; + } else { + kind = format.match(/(\$|%|:|[ai]?b|o|e\+|e-)/); + + switch (kind ? kind[0] : '') { + case '$': + formatFunction = formatCurrency; + break; + case '%': + formatFunction = formatPercentage; + break; + case ':': + formatFunction = formatTime; + break; + case 'b': + case 'ib': + formatFunction = formatBytes; + break; + case 'o': + formatFunction = formatOrdinal; + break; + case 'e+': + case 'e-': + formatFunction = formatExponential; + break; + default: + formatFunction = formatNumber; + } + + output = formatFunction(value, format, roundingFunction); + } + + return output; + } + + function formatCurrency(value, format, roundingFunction) { + var symbolIndex = format.indexOf('$'), + openParenIndex = format.indexOf('('), + minusSignIndex = format.indexOf('-'), + space = format.includes(' $') || format.includes('$ ') ? ' ' : '', + spliceIndex, + output; + + // strip format of spaces and $ + format = format.replace(/\s?\$\s?/, ''); + + // format the number + output = formatNumber(value, format, roundingFunction); + + // position the symbol + if (symbolIndex <= 1) { + if (output.includes('(') || output.includes('-')) { + output = output.split(''); + + spliceIndex = symbolIndex < openParenIndex || symbolIndex < minusSignIndex ? 0 : 1; + + output.splice(spliceIndex, 0, locales[options.currentLocale].currency.symbol + space); + + output = output.join(''); + } else { + output = locales[options.currentLocale].currency.symbol + space + output; + } + } else { + if (output.includes(')')) { + output = output.split(''); + + output.splice(-1, 0, space + locales[options.currentLocale].currency.symbol); + + output = output.join(''); + } else { + output = output + space + locales[options.currentLocale].currency.symbol; + } + } + + return output; + } + + function formatPercentage(value, format, roundingFunction) { + var space = format.includes(' %') ? ' ' : '', + output; + + value = value * 100; + + // check for space before % + format = format.replace(/\s?\%/, ''); + + output = formatNumber(value, format, roundingFunction); + + if (output.includes(')')) { + output = output.split(''); + + output.splice(-1, 0, space + '%'); + + output = output.join(''); + } else { + output = output + space + '%'; + } + + return output; + } + + function formatBytes(value, format, roundingFunction) { + var output, + bytes = format.includes('ib') ? config.bytes.binary : config.bytes.decimal, + suffix = format.includes(' b') || format.includes(' 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 = formatNumber(value, format, roundingFunction); + + return output + suffix; + } + + function formatOrdinal(value, format, roundingFunction) { + var output, + ordinal = format.includes(' o') ? ' ' : ''; + + // check for space before + format = format.replace(/\s?o/, ''); + + ordinal += locales[options.currentLocale].ordinal(value); + + output = formatNumber(value, format, roundingFunction); + + return output + ordinal; + } + + function formatExponential(value, format, roundingFunction) { + var output, + exponential = typeof value === 'number' && !Number.isNaN(value) ? value.toExponential() : '0e+0', + parts = exponential.split('e'); + + format = format.replace(/e[\+|\-]{1}0/, ''); + + output = formatNumber(Number(parts[0]), format, roundingFunction); + + return output + 'e' + parts[1]; + } + + function formatTime(value) { + 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); + } + + function formatNumber(value, format, roundingFunction) { + var negP = false, + signed = false, + optDec = false, + abbr = '', + trillion = 1000000000000, + billion = 1000000000, + million = 1000000, + thousand = 1000, + abbrForce, // force abbreviation + abs, + min, + max, + power, + int, + precision, + thousands, + decimal = '', + neg = false; + + // 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 (format.includes('(')) { + negP = true; + format = format.slice(1, -1); + } else if (format.includes('+')) { + signed = true; + format = format.replace(/\+/g, ''); + } + + // see if abbreviation is wanted + if (format.includes('a')) { + abbrForce = format.match(/a(k|m|b|t)?/); + + abbrForce = abbrForce ? abbrForce[1] : false; + + // check for space before abbreviation + if (format.includes(' a')) { + abbr = ' '; + } + + format = format.replace(new RegExp(abbr + 'a[kmbt]?'), ''); + + if (abs >= trillion && !abbrForce || abbrForce === 't') { + // trillion + abbr += locales[options.currentLocale].abbreviations.trillion; + value = value / trillion; + } else if (abs < trillion && abs >= billion && !abbrForce || abbrForce === 'b') { + // billion + abbr += locales[options.currentLocale].abbreviations.billion; + value = value / billion; + } else if (abs < billion && abs >= million && !abbrForce || abbrForce === 'm') { + // million + abbr += locales[options.currentLocale].abbreviations.million; + value = value / million; + } else if (abs < million && abs >= thousand && !abbrForce || abbrForce === 'k') { + // thousand + abbr += locales[options.currentLocale].abbreviations.thousand; + value = value / thousand; + } + } + + + if (format.includes('[.]')) { + optDec = true; + format = format.replace('[.]', '.'); + } + + int = value.toString().split('.')[0]; + precision = format.split('.')[1]; + thousands = format.indexOf(','); + + if (precision) { + if (precision.includes('[')) { + precision = precision.replace(']', ''); + precision = precision.split('['); + decimal = toFixed(value, (precision[0].length + precision[1].length), roundingFunction, precision[1].length); + } else { + decimal = toFixed(value, precision.length, roundingFunction); + } + + int = decimal.split('.')[0]; + + if (decimal.includes('.')) { + decimal = locales[options.currentLocale].delimiters.decimal + decimal.split('.')[1]; + } else { + decimal = ''; + } + + if (optDec && Number(decimal.slice(1)) === 0) { + decimal = ''; + } + } else { + int = toFixed(value, null, roundingFunction); + } + + // format number + if (int.includes('-')) { + int = int.slice(1); + neg = true; + } + + if (thousands > -1) { + int = int.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + locales[options.currentLocale].delimiters.thousands); + } + + if (format.indexOf('.') === 0) { + int = ''; + } + + return (negP && neg ? '(' : '') + (!negP && neg ? '-' : '') + (!neg && signed ? '+' : '') + int + decimal + (abbr ? abbr : '') + (negP && neg ? ')' : ''); + } + + + /************************************ + Unformatting + ************************************/ + + // revert to number + function unformatNumeral(n, string) { + var stringOriginal = string, + thousandRegExp, + millionRegExp, + billionRegExp, + trillionRegExp, + bytesMultiplier = false, + power, + value; + + if (string.includes(':')) { + value = unformatTime(string); + } else if (string.includes('e+') || string.includes('e-')) { + value = unformatExponential(string); + } else { + if (string === options.zeroFormat || string === options.nullFormat) { + value = 0; + } else { + if (locales[options.currentLocale].delimiters.decimal !== '.') { + string = string.replace(/\./g, '').replace(locales[options.currentLocale].delimiters.decimal, '.'); + } + + // see if abbreviations are there so that we can multiply to the correct number + thousandRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.thousand + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); + millionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.million + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); + billionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.billion + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); + trillionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.trillion + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); + + // see if bytes are there so that we can multiply to the correct number + for (power = 1; power <= config.bytes.decimal.suffixes.length; power++) { + bytesMultiplier = ((string.includes(config.bytes.decimal.suffixes[power])) || (string.includes(config.bytes.binary.suffixes[power])))? Math.pow(1024, power) : false; + + if (bytesMultiplier) { + break; + } + } + + // do some math to create our number + value = bytesMultiplier ? bytesMultiplier : 1; + value *= stringOriginal.match(thousandRegExp) ? Math.pow(10, 3) : 1; + value *= stringOriginal.match(millionRegExp) ? Math.pow(10, 6) : 1; + value *= stringOriginal.match(billionRegExp) ? Math.pow(10, 9) : 1; + value *= stringOriginal.match(trillionRegExp) ? Math.pow(10, 12) : 1; + // check for percentage + value *= string.includes('%') ? 0.01 : 1; + // check for negative number + value *= (string.split('-').length + Math.min(string.split('(').length - 1, string.split(')').length - 1)) % 2 ? 1 : -1; + // remove non numbers + value *= Number(string.replace(/[^0-9\.]+/g, '')); + // round if we are talking about bytes + value = bytesMultiplier ? Math.ceil(value) : value; + } + } + + n._value = value; + + return n._value; + } + + 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); + } + + function unformatExponential(string) { + var parts = string.includes('e+') ? string.split('e+') : string.split('e-'), + value = Number(parts[0]), + power = Number(parts[1]); + + power = string.includes('e-') ? power *= -1 : power; + + function cback(accum, curr, currI, O) { + var corrFactor = correctionFactor(accum, curr), + num = (accum * corrFactor) * (curr * corrFactor) / (corrFactor * corrFactor); + return num; + } + + return [value, Math.pow(10, power)].reduce(cback, 1); + } + + /************************************ + Top Level Functions + ************************************/ + + numeral = function(input) { + if (numeral.isNumeral(input)) { + input = input.value(); + } else if (input === 0 || typeof input === 'undefined') { + input = 0; + } else if (input === null || Number.isNaN(input)) { + input = null; + } else if (!Number(input)) { + input = numeral.fn.unformat(input); + } else { + input = Number(input); + } + + return new Numeral(input); + }; + + // version number + numeral.version = VERSION; + + // compare numeral object + numeral.isNumeral = function(obj) { + return obj instanceof Numeral; + }; + + + // This function will load locales and then set the global locale. If + // no arguments are passed in, it will simply return the current global + // locale key. + numeral.locale = function(key, values) { + if (!key) { + return options.currentLocale; + } + + // standardize to lowercase + key = key.toLowerCase(); + + if (key && !values) { + if (!locales[key]) { + throw new Error('Unknown locale : ' + key); + } + + options.currentLocale = key; + } + + if (values || !locales[key]) { + loadLocale(key, values); + } + + return numeral; + }; + + // 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.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: '$' + } + }); + + 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.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; + }; + + /************************************ + Helpers + ************************************/ + + function loadLocale(key, values) { + locales[key] = values; + } + + // isNaN polyfill + Number.isNaN = Number.isNaN || function(value) { + return typeof value === 'number' && isNaN(value); + }; + + // String includes polyfill + String.prototype.includes = String.prototype.includes || function(search, start) { + return this.indexOf(search, start) !== -1; + }; + + // Production steps of ECMA-262, Edition 5, 15.4.4.21 + // Reference: http://es5.github.io/#x15.4.4.21 + if (!Array.prototype.reduce) { + Array.prototype.reduce = function(callback /*, initialValue*/) { + 'use strict'; + 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(this), len = t.length >>> 0, k = 0, value; + + if (arguments.length === 2) { + value = arguments[1]; + } 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. + */ + function multiplier(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. + */ + function correctionFactor() { + var args = Array.prototype.slice.call(arguments); + + return args.reduce(function(accum, next) { + var mn = multiplier(next); + return accum > mn ? accum : mn; + }, 1); + } + + + /************************************ + Numeral Prototype + ************************************/ + + + numeral.fn = Numeral.prototype = { + clone: function() { + return numeral(this); + }, + format: function (inputString, roundingFunction) { + return formatNumeral(this, + inputString ? inputString : options.defaultFormat, + roundingFunction !== undefined ? roundingFunction : Math.round + ); + }, + unformat: function (inputString) { + if (Object.prototype.toString.call(inputString) === '[object Number]') { + return inputString; + } + + return unformatNumeral(this, inputString ? inputString : options.defaultFormat); + }, + value: function() { + return this._value; + }, + valueOf: function() { + return this._value; + }, + 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 = [this._value, value].reduce(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 = [value].reduce(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 = [this._value, value].reduce(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 = [this._value, value].reduce(cback); + + return this; + }, + difference: function(value) { + return Math.abs(numeral(this._value).subtract(value).value()); + } + }; + + /************************************ + Exposing Numeral + ************************************/ + + // CommonJS module is defined + if (typeof module !== 'undefined' && module.exports) { + module.exports = numeral; + } + + /*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; + } + + /*global define:false */ + if (typeof define === 'function' && define.amd) { + define([], function() { + return numeral; + }); + } +}).call(this); diff --git a/tests/locales/be-nl.js b/tests/locales/be-nl.js index 6be7485e..8951ce95 100644 --- a/tests/locales/be-nl.js +++ b/tests/locales/be-nl.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/be-nl'); + var locale = require('../../src/locales/be-nl'); } describe('Locale: be-nl', function() { diff --git a/tests/locales/bg.js b/tests/locales/bg.js index 18accf7c..f161b320 100644 --- a/tests/locales/bg.js +++ b/tests/locales/bg.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/bg'); + var locale = require('../../src/locales/bg'); } describe('Locale: bg', function() { diff --git a/tests/locales/chs.js b/tests/locales/chs.js index 30787d37..10be70c0 100644 --- a/tests/locales/chs.js +++ b/tests/locales/chs.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/chs'); + var locale = require('../../src/locales/chs'); } describe('Locale: chs', function() { diff --git a/tests/locales/cs.js b/tests/locales/cs.js index cbff3ef8..1e1e7996 100644 --- a/tests/locales/cs.js +++ b/tests/locales/cs.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/cs'); + var locale = require('../../src/locales/cs'); } describe('Locale: cs', function() { diff --git a/tests/locales/da-dk.js b/tests/locales/da-dk.js index c8ed7fff..b684788d 100644 --- a/tests/locales/da-dk.js +++ b/tests/locales/da-dk.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/da-dk'); + var locale = require('../../src/locales/da-dk'); } describe('Locale: da-dk', function() { diff --git a/tests/locales/de-ch.js b/tests/locales/de-ch.js index af86325f..3c870228 100644 --- a/tests/locales/de-ch.js +++ b/tests/locales/de-ch.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/de-ch'); + var locale = require('../../src/locales/de-ch'); } describe('Locale: de-ch', function() { diff --git a/tests/locales/de.js b/tests/locales/de.js index 047c553e..234aef3a 100644 --- a/tests/locales/de.js +++ b/tests/locales/de.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/de'); + var locale = require('../../src/locales/de'); } describe('Locale: de', function() { diff --git a/tests/locales/en-au.js b/tests/locales/en-au.js index ea59b27a..3c74ec05 100644 --- a/tests/locales/en-au.js +++ b/tests/locales/en-au.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/en-au'); + var locale = require('../../src/locales/en-au'); } describe('Locale: en-au', function() { diff --git a/tests/locales/en-gb.js b/tests/locales/en-gb.js index 4bbc7221..33453b7c 100644 --- a/tests/locales/en-gb.js +++ b/tests/locales/en-gb.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/en-gb'); + var locale = require('../../src/locales/en-gb'); } describe('Locale: en-gb', function() { diff --git a/tests/locales/en-za.js b/tests/locales/en-za.js index 065304fc..efae64f3 100644 --- a/tests/locales/en-za.js +++ b/tests/locales/en-za.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/en-za'); + var locale = require('../../src/locales/en-za'); } describe('Locale: en-za', function() { diff --git a/tests/locales/en.js b/tests/locales/en.js index 287ae541..500c85e8 100644 --- a/tests/locales/en.js +++ b/tests/locales/en.js @@ -1,6 +1,6 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; } diff --git a/tests/locales/es-es.js b/tests/locales/es-es.js index a97f7651..f6fe25cd 100644 --- a/tests/locales/es-es.js +++ b/tests/locales/es-es.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/es-es'); + var locale = require('../../src/locales/es-es'); } describe('Locale: es-es', function() { diff --git a/tests/locales/es.js b/tests/locales/es.js index 1c27512d..782039bd 100644 --- a/tests/locales/es.js +++ b/tests/locales/es.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/es'); + var locale = require('../../src/locales/es'); } describe('Locale: es', function() { diff --git a/tests/locales/et.js b/tests/locales/et.js index 4b1b575a..19ec7321 100644 --- a/tests/locales/et.js +++ b/tests/locales/et.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/et'); + var locale = require('../../src/locales/et'); } describe('Locale: et', function() { diff --git a/tests/locales/fi.js b/tests/locales/fi.js index e934cdd0..0b976829 100644 --- a/tests/locales/fi.js +++ b/tests/locales/fi.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/fi'); + var locale = require('../../src/locales/fi'); } describe('Locale: fi', function() { diff --git a/tests/locales/fr-ca.js b/tests/locales/fr-ca.js index ba5dfc00..d1677847 100644 --- a/tests/locales/fr-ca.js +++ b/tests/locales/fr-ca.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/fr-ca'); + var locale = require('../../src/locales/fr-ca'); } describe('Locale: fr-ca', function() { diff --git a/tests/locales/fr-ch.js b/tests/locales/fr-ch.js index 57230ba5..7bba1b44 100644 --- a/tests/locales/fr-ch.js +++ b/tests/locales/fr-ch.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/fr-ch'); + var locale = require('../../src/locales/fr-ch'); } describe('Locale: fr-ch', function() { diff --git a/tests/locales/fr.js b/tests/locales/fr.js index 73564648..f3bfb584 100644 --- a/tests/locales/fr.js +++ b/tests/locales/fr.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/fr'); + var locale = require('../../src/locales/fr'); } describe('Locale: fr', function() { diff --git a/tests/locales/hu.js b/tests/locales/hu.js index 5525dae3..6716d2de 100644 --- a/tests/locales/hu.js +++ b/tests/locales/hu.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/hu'); + var locale = require('../../src/locales/hu'); } describe('Locale: hu', function() { diff --git a/tests/locales/it.js b/tests/locales/it.js index 506d36ea..2f59461b 100644 --- a/tests/locales/it.js +++ b/tests/locales/it.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/it'); + var locale = require('../../src/locales/it'); } describe('Locale: it', function() { diff --git a/tests/locales/ja.js b/tests/locales/ja.js index 50c39ace..af5f4ee3 100644 --- a/tests/locales/ja.js +++ b/tests/locales/ja.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/ja'); + var locale = require('../../src/locales/ja'); } describe('Locale: ja', function() { diff --git a/tests/locales/lv.js b/tests/locales/lv.js index 44ff450f..425e1340 100644 --- a/tests/locales/lv.js +++ b/tests/locales/lv.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/lv'); + var locale = require('../../src/locales/lv'); } describe('Locale: lv', function() { diff --git a/tests/locales/nl-nl.js b/tests/locales/nl-nl.js index a269365e..bdf4c354 100644 --- a/tests/locales/nl-nl.js +++ b/tests/locales/nl-nl.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/nl-nl'); + var locale = require('../../src/locales/nl-nl'); } describe('Locale: nl-nl', function() { diff --git a/tests/locales/no.js b/tests/locales/no.js index 5714719d..e0cbcc31 100644 --- a/tests/locales/no.js +++ b/tests/locales/no.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/no'); + var locale = require('../../src/locales/no'); } describe('Locale: no', function() { diff --git a/tests/locales/pl.js b/tests/locales/pl.js index 740a71f4..7bc705b6 100644 --- a/tests/locales/pl.js +++ b/tests/locales/pl.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/pl'); + var locale = require('../../src/locales/pl'); } describe('Locale: pl', function() { diff --git a/tests/locales/pt-br.js b/tests/locales/pt-br.js index 3f137c2c..57e91a8a 100644 --- a/tests/locales/pt-br.js +++ b/tests/locales/pt-br.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/pt-br'); + var locale = require('../../src/locales/pt-br'); } describe('Locale: pt-br', function() { diff --git a/tests/locales/pt-pt.js b/tests/locales/pt-pt.js index cf241f06..f0dd31db 100644 --- a/tests/locales/pt-pt.js +++ b/tests/locales/pt-pt.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/pt-pt'); + var locale = require('../../src/locales/pt-pt'); } describe('Locale: pt-pt', function() { diff --git a/tests/locales/ru-ua.js b/tests/locales/ru-ua.js index 711ad919..db5765f7 100644 --- a/tests/locales/ru-ua.js +++ b/tests/locales/ru-ua.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/ru-ua'); + var locale = require('../../src/locales/ru-ua'); } describe('Locale: ru-ua', function() { diff --git a/tests/locales/ru.js b/tests/locales/ru.js index d9b4d02f..f5a1b3fe 100644 --- a/tests/locales/ru.js +++ b/tests/locales/ru.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/ru'); + var locale = require('../../src/locales/ru'); } describe('Locale: ru', function() { diff --git a/tests/locales/sk.js b/tests/locales/sk.js index 76e2ff91..a93e3c63 100644 --- a/tests/locales/sk.js +++ b/tests/locales/sk.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/sk'); + var locale = require('../../src/locales/sk'); } describe('Locale: sk', function() { diff --git a/tests/locales/th.js b/tests/locales/th.js index e155df1b..078e6432 100644 --- a/tests/locales/th.js +++ b/tests/locales/th.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/th'); + var locale = require('../../src/locales/th'); } describe('Locale: th', function() { diff --git a/tests/locales/tr.js b/tests/locales/tr.js index 5cbd0f0b..fb5741a7 100644 --- a/tests/locales/tr.js +++ b/tests/locales/tr.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/tr'); + var locale = require('../../src/locales/tr'); } describe('Locale: tr', function() { diff --git a/tests/locales/uk-ua.js b/tests/locales/uk-ua.js index 1e5940fa..935a5a01 100644 --- a/tests/locales/uk-ua.js +++ b/tests/locales/uk-ua.js @@ -1,8 +1,8 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; - var locale = require('../../locales/uk-ua'); + var locale = require('../../src/locales/uk-ua'); } describe('Locale: uk-ua', function() { diff --git a/tests/numeral/format.js b/tests/numeral/format.js index 6f66dd96..ccb38cb9 100644 --- a/tests/numeral/format.js +++ b/tests/numeral/format.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; } diff --git a/tests/numeral/manipulate.js b/tests/numeral/manipulate.js index a75bdb40..4a6a60cd 100644 --- a/tests/numeral/manipulate.js +++ b/tests/numeral/manipulate.js @@ -1,6 +1,6 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; } diff --git a/tests/numeral/misc.js b/tests/numeral/misc.js index 254bf29a..fba3f2db 100644 --- a/tests/numeral/misc.js +++ b/tests/numeral/misc.js @@ -1,6 +1,6 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; } diff --git a/tests/numeral/unformat.js b/tests/numeral/unformat.js index e61d2ded..25b4bd46 100644 --- a/tests/numeral/unformat.js +++ b/tests/numeral/unformat.js @@ -1,6 +1,6 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; } diff --git a/tests/numeral/validate.js b/tests/numeral/validate.js index 61f3e144..d72c71cb 100644 --- a/tests/numeral/validate.js +++ b/tests/numeral/validate.js @@ -1,6 +1,6 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../numeral'); + var numeral = require('../../src/numeral'); var expect = require('chai').expect; } From 7d7c0a5a199070bf8672d5cd9eb3dbfe47b31e4f Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Wed, 30 Nov 2016 22:58:31 -0800 Subject: [PATCH 089/150] start a core file --- Gruntfile.js | 13 +- src/core.js | 726 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 733 insertions(+), 6 deletions(-) create mode 100644 src/core.js diff --git a/Gruntfile.js b/Gruntfile.js index 29bdc8d4..0586cf7e 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -26,17 +26,18 @@ module.exports = function(grunt) { grunt.initConfig({ mochaTest : { all: [ - 'tests/numeral/*.js', - 'tests/locales/*.js' + 'tests/numeral/*.js' + // 'tests/locales/*.js' ] }, karma: { options: { files: [ - 'src/numeral.js', - 'src/locales/*.js', - 'tests/numeral/*.js', - 'tests/locales/*.js' + 'src/core.js', + 'tests/numeral/format.js' + // 'src/locales/*.js', + // 'tests/numeral/*.js', + // 'tests/locales/*.js' ], frameworks: [ 'mocha', diff --git a/src/core.js b/src/core.js new file mode 100644 index 00000000..72708811 --- /dev/null +++ b/src/core.js @@ -0,0 +1,726 @@ +/*! @preserve + * numeral.js + * version : Edge + * author : Adam Draper + * license : MIT + * http://adamwdraper.github.com/Numeral-js/ + */ + +(function() { + + /************************************ + Variables + ************************************/ + + var numeral, + _ = { + loadLocale: function (key, values) { + locales[key] = values; + }, + isNaN: function(value) { + return typeof value === 'number' && isNaN(value); + }, + includes: function(string, search) { + return string.indexOf(search) !== -1; + }, + reduce: function (array, callback) { + 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(this), len = t.length >>> 0, k = 0, value; + + if (arguments.length === 2) { + value = arguments[1]; + } 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); + } + }, + VERSION = 'Edge', + // internal storage for locale config files + locales = {}, + defaults = { + currentLocale: 'en', + zeroFormat: null, + nullFormat: null, + defaultFormat: '0,0' + }, + options = { + currentLocale: defaults.currentLocale, + zeroFormat: defaults.zeroFormat, + nullFormat: defaults.nullFormat, + defaultFormat: defaults.defaultFormat + }, + config = { + bytes: { + 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'] + } + } + }; + + + /************************************ + Constructors + ************************************/ + + + // Numeral prototype object + function Numeral(input, number) { + this._input = input; + + 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, 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); + + //roundingFunction = (roundingFunction !== undefined ? roundingFunction : Math.round); + // Multiply up by precision, round accurately, then divide and use native toFixed(): + output = (roundingFunction(value * power) / power).toFixed(boundedPrecision); + + if (optionals > maxDecimals - boundedPrecision) { + optionalsRegExp = new RegExp('\\.?0{1,' + (optionals - (maxDecimals - boundedPrecision)) + '}$'); + output = output.replace(optionalsRegExp, ''); + } + + return output; + } + + /************************************ + Formatting + ************************************/ + + // determine what type of formatting we need to do + function formatNumeral(n, format, roundingFunction) { + var value = n._value, + kind, + output, + formatFunction; + + if (value === 0 && options.zeroFormat !== null) { + output = options.zeroFormat; + } else if (value === null && options.nullFormat !== null) { + output = options.nullFormat; + } else { + kind = format.match(/(\$|%|:|[ai]?b|o|e\+|e-)/); + + switch (kind ? kind[0] : '') { + case '$': + formatFunction = formatCurrency; + break; + case '%': + formatFunction = formatPercentage; + break; + case ':': + formatFunction = formatTime; + break; + case 'b': + case 'ib': + formatFunction = formatBytes; + break; + case 'o': + formatFunction = formatOrdinal; + break; + case 'e+': + case 'e-': + formatFunction = formatExponential; + break; + default: + formatFunction = formatNumber; + } + + output = formatFunction(value, format, roundingFunction); + } + + return output; + } + + function formatCurrency(value, format, roundingFunction) { + var symbolIndex = format.indexOf('$'), + openParenIndex = format.indexOf('('), + minusSignIndex = format.indexOf('-'), + space = _.includes(format, ' $') || _.includes(format, '$ ') ? ' ' : '', + spliceIndex, + output; + + // strip format of spaces and $ + format = format.replace(/\s?\$\s?/, ''); + + // format the number + output = formatNumber(value, format, roundingFunction); + + // position the symbol + if (symbolIndex <= 1) { + if (_.includes(output, '(') || _.includes(output, '-')) { + output = output.split(''); + + spliceIndex = symbolIndex < openParenIndex || symbolIndex < minusSignIndex ? 0 : 1; + + output.splice(spliceIndex, 0, locales[options.currentLocale].currency.symbol + space); + + output = output.join(''); + } else { + output = locales[options.currentLocale].currency.symbol + space + output; + } + } else { + if (_.includes(output, ')')) { + output = output.split(''); + + output.splice(-1, 0, space + locales[options.currentLocale].currency.symbol); + + output = output.join(''); + } else { + output = output + space + locales[options.currentLocale].currency.symbol; + } + } + + return output; + } + + function formatPercentage(value, format, roundingFunction) { + var space = _.includes(format, ' %') ? ' ' : '', + output; + + value = value * 100; + + // check for space before % + format = format.replace(/\s?\%/, ''); + + output = formatNumber(value, format, roundingFunction); + + if (_.includes(output, ')')) { + output = output.split(''); + + output.splice(-1, 0, space + '%'); + + output = output.join(''); + } else { + output = output + space + '%'; + } + + return output; + } + + function formatBytes(value, format, roundingFunction) { + var output, + bytes = _.includes(format, 'ib') ? config.bytes.binary : config.bytes.decimal, + suffix = _.includes(format, ' b') || _.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 = formatNumber(value, format, roundingFunction); + + return output + suffix; + } + + function formatOrdinal(value, format, roundingFunction) { + var output, + ordinal = _.includes(format, ' o') ? ' ' : ''; + + // check for space before + format = format.replace(/\s?o/, ''); + + ordinal += locales[options.currentLocale].ordinal(value); + + output = formatNumber(value, format, roundingFunction); + + return output + ordinal; + } + + function formatExponential(value, format, roundingFunction) { + var output, + exponential = typeof value === 'number' && !_.isNaN(value) ? value.toExponential() : '0e+0', + parts = exponential.split('e'); + + format = format.replace(/e[\+|\-]{1}0/, ''); + + output = formatNumber(Number(parts[0]), format, roundingFunction); + + return output + 'e' + parts[1]; + } + + function formatTime(value) { + 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); + } + + function formatNumber(value, format, roundingFunction) { + var negP = false, + signed = false, + optDec = false, + abbr = '', + trillion = 1000000000000, + billion = 1000000000, + million = 1000000, + thousand = 1000, + abbrForce, // force abbreviation + abs, + min, + max, + power, + int, + precision, + thousands, + decimal = '', + neg = false; + + // 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 (_.includes(format, '(')) { + negP = true; + format = format.slice(1, -1); + } else if (_.includes(format, '+')) { + signed = true; + format = format.replace(/\+/g, ''); + } + + // see if abbreviation is wanted + if (_.includes(format, 'a')) { + abbrForce = format.match(/a(k|m|b|t)?/); + + abbrForce = abbrForce ? abbrForce[1] : false; + + // check for space before abbreviation + if (_.includes(format, ' a')) { + abbr = ' '; + } + + format = format.replace(new RegExp(abbr + 'a[kmbt]?'), ''); + + if (abs >= trillion && !abbrForce || abbrForce === 't') { + // trillion + abbr += locales[options.currentLocale].abbreviations.trillion; + value = value / trillion; + } else if (abs < trillion && abs >= billion && !abbrForce || abbrForce === 'b') { + // billion + abbr += locales[options.currentLocale].abbreviations.billion; + value = value / billion; + } else if (abs < billion && abs >= million && !abbrForce || abbrForce === 'm') { + // million + abbr += locales[options.currentLocale].abbreviations.million; + value = value / million; + } else if (abs < million && abs >= thousand && !abbrForce || abbrForce === 'k') { + // thousand + abbr += locales[options.currentLocale].abbreviations.thousand; + value = value / thousand; + } + } + + + if (_.includes(format, '[.]')) { + optDec = true; + format = format.replace('[.]', '.'); + } + + int = value.toString().split('.')[0]; + precision = format.split('.')[1]; + thousands = format.indexOf(','); + + if (precision) { + if (_.includes(precision, '[')) { + precision = precision.replace(']', ''); + precision = precision.split('['); + decimal = toFixed(value, (precision[0].length + precision[1].length), roundingFunction, precision[1].length); + } else { + decimal = toFixed(value, precision.length, roundingFunction); + } + + int = decimal.split('.')[0]; + + if (_.includes(decimal, '.')) { + decimal = locales[options.currentLocale].delimiters.decimal + decimal.split('.')[1]; + } else { + decimal = ''; + } + + if (optDec && Number(decimal.slice(1)) === 0) { + decimal = ''; + } + } else { + int = toFixed(value, null, roundingFunction); + } + + // format number + if (_.includes(int, '-')) { + int = int.slice(1); + neg = true; + } + + if (thousands > -1) { + int = int.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + locales[options.currentLocale].delimiters.thousands); + } + + if (format.indexOf('.') === 0) { + int = ''; + } + + return (negP && neg ? '(' : '') + (!negP && neg ? '-' : '') + (!neg && signed ? '+' : '') + int + decimal + (abbr ? abbr : '') + (negP && neg ? ')' : ''); + } + + + /************************************ + Unformatting + ************************************/ + + // revert to number + function unformatNumeral(n, string) { + var stringOriginal = string, + thousandRegExp, + millionRegExp, + billionRegExp, + trillionRegExp, + bytesMultiplier = false, + power, + value; + + if (_.includes(string, ':')) { + value = unformatTime(string); + } else if (_.includes(string, 'e+') || _.includes(string, 'e-')) { + value = unformatExponential(string); + } else { + if (string === options.zeroFormat || string === options.nullFormat) { + value = 0; + } else { + if (locales[options.currentLocale].delimiters.decimal !== '.') { + string = string.replace(/\./g, '').replace(locales[options.currentLocale].delimiters.decimal, '.'); + } + + // see if abbreviations are there so that we can multiply to the correct number + thousandRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.thousand + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); + millionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.million + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); + billionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.billion + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); + trillionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.trillion + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); + + // see if bytes are there so that we can multiply to the correct number + for (power = 1; power <= config.bytes.decimal.suffixes.length; power++) { + bytesMultiplier = ((_.includes(string, config.bytes.decimal.suffixes[power])) || (_.includes(string, config.bytes.binary.suffixes[power])))? Math.pow(1024, power) : false; + + if (bytesMultiplier) { + break; + } + } + + // do some math to create our number + value = bytesMultiplier ? bytesMultiplier : 1; + value *= stringOriginal.match(thousandRegExp) ? Math.pow(10, 3) : 1; + value *= stringOriginal.match(millionRegExp) ? Math.pow(10, 6) : 1; + value *= stringOriginal.match(billionRegExp) ? Math.pow(10, 9) : 1; + value *= stringOriginal.match(trillionRegExp) ? Math.pow(10, 12) : 1; + // check for percentage + value *= _.includes(string, '%') ? 0.01 : 1; + // check for negative number + value *= (string.split('-').length + Math.min(string.split('(').length - 1, string.split(')').length - 1)) % 2 ? 1 : -1; + // remove non numbers + value *= Number(string.replace(/[^0-9\.]+/g, '')); + // round if we are talking about bytes + value = bytesMultiplier ? Math.ceil(value) : value; + } + } + + n._value = value; + + return n._value; + } + + 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); + } + + function unformatExponential(string) { + var parts = _.includes(string, 'e+') ? string.split('e+') : string.split('e-'), + value = Number(parts[0]), + power = Number(parts[1]); + + power = _.includes(string, 'e-') ? power *= -1 : power; + + function cback(accum, curr, currI, O) { + var corrFactor = _.correctionFactor(accum, curr), + num = (accum * corrFactor) * (curr * corrFactor) / (corrFactor * corrFactor); + return num; + } + + return [value, Math.pow(10, power)].reduce(cback, 1); + } + + /************************************ + Top Level Functions + ************************************/ + + numeral = function(input) { + var value; + + 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 { + 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._ = _; + + // This function will load locales and then set the global locale. If + // no arguments are passed in, it will simply return the current global + // locale key. + numeral.locale = function(key, values) { + if (!key) { + return options.currentLocale; + } + + // standardize to lowercase + key = key.toLowerCase(); + + if (key && !values) { + if (!locales[key]) { + throw new Error('Unknown locale : ' + key); + } + + options.currentLocale = key; + } + + if (values || !locales[key]) { + _.loadLocale(key, values); + } + + return numeral; + }; + + // 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 Prototype + ************************************/ + + numeral.fn = Numeral.prototype = { + clone: function() { + return numeral(this); + }, + format: function (inputString, roundingFunction) { + return formatNumeral(this, + inputString ? inputString : options.defaultFormat, + roundingFunction !== undefined ? roundingFunction : Math.round + ); + }, + value: function() { + return this._value; + }, + set: function(value) { + this._value = Number(value); + + return this; + } + }; + + + + /************************************ + Default Locale + ************************************/ + + numeral.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: '$' + } + }); + + + /************************************ + Exposing Numeral + ************************************/ + + // CommonJS module is defined + if (typeof module !== 'undefined' && module.exports) { + module.exports = numeral; + } + + /*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; + } + + /*global define:false */ + if (typeof define === 'function' && define.amd) { + define([], function() { + return numeral; + }); + } +}).call(this); From 8afd5b0cb3ccb4e6257cc9071632f34faaad2c89 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 1 Dec 2016 00:05:32 -0800 Subject: [PATCH 090/150] create register function for formats --- Gruntfile.js | 2 +- src/core.js | 711 ++++++++++++++++++++-------------------- src/formats/currency.js | 67 ++++ tests/numeral/format.js | 259 ++++++++------- 4 files changed, 556 insertions(+), 483 deletions(-) create mode 100644 src/formats/currency.js diff --git a/Gruntfile.js b/Gruntfile.js index 0586cf7e..3076770b 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -26,7 +26,7 @@ module.exports = function(grunt) { grunt.initConfig({ mochaTest : { all: [ - 'tests/numeral/*.js' + 'tests/numeral/format.js' // 'tests/locales/*.js' ] }, diff --git a/src/core.js b/src/core.js index 72708811..03b298de 100644 --- a/src/core.js +++ b/src/core.js @@ -13,73 +13,10 @@ ************************************/ var numeral, - _ = { - loadLocale: function (key, values) { - locales[key] = values; - }, - isNaN: function(value) { - return typeof value === 'number' && isNaN(value); - }, - includes: function(string, search) { - return string.indexOf(search) !== -1; - }, - reduce: function (array, callback) { - 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(this), len = t.length >>> 0, k = 0, value; - - if (arguments.length === 2) { - value = arguments[1]; - } 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); - } - }, + _ = {}, VERSION = 'Edge', // internal storage for locale config files + formats = {}, locales = {}, defaults = { currentLocale: 'en', @@ -119,338 +56,266 @@ 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, 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); - - //roundingFunction = (roundingFunction !== undefined ? roundingFunction : Math.round); - // Multiply up by precision, round accurately, then divide and use native toFixed(): - output = (roundingFunction(value * power) / power).toFixed(boundedPrecision); - - if (optionals > maxDecimals - boundedPrecision) { - optionalsRegExp = new RegExp('\\.?0{1,' + (optionals - (maxDecimals - boundedPrecision)) + '}$'); - output = output.replace(optionalsRegExp, ''); - } - - return output; - } /************************************ Formatting ************************************/ - // determine what type of formatting we need to do - function formatNumeral(n, format, roundingFunction) { - var value = n._value, - kind, - output, - formatFunction; - - if (value === 0 && options.zeroFormat !== null) { - output = options.zeroFormat; - } else if (value === null && options.nullFormat !== null) { - output = options.nullFormat; - } else { - kind = format.match(/(\$|%|:|[ai]?b|o|e\+|e-)/); - - switch (kind ? kind[0] : '') { - case '$': - formatFunction = formatCurrency; - break; - case '%': - formatFunction = formatPercentage; - break; - case ':': - formatFunction = formatTime; - break; - case 'b': - case 'ib': - formatFunction = formatBytes; - break; - case 'o': - formatFunction = formatOrdinal; - break; - case 'e+': - case 'e-': - formatFunction = formatExponential; - break; - default: - formatFunction = formatNumber; - } - - output = formatFunction(value, format, roundingFunction); - } - - return output; - } - - function formatCurrency(value, format, roundingFunction) { - var symbolIndex = format.indexOf('$'), - openParenIndex = format.indexOf('('), - minusSignIndex = format.indexOf('-'), - space = _.includes(format, ' $') || _.includes(format, '$ ') ? ' ' : '', - spliceIndex, - output; + formats.currency = { + regexp: /(\$)/, + format: function(value, format, roundingFunction) { + var symbolIndex = format.indexOf('$'), + openParenIndex = format.indexOf('('), + minusSignIndex = format.indexOf('-'), + space = _.includes(format, ' $') || _.includes(format, '$ ') ? ' ' : '', + spliceIndex, + output; - // strip format of spaces and $ - format = format.replace(/\s?\$\s?/, ''); + // strip format of spaces and $ + format = format.replace(/\s?\$\s?/, ''); - // format the number - output = formatNumber(value, format, roundingFunction); + // format the number + output = formats.number(value, format, roundingFunction); - // position the symbol - if (symbolIndex <= 1) { - if (_.includes(output, '(') || _.includes(output, '-')) { - output = output.split(''); + // position the symbol + if (symbolIndex <= 1) { + if (_.includes(output, '(') || _.includes(output, '-')) { + output = output.split(''); - spliceIndex = symbolIndex < openParenIndex || symbolIndex < minusSignIndex ? 0 : 1; + spliceIndex = symbolIndex < openParenIndex || symbolIndex < minusSignIndex ? 0 : 1; - output.splice(spliceIndex, 0, locales[options.currentLocale].currency.symbol + space); + output.splice(spliceIndex, 0, locales[options.currentLocale].currency.symbol + space); - output = output.join(''); + output = output.join(''); + } else { + output = locales[options.currentLocale].currency.symbol + space + output; + } } else { - output = locales[options.currentLocale].currency.symbol + space + output; - } - } else { - if (_.includes(output, ')')) { - output = output.split(''); + if (_.includes(output, ')')) { + output = output.split(''); - output.splice(-1, 0, space + locales[options.currentLocale].currency.symbol); + output.splice(-1, 0, space + locales[options.currentLocale].currency.symbol); - output = output.join(''); - } else { - output = output + space + locales[options.currentLocale].currency.symbol; + output = output.join(''); + } else { + output = output + space + locales[options.currentLocale].currency.symbol; + } } - } - - return output; - } - - function formatPercentage(value, format, roundingFunction) { - var space = _.includes(format, ' %') ? ' ' : '', - output; - value = value * 100; - - // check for space before % - format = format.replace(/\s?\%/, ''); - - output = formatNumber(value, format, roundingFunction); - - if (_.includes(output, ')')) { - output = output.split(''); - - output.splice(-1, 0, space + '%'); - - output = output.join(''); - } else { - output = output + space + '%'; + return output; } + }; - return output; - } - - function formatBytes(value, format, roundingFunction) { - var output, - bytes = _.includes(format, 'ib') ? config.bytes.binary : config.bytes.decimal, - suffix = _.includes(format, ' b') || _.includes(format, ' ib') ? ' ' : '', - power, - min, - max; - // check for space before - format = format.replace(/\s?i?b/, ''); + // function formatPercentage(value, format, roundingFunction) { + // var space = _.includes(format, ' %') ? ' ' : '', + // output; + // + // value = value * 100; + // + // // check for space before % + // format = format.replace(/\s?\%/, ''); + // + // output = formatNumber(value, format, roundingFunction); + // + // if (_.includes(output, ')')) { + // output = output.split(''); + // + // output.splice(-1, 0, space + '%'); + // + // output = output.join(''); + // } else { + // output = output + space + '%'; + // } + // + // return output; + // } + // + // function formatBytes(value, format, roundingFunction) { + // var output, + // bytes = _.includes(format, 'ib') ? config.bytes.binary : config.bytes.decimal, + // suffix = _.includes(format, ' b') || _.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 = formatNumber(value, format, roundingFunction); + // + // return output + suffix; + // } + // + // function formatOrdinal(value, format, roundingFunction) { + // var output, + // ordinal = _.includes(format, ' o') ? ' ' : ''; + // + // // check for space before + // format = format.replace(/\s?o/, ''); + // + // ordinal += locales[options.currentLocale].ordinal(value); + // + // output = formatNumber(value, format, roundingFunction); + // + // return output + ordinal; + // } + // + // function formatExponential(value, format, roundingFunction) { + // var output, + // exponential = typeof value === 'number' && !_.isNaN(value) ? value.toExponential() : '0e+0', + // parts = exponential.split('e'); + // + // format = format.replace(/e[\+|\-]{1}0/, ''); + // + // output = formatNumber(Number(parts[0]), format, roundingFunction); + // + // return output + 'e' + parts[1]; + // } + // + // function formatTime(value) { + // 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); + // } + + formats.number = { + regexp: null, + format: function(value, format, roundingFunction) { + var negP = false, + signed = false, + optDec = false, + abbr = '', + trillion = 1000000000000, + billion = 1000000000, + million = 1000000, + thousand = 1000, + abbrForce, // force abbreviation + abs, + min, + max, + power, + int, + precision, + thousands, + decimal = '', + neg = false; + + // 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 (_.includes(format, '(')) { + negP = true; + format = format.slice(1, -1); + } else if (_.includes(format, '+')) { + signed = true; + format = format.replace(/\+/g, ''); + } - for (power = 0; power <= bytes.suffixes.length; power++) { - min = Math.pow(bytes.base, power); - max = Math.pow(bytes.base, power + 1); + // see if abbreviation is wanted + if (_.includes(format, 'a')) { + abbrForce = format.match(/a(k|m|b|t)?/); - if (value === null || value === 0 || value >= min && value < max) { - suffix += bytes.suffixes[power]; + abbrForce = abbrForce ? abbrForce[1] : false; - if (min > 0) { - value = value / min; + // check for space before abbreviation + if (_.includes(format, ' a')) { + abbr = ' '; } - break; + format = format.replace(new RegExp(abbr + 'a[kmbt]?'), ''); + + if (abs >= trillion && !abbrForce || abbrForce === 't') { + // trillion + abbr += locales[options.currentLocale].abbreviations.trillion; + value = value / trillion; + } else if (abs < trillion && abs >= billion && !abbrForce || abbrForce === 'b') { + // billion + abbr += locales[options.currentLocale].abbreviations.billion; + value = value / billion; + } else if (abs < billion && abs >= million && !abbrForce || abbrForce === 'm') { + // million + abbr += locales[options.currentLocale].abbreviations.million; + value = value / million; + } else if (abs < million && abs >= thousand && !abbrForce || abbrForce === 'k') { + // thousand + abbr += locales[options.currentLocale].abbreviations.thousand; + value = value / thousand; + } } - } - - output = formatNumber(value, format, roundingFunction); - - return output + suffix; - } - - function formatOrdinal(value, format, roundingFunction) { - var output, - ordinal = _.includes(format, ' o') ? ' ' : ''; - - // check for space before - format = format.replace(/\s?o/, ''); - - ordinal += locales[options.currentLocale].ordinal(value); - - output = formatNumber(value, format, roundingFunction); - - return output + ordinal; - } - - function formatExponential(value, format, roundingFunction) { - var output, - exponential = typeof value === 'number' && !_.isNaN(value) ? value.toExponential() : '0e+0', - parts = exponential.split('e'); - - format = format.replace(/e[\+|\-]{1}0/, ''); - output = formatNumber(Number(parts[0]), format, roundingFunction); - return output + 'e' + parts[1]; - } - - function formatTime(value) { - 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); - } - - function formatNumber(value, format, roundingFunction) { - var negP = false, - signed = false, - optDec = false, - abbr = '', - trillion = 1000000000000, - billion = 1000000000, - million = 1000000, - thousand = 1000, - abbrForce, // force abbreviation - abs, - min, - max, - power, - int, - precision, - thousands, - decimal = '', - neg = false; - - // 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 (_.includes(format, '(')) { - negP = true; - format = format.slice(1, -1); - } else if (_.includes(format, '+')) { - signed = true; - format = format.replace(/\+/g, ''); - } - - // see if abbreviation is wanted - if (_.includes(format, 'a')) { - abbrForce = format.match(/a(k|m|b|t)?/); - - abbrForce = abbrForce ? abbrForce[1] : false; - - // check for space before abbreviation - if (_.includes(format, ' a')) { - abbr = ' '; + if (_.includes(format, '[.]')) { + optDec = true; + format = format.replace('[.]', '.'); } - format = format.replace(new RegExp(abbr + 'a[kmbt]?'), ''); - - if (abs >= trillion && !abbrForce || abbrForce === 't') { - // trillion - abbr += locales[options.currentLocale].abbreviations.trillion; - value = value / trillion; - } else if (abs < trillion && abs >= billion && !abbrForce || abbrForce === 'b') { - // billion - abbr += locales[options.currentLocale].abbreviations.billion; - value = value / billion; - } else if (abs < billion && abs >= million && !abbrForce || abbrForce === 'm') { - // million - abbr += locales[options.currentLocale].abbreviations.million; - value = value / million; - } else if (abs < million && abs >= thousand && !abbrForce || abbrForce === 'k') { - // thousand - abbr += locales[options.currentLocale].abbreviations.thousand; - value = value / thousand; - } - } + int = value.toString().split('.')[0]; + precision = format.split('.')[1]; + thousands = format.indexOf(','); + if (precision) { + if (_.includes(precision, '[')) { + precision = precision.replace(']', ''); + precision = precision.split('['); + decimal = _.toFixed(value, (precision[0].length + precision[1].length), roundingFunction, precision[1].length); + } else { + decimal = _.toFixed(value, precision.length, roundingFunction); + } - if (_.includes(format, '[.]')) { - optDec = true; - format = format.replace('[.]', '.'); - } + int = decimal.split('.')[0]; - int = value.toString().split('.')[0]; - precision = format.split('.')[1]; - thousands = format.indexOf(','); + if (_.includes(decimal, '.')) { + decimal = locales[options.currentLocale].delimiters.decimal + decimal.split('.')[1]; + } else { + decimal = ''; + } - if (precision) { - if (_.includes(precision, '[')) { - precision = precision.replace(']', ''); - precision = precision.split('['); - decimal = toFixed(value, (precision[0].length + precision[1].length), roundingFunction, precision[1].length); + if (optDec && Number(decimal.slice(1)) === 0) { + decimal = ''; + } } else { - decimal = toFixed(value, precision.length, roundingFunction); + int = _.toFixed(value, null, roundingFunction); } - int = decimal.split('.')[0]; - - if (_.includes(decimal, '.')) { - decimal = locales[options.currentLocale].delimiters.decimal + decimal.split('.')[1]; - } else { - decimal = ''; + // format number + if (_.includes(int, '-')) { + int = int.slice(1); + neg = true; } - if (optDec && Number(decimal.slice(1)) === 0) { - decimal = ''; + if (thousands > -1) { + int = int.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + locales[options.currentLocale].delimiters.thousands); } - } else { - int = toFixed(value, null, roundingFunction); - } - - // format number - if (_.includes(int, '-')) { - int = int.slice(1); - neg = true; - } - if (thousands > -1) { - int = int.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + locales[options.currentLocale].delimiters.thousands); - } + if (format.indexOf('.') === 0) { + int = ''; + } - if (format.indexOf('.') === 0) { - int = ''; + return (negP && neg ? '(' : '') + (!negP && neg ? '-' : '') + (!neg && signed ? '+' : '') + int + decimal + (abbr ? abbr : '') + (negP && neg ? ')' : ''); } - - return (negP && neg ? '(' : '') + (!negP && neg ? '-' : '') + (!neg && signed ? '+' : '') + int + decimal + (abbr ? abbr : '') + (negP && neg ? ')' : ''); - } + }; /************************************ @@ -582,7 +447,105 @@ }; // helper functions - numeral._ = _; + numeral._ = _ = { + loadLocale: function (key, values) { + locales[key] = values; + }, + isNaN: function(value) { + return typeof value === 'number' && isNaN(value); + }, + includes: function(string, search) { + return string.indexOf(search) !== -1; + }, + reduce: function (array, callback) { + 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(this), len = t.length >>> 0, k = 0, value; + + if (arguments.length === 2) { + value = arguments[1]; + } 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); + + //roundingFunction = (roundingFunction !== undefined ? roundingFunction : Math.round); + // Multiply up by precision, round accurately, then divide and use native toFixed(): + output = (roundingFunction(value * power) / power).toFixed(boundedPrecision); + + if (optionals > maxDecimals - boundedPrecision) { + optionalsRegExp = new RegExp('\\.?0{1,' + (optionals - (maxDecimals - boundedPrecision)) + '}$'); + output = output.replace(optionalsRegExp, ''); + } + + return output; + } + }; // This function will load locales and then set the global locale. If // no arguments are passed in, it will simply return the current global @@ -654,11 +617,34 @@ clone: function() { return numeral(this); }, - format: function (inputString, roundingFunction) { - return formatNumeral(this, - inputString ? inputString : options.defaultFormat, - roundingFunction !== undefined ? roundingFunction : Math.round - ); + format: function(inputString, roundingFunction) { + var value = this._value, + format = inputString || options.defaultFormat, + kind, + output, + formatFunction = formats.number.format; + + // 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 (kind.regexp && format.match(kind.regexp)) { + formatFunction = kind.format; + + break; + } + } + + output = formatFunction(value, format, roundingFunction); + } + + return output; }, value: function() { return this._value; @@ -667,6 +653,9 @@ this._value = Number(value); return this; + }, + register: function(type, name, format) { + this[type][name] = format; } }; diff --git a/src/formats/currency.js b/src/formats/currency.js new file mode 100644 index 00000000..f27ecbe6 --- /dev/null +++ b/src/formats/currency.js @@ -0,0 +1,67 @@ +/* + * numeral.js format configuration + * format : currency + * author : Adam Draper : https://github.com/adamwdraper + */ + + + + +(function () { + // var numeral; + // var currency = { + // regexp: /(\$)/, + // format: function(value, format, roundingFunction) { + // var symbolIndex = format.indexOf('$'), + // openParenIndex = format.indexOf('('), + // minusSignIndex = format.indexOf('-'), + // space = _.includes(format, ' $') || _.includes(format, '$ ') ? ' ' : '', + // spliceIndex, + // output; + // + // // strip format of spaces and $ + // format = format.replace(/\s?\$\s?/, ''); + // + // // format the number + // output = formatNumber(value, format, roundingFunction); + // + // // position the symbol + // if (symbolIndex <= 1) { + // if (_.includes(output, '(') || _.includes(output, '-')) { + // output = output.split(''); + // + // spliceIndex = symbolIndex < openParenIndex || symbolIndex < minusSignIndex ? 0 : 1; + // + // output.splice(spliceIndex, 0, locales[options.currentLocale].currency.symbol + space); + // + // output = output.join(''); + // } else { + // output = locales[options.currentLocale].currency.symbol + space + output; + // } + // } else { + // if (_.includes(output, ')')) { + // output = output.split(''); + // + // output.splice(-1, 0, space + locales[options.currentLocale].currency.symbol); + // + // output = output.join(''); + // } else { + // output = output + space + locales[options.currentLocale].currency.symbol; + // } + // } + // + // return output; + // } + // }; + // + // // get numeral from environment + // if (typeof window !== 'undefined' && this.numeral) { + // // Browser + // numeral = this.numeral; + // } else if (typeof module !== 'undefined' && module.exports) { + // // Node + // numeral = require('../numeral'); + // } + // + // numeral.register('format', 'currency', currency); +}()); diff --git a/tests/numeral/format.js b/tests/numeral/format.js index ccb38cb9..cb378f61 100644 --- a/tests/numeral/format.js +++ b/tests/numeral/format.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../src/numeral'); + var numeral = require('../../src/core'); var expect = require('chai').expect; } @@ -10,14 +10,14 @@ describe('Format', 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('Default', function() { + // it('should set a default format', function() { + // numeral.defaultFormat('0,0'); + // + // expect(numeral(10000).format()).to.equal('10,000'); + // }); + // }); + // describe('Numbers', function() { it('should format to a number', function() { var tests = [ @@ -51,12 +51,6 @@ describe('Format', function() { [3162.63,'0.0[00000000000000]','3162.63'], [1.99,'0.[0]','2'], [1.0501,'0.00[0]','1.05'], - // ordinals - [1,'0o','1st'], - [52,'0 o','52 nd'], - [23,'0o','23rd'], - [100,'0o','100th'], - [1234,'0,0o','1,234th'], // abbreviations [2000000000,'0.0a','2.0b'], [1230974,'0.0a','1.2m'], @@ -84,6 +78,29 @@ describe('Format', function() { } }); }); + // describe('Ordinals', function() { + // 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'); + // } + // }); + // }); describe('Currency', function() { it('should format to currency', function() { @@ -123,110 +140,110 @@ describe('Format', function() { } }); }); - - describe('Bytes', function() { - 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]); - } - }); - }); - - describe('Percentages', function() { - it('should format to percentages', 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]); - } - }); - }); - - describe('Times', function() { - it('should format to times', 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]); - } - - }); - }); - - describe('Exponential', function() { - 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]); - } - - }); - }); - - 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.974878234,'0.000%','97.487%','97.488%'], - [-0.433,'0 %','-44 %', '-43 %'] - ], - 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('Bytes', function() { + // 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]); + // } + // }); + // }); + // + // describe('Percentages', function() { + // it('should format to percentages', 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]); + // } + // }); + // }); + // + // describe('Times', function() { + // it('should format to times', 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]); + // } + // + // }); + // }); + // + // describe('Exponential', function() { + // 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]); + // } + // + // }); + // }); + // + // 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.974878234,'0.000%','97.487%','97.488%'], + // [-0.433,'0 %','-44 %', '-43 %'] + // ], + // 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]); + // } + // }); + // }); }); From 9d12018af508de9e7d25f953602af618852fca37 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 1 Dec 2016 11:15:41 -0800 Subject: [PATCH 091/150] move number to format config --- Gruntfile.js | 2 +- src/core.js | 715 ------------------------- src/formats/number.js | 143 +++++ src/numeral-old.js | 876 +++++++++++++++++++++++++++++++ src/numeral.js | 1091 +++++++++++++++------------------------ tests/formats/number.js | 75 +++ tests/numeral/format.js | 76 +-- 7 files changed, 1545 insertions(+), 1433 deletions(-) delete mode 100644 src/core.js create mode 100644 src/formats/number.js create mode 100644 src/numeral-old.js create mode 100644 tests/formats/number.js diff --git a/Gruntfile.js b/Gruntfile.js index 3076770b..235055f0 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -26,7 +26,7 @@ module.exports = function(grunt) { grunt.initConfig({ mochaTest : { all: [ - 'tests/numeral/format.js' + 'tests/formats/number.js' // 'tests/locales/*.js' ] }, diff --git a/src/core.js b/src/core.js deleted file mode 100644 index 03b298de..00000000 --- a/src/core.js +++ /dev/null @@ -1,715 +0,0 @@ -/*! @preserve - * numeral.js - * version : Edge - * author : Adam Draper - * license : MIT - * http://adamwdraper.github.com/Numeral-js/ - */ - -(function() { - - /************************************ - Variables - ************************************/ - - var numeral, - _ = {}, - VERSION = 'Edge', - // internal storage for locale config files - formats = {}, - locales = {}, - defaults = { - currentLocale: 'en', - zeroFormat: null, - nullFormat: null, - defaultFormat: '0,0' - }, - options = { - currentLocale: defaults.currentLocale, - zeroFormat: defaults.zeroFormat, - nullFormat: defaults.nullFormat, - defaultFormat: defaults.defaultFormat - }, - config = { - bytes: { - 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'] - } - } - }; - - - /************************************ - Constructors - ************************************/ - - - // Numeral prototype object - function Numeral(input, number) { - this._input = input; - - this._value = number; - } - - - /************************************ - Formatting - ************************************/ - - formats.currency = { - regexp: /(\$)/, - format: function(value, format, roundingFunction) { - var symbolIndex = format.indexOf('$'), - openParenIndex = format.indexOf('('), - minusSignIndex = format.indexOf('-'), - space = _.includes(format, ' $') || _.includes(format, '$ ') ? ' ' : '', - spliceIndex, - output; - - // strip format of spaces and $ - format = format.replace(/\s?\$\s?/, ''); - - // format the number - output = formats.number(value, format, roundingFunction); - - // position the symbol - if (symbolIndex <= 1) { - if (_.includes(output, '(') || _.includes(output, '-')) { - output = output.split(''); - - spliceIndex = symbolIndex < openParenIndex || symbolIndex < minusSignIndex ? 0 : 1; - - output.splice(spliceIndex, 0, locales[options.currentLocale].currency.symbol + space); - - output = output.join(''); - } else { - output = locales[options.currentLocale].currency.symbol + space + output; - } - } else { - if (_.includes(output, ')')) { - output = output.split(''); - - output.splice(-1, 0, space + locales[options.currentLocale].currency.symbol); - - output = output.join(''); - } else { - output = output + space + locales[options.currentLocale].currency.symbol; - } - } - - return output; - } - }; - - - // function formatPercentage(value, format, roundingFunction) { - // var space = _.includes(format, ' %') ? ' ' : '', - // output; - // - // value = value * 100; - // - // // check for space before % - // format = format.replace(/\s?\%/, ''); - // - // output = formatNumber(value, format, roundingFunction); - // - // if (_.includes(output, ')')) { - // output = output.split(''); - // - // output.splice(-1, 0, space + '%'); - // - // output = output.join(''); - // } else { - // output = output + space + '%'; - // } - // - // return output; - // } - // - // function formatBytes(value, format, roundingFunction) { - // var output, - // bytes = _.includes(format, 'ib') ? config.bytes.binary : config.bytes.decimal, - // suffix = _.includes(format, ' b') || _.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 = formatNumber(value, format, roundingFunction); - // - // return output + suffix; - // } - // - // function formatOrdinal(value, format, roundingFunction) { - // var output, - // ordinal = _.includes(format, ' o') ? ' ' : ''; - // - // // check for space before - // format = format.replace(/\s?o/, ''); - // - // ordinal += locales[options.currentLocale].ordinal(value); - // - // output = formatNumber(value, format, roundingFunction); - // - // return output + ordinal; - // } - // - // function formatExponential(value, format, roundingFunction) { - // var output, - // exponential = typeof value === 'number' && !_.isNaN(value) ? value.toExponential() : '0e+0', - // parts = exponential.split('e'); - // - // format = format.replace(/e[\+|\-]{1}0/, ''); - // - // output = formatNumber(Number(parts[0]), format, roundingFunction); - // - // return output + 'e' + parts[1]; - // } - // - // function formatTime(value) { - // 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); - // } - - formats.number = { - regexp: null, - format: function(value, format, roundingFunction) { - var negP = false, - signed = false, - optDec = false, - abbr = '', - trillion = 1000000000000, - billion = 1000000000, - million = 1000000, - thousand = 1000, - abbrForce, // force abbreviation - abs, - min, - max, - power, - int, - precision, - thousands, - decimal = '', - neg = false; - - // 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 (_.includes(format, '(')) { - negP = true; - format = format.slice(1, -1); - } else if (_.includes(format, '+')) { - signed = true; - format = format.replace(/\+/g, ''); - } - - // see if abbreviation is wanted - if (_.includes(format, 'a')) { - abbrForce = format.match(/a(k|m|b|t)?/); - - abbrForce = abbrForce ? abbrForce[1] : false; - - // check for space before abbreviation - if (_.includes(format, ' a')) { - abbr = ' '; - } - - format = format.replace(new RegExp(abbr + 'a[kmbt]?'), ''); - - if (abs >= trillion && !abbrForce || abbrForce === 't') { - // trillion - abbr += locales[options.currentLocale].abbreviations.trillion; - value = value / trillion; - } else if (abs < trillion && abs >= billion && !abbrForce || abbrForce === 'b') { - // billion - abbr += locales[options.currentLocale].abbreviations.billion; - value = value / billion; - } else if (abs < billion && abs >= million && !abbrForce || abbrForce === 'm') { - // million - abbr += locales[options.currentLocale].abbreviations.million; - value = value / million; - } else if (abs < million && abs >= thousand && !abbrForce || abbrForce === 'k') { - // thousand - abbr += locales[options.currentLocale].abbreviations.thousand; - value = value / thousand; - } - } - - - if (_.includes(format, '[.]')) { - optDec = true; - format = format.replace('[.]', '.'); - } - - int = value.toString().split('.')[0]; - precision = format.split('.')[1]; - thousands = format.indexOf(','); - - if (precision) { - if (_.includes(precision, '[')) { - precision = precision.replace(']', ''); - precision = precision.split('['); - decimal = _.toFixed(value, (precision[0].length + precision[1].length), roundingFunction, precision[1].length); - } else { - decimal = _.toFixed(value, precision.length, roundingFunction); - } - - int = decimal.split('.')[0]; - - if (_.includes(decimal, '.')) { - decimal = locales[options.currentLocale].delimiters.decimal + decimal.split('.')[1]; - } else { - decimal = ''; - } - - if (optDec && Number(decimal.slice(1)) === 0) { - decimal = ''; - } - } else { - int = _.toFixed(value, null, roundingFunction); - } - - // format number - if (_.includes(int, '-')) { - int = int.slice(1); - neg = true; - } - - if (thousands > -1) { - int = int.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + locales[options.currentLocale].delimiters.thousands); - } - - if (format.indexOf('.') === 0) { - int = ''; - } - - return (negP && neg ? '(' : '') + (!negP && neg ? '-' : '') + (!neg && signed ? '+' : '') + int + decimal + (abbr ? abbr : '') + (negP && neg ? ')' : ''); - } - }; - - - /************************************ - Unformatting - ************************************/ - - // revert to number - function unformatNumeral(n, string) { - var stringOriginal = string, - thousandRegExp, - millionRegExp, - billionRegExp, - trillionRegExp, - bytesMultiplier = false, - power, - value; - - if (_.includes(string, ':')) { - value = unformatTime(string); - } else if (_.includes(string, 'e+') || _.includes(string, 'e-')) { - value = unformatExponential(string); - } else { - if (string === options.zeroFormat || string === options.nullFormat) { - value = 0; - } else { - if (locales[options.currentLocale].delimiters.decimal !== '.') { - string = string.replace(/\./g, '').replace(locales[options.currentLocale].delimiters.decimal, '.'); - } - - // see if abbreviations are there so that we can multiply to the correct number - thousandRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.thousand + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); - millionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.million + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); - billionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.billion + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); - trillionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.trillion + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); - - // see if bytes are there so that we can multiply to the correct number - for (power = 1; power <= config.bytes.decimal.suffixes.length; power++) { - bytesMultiplier = ((_.includes(string, config.bytes.decimal.suffixes[power])) || (_.includes(string, config.bytes.binary.suffixes[power])))? Math.pow(1024, power) : false; - - if (bytesMultiplier) { - break; - } - } - - // do some math to create our number - value = bytesMultiplier ? bytesMultiplier : 1; - value *= stringOriginal.match(thousandRegExp) ? Math.pow(10, 3) : 1; - value *= stringOriginal.match(millionRegExp) ? Math.pow(10, 6) : 1; - value *= stringOriginal.match(billionRegExp) ? Math.pow(10, 9) : 1; - value *= stringOriginal.match(trillionRegExp) ? Math.pow(10, 12) : 1; - // check for percentage - value *= _.includes(string, '%') ? 0.01 : 1; - // check for negative number - value *= (string.split('-').length + Math.min(string.split('(').length - 1, string.split(')').length - 1)) % 2 ? 1 : -1; - // remove non numbers - value *= Number(string.replace(/[^0-9\.]+/g, '')); - // round if we are talking about bytes - value = bytesMultiplier ? Math.ceil(value) : value; - } - } - - n._value = value; - - return n._value; - } - - 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); - } - - function unformatExponential(string) { - var parts = _.includes(string, 'e+') ? string.split('e+') : string.split('e-'), - value = Number(parts[0]), - power = Number(parts[1]); - - power = _.includes(string, 'e-') ? power *= -1 : power; - - function cback(accum, curr, currI, O) { - var corrFactor = _.correctionFactor(accum, curr), - num = (accum * corrFactor) * (curr * corrFactor) / (corrFactor * corrFactor); - return num; - } - - return [value, Math.pow(10, power)].reduce(cback, 1); - } - - /************************************ - Top Level Functions - ************************************/ - - numeral = function(input) { - var value; - - 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 { - 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._ = _ = { - loadLocale: function (key, values) { - locales[key] = values; - }, - isNaN: function(value) { - return typeof value === 'number' && isNaN(value); - }, - includes: function(string, search) { - return string.indexOf(search) !== -1; - }, - reduce: function (array, callback) { - 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(this), len = t.length >>> 0, k = 0, value; - - if (arguments.length === 2) { - value = arguments[1]; - } 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); - - //roundingFunction = (roundingFunction !== undefined ? roundingFunction : Math.round); - // Multiply up by precision, round accurately, then divide and use native toFixed(): - output = (roundingFunction(value * power) / power).toFixed(boundedPrecision); - - if (optionals > maxDecimals - boundedPrecision) { - optionalsRegExp = new RegExp('\\.?0{1,' + (optionals - (maxDecimals - boundedPrecision)) + '}$'); - output = output.replace(optionalsRegExp, ''); - } - - return output; - } - }; - - // This function will load locales and then set the global locale. If - // no arguments are passed in, it will simply return the current global - // locale key. - numeral.locale = function(key, values) { - if (!key) { - return options.currentLocale; - } - - // standardize to lowercase - key = key.toLowerCase(); - - if (key && !values) { - if (!locales[key]) { - throw new Error('Unknown locale : ' + key); - } - - options.currentLocale = key; - } - - if (values || !locales[key]) { - _.loadLocale(key, values); - } - - return numeral; - }; - - // 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 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 = formats.number.format; - - // 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 (kind.regexp && format.match(kind.regexp)) { - formatFunction = kind.format; - - break; - } - } - - output = formatFunction(value, format, roundingFunction); - } - - return output; - }, - value: function() { - return this._value; - }, - set: function(value) { - this._value = Number(value); - - return this; - }, - register: function(type, name, format) { - this[type][name] = format; - } - }; - - - - /************************************ - Default Locale - ************************************/ - - numeral.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: '$' - } - }); - - - /************************************ - Exposing Numeral - ************************************/ - - // CommonJS module is defined - if (typeof module !== 'undefined' && module.exports) { - module.exports = numeral; - } - - /*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; - } - - /*global define:false */ - if (typeof define === 'function' && define.amd) { - define([], function() { - return numeral; - }); - } -}).call(this); diff --git a/src/formats/number.js b/src/formats/number.js new file mode 100644 index 00000000..98b695ff --- /dev/null +++ b/src/formats/number.js @@ -0,0 +1,143 @@ +/* + * numeral.js format configuration + * format : currency + * author : Adam Draper : https://github.com/adamwdraper + */ + +(function () { + var numeral, + format; + + // get numeral from environment + if (typeof window !== 'undefined' && this.numeral) { + // Browser + numeral = this.numeral; + } else if (typeof module !== 'undefined' && module.exports) { + // Node + numeral = require('../numeral'); + } + + format = { + regexp: null, + format: function(value, format, roundingFunction) { + var locale = numeral.locales[numeral.options.currentLocale], + negP = false, + signed = false, + optDec = false, + abbr = '', + trillion = 1000000000000, + billion = 1000000000, + million = 1000000, + thousand = 1000, + abbrForce, // force abbreviation + abs, + min, + max, + power, + int, + precision, + thousands, + decimal = '', + neg = false; + + // 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.slice(1, -1); + } else if (numeral._.includes(format, '+')) { + signed = true; + 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; + } + } + + + if (numeral._.includes(format, '[.]')) { + optDec = true; + format = format.replace('[.]', '.'); + } + + int = value.toString().split('.')[0]; + precision = format.split('.')[1]; + thousands = format.indexOf(','); + + 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, null, roundingFunction); + } + + // format number + if (numeral._.includes(int, '-')) { + int = int.slice(1); + neg = true; + } + + if (thousands > -1) { + int = int.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + locale.delimiters.thousands); + } + + if (format.indexOf('.') === 0) { + int = ''; + } + + return (negP && neg ? '(' : '') + (!negP && neg ? '-' : '') + (!neg && signed ? '+' : '') + int + decimal + (abbr ? abbr : '') + (negP && neg ? ')' : ''); + } + }; + + numeral.register('format', 'number', format); +}()); diff --git a/src/numeral-old.js b/src/numeral-old.js new file mode 100644 index 00000000..00cc7086 --- /dev/null +++ b/src/numeral-old.js @@ -0,0 +1,876 @@ +/*! @preserve + * numeral.js + * version : Edge + * author : Adam Draper + * license : MIT + * http://adamwdraper.github.com/Numeral-js/ + */ + +(function() { + + /************************************ + Variables + ************************************/ + + var numeral, + VERSION = 'Edge', + // internal storage for locale config files + locales = {}, + defaults = { + currentLocale: 'en', + zeroFormat: null, + nullFormat: null, + defaultFormat: '0,0' + }, + options = { + currentLocale: defaults.currentLocale, + zeroFormat: defaults.zeroFormat, + nullFormat: defaults.nullFormat, + defaultFormat: defaults.defaultFormat + }, + config = { + bytes: { + 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'] + } + } + }; + + + /************************************ + 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, 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); + + //roundingFunction = (roundingFunction !== undefined ? roundingFunction : Math.round); + // Multiply up by precision, round accurately, then divide and use native toFixed(): + output = (roundingFunction(value * power) / power).toFixed(boundedPrecision); + + if (optionals > maxDecimals - boundedPrecision) { + optionalsRegExp = new RegExp('\\.?0{1,' + (optionals - (maxDecimals - boundedPrecision)) + '}$'); + output = output.replace(optionalsRegExp, ''); + } + + return output; + } + + /************************************ + Formatting + ************************************/ + + // determine what type of formatting we need to do + function formatNumeral(n, format, roundingFunction) { + var value = n._value, + kind, + output, + formatFunction; + + if (value === 0 && options.zeroFormat !== null) { + output = options.zeroFormat; + } else if (value === null && options.nullFormat !== null) { + output = options.nullFormat; + } else { + kind = format.match(/(\$|%|:|[ai]?b|o|e\+|e-)/); + + switch (kind ? kind[0] : '') { + case '$': + formatFunction = formatCurrency; + break; + case '%': + formatFunction = formatPercentage; + break; + case ':': + formatFunction = formatTime; + break; + case 'b': + case 'ib': + formatFunction = formatBytes; + break; + case 'o': + formatFunction = formatOrdinal; + break; + case 'e+': + case 'e-': + formatFunction = formatExponential; + break; + default: + formatFunction = formatNumber; + } + + output = formatFunction(value, format, roundingFunction); + } + + return output; + } + + function formatCurrency(value, format, roundingFunction) { + var symbolIndex = format.indexOf('$'), + openParenIndex = format.indexOf('('), + minusSignIndex = format.indexOf('-'), + space = format.includes(' $') || format.includes('$ ') ? ' ' : '', + spliceIndex, + output; + + // strip format of spaces and $ + format = format.replace(/\s?\$\s?/, ''); + + // format the number + output = formatNumber(value, format, roundingFunction); + + // position the symbol + if (symbolIndex <= 1) { + if (output.includes('(') || output.includes('-')) { + output = output.split(''); + + spliceIndex = symbolIndex < openParenIndex || symbolIndex < minusSignIndex ? 0 : 1; + + output.splice(spliceIndex, 0, locales[options.currentLocale].currency.symbol + space); + + output = output.join(''); + } else { + output = locales[options.currentLocale].currency.symbol + space + output; + } + } else { + if (output.includes(')')) { + output = output.split(''); + + output.splice(-1, 0, space + locales[options.currentLocale].currency.symbol); + + output = output.join(''); + } else { + output = output + space + locales[options.currentLocale].currency.symbol; + } + } + + return output; + } + + function formatPercentage(value, format, roundingFunction) { + var space = format.includes(' %') ? ' ' : '', + output; + + value = value * 100; + + // check for space before % + format = format.replace(/\s?\%/, ''); + + output = formatNumber(value, format, roundingFunction); + + if (output.includes(')')) { + output = output.split(''); + + output.splice(-1, 0, space + '%'); + + output = output.join(''); + } else { + output = output + space + '%'; + } + + return output; + } + + function formatBytes(value, format, roundingFunction) { + var output, + bytes = format.includes('ib') ? config.bytes.binary : config.bytes.decimal, + suffix = format.includes(' b') || format.includes(' 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 = formatNumber(value, format, roundingFunction); + + return output + suffix; + } + + function formatOrdinal(value, format, roundingFunction) { + var output, + ordinal = format.includes(' o') ? ' ' : ''; + + // check for space before + format = format.replace(/\s?o/, ''); + + ordinal += locales[options.currentLocale].ordinal(value); + + output = formatNumber(value, format, roundingFunction); + + return output + ordinal; + } + + function formatExponential(value, format, roundingFunction) { + var output, + exponential = typeof value === 'number' && !Number.isNaN(value) ? value.toExponential() : '0e+0', + parts = exponential.split('e'); + + format = format.replace(/e[\+|\-]{1}0/, ''); + + output = formatNumber(Number(parts[0]), format, roundingFunction); + + return output + 'e' + parts[1]; + } + + function formatTime(value) { + 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); + } + + function formatNumber(value, format, roundingFunction) { + var negP = false, + signed = false, + optDec = false, + abbr = '', + trillion = 1000000000000, + billion = 1000000000, + million = 1000000, + thousand = 1000, + abbrForce, // force abbreviation + abs, + min, + max, + power, + int, + precision, + thousands, + decimal = '', + neg = false; + + // 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 (format.includes('(')) { + negP = true; + format = format.slice(1, -1); + } else if (format.includes('+')) { + signed = true; + format = format.replace(/\+/g, ''); + } + + // see if abbreviation is wanted + if (format.includes('a')) { + abbrForce = format.match(/a(k|m|b|t)?/); + + abbrForce = abbrForce ? abbrForce[1] : false; + + // check for space before abbreviation + if (format.includes(' a')) { + abbr = ' '; + } + + format = format.replace(new RegExp(abbr + 'a[kmbt]?'), ''); + + if (abs >= trillion && !abbrForce || abbrForce === 't') { + // trillion + abbr += locales[options.currentLocale].abbreviations.trillion; + value = value / trillion; + } else if (abs < trillion && abs >= billion && !abbrForce || abbrForce === 'b') { + // billion + abbr += locales[options.currentLocale].abbreviations.billion; + value = value / billion; + } else if (abs < billion && abs >= million && !abbrForce || abbrForce === 'm') { + // million + abbr += locales[options.currentLocale].abbreviations.million; + value = value / million; + } else if (abs < million && abs >= thousand && !abbrForce || abbrForce === 'k') { + // thousand + abbr += locales[options.currentLocale].abbreviations.thousand; + value = value / thousand; + } + } + + + if (format.includes('[.]')) { + optDec = true; + format = format.replace('[.]', '.'); + } + + int = value.toString().split('.')[0]; + precision = format.split('.')[1]; + thousands = format.indexOf(','); + + if (precision) { + if (precision.includes('[')) { + precision = precision.replace(']', ''); + precision = precision.split('['); + decimal = toFixed(value, (precision[0].length + precision[1].length), roundingFunction, precision[1].length); + } else { + decimal = toFixed(value, precision.length, roundingFunction); + } + + int = decimal.split('.')[0]; + + if (decimal.includes('.')) { + decimal = locales[options.currentLocale].delimiters.decimal + decimal.split('.')[1]; + } else { + decimal = ''; + } + + if (optDec && Number(decimal.slice(1)) === 0) { + decimal = ''; + } + } else { + int = toFixed(value, null, roundingFunction); + } + + // format number + if (int.includes('-')) { + int = int.slice(1); + neg = true; + } + + if (thousands > -1) { + int = int.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + locales[options.currentLocale].delimiters.thousands); + } + + if (format.indexOf('.') === 0) { + int = ''; + } + + return (negP && neg ? '(' : '') + (!negP && neg ? '-' : '') + (!neg && signed ? '+' : '') + int + decimal + (abbr ? abbr : '') + (negP && neg ? ')' : ''); + } + + + /************************************ + Unformatting + ************************************/ + + // revert to number + function unformatNumeral(n, string) { + var stringOriginal = string, + thousandRegExp, + millionRegExp, + billionRegExp, + trillionRegExp, + bytesMultiplier = false, + power, + value; + + if (string.includes(':')) { + value = unformatTime(string); + } else if (string.includes('e+') || string.includes('e-')) { + value = unformatExponential(string); + } else { + if (string === options.zeroFormat || string === options.nullFormat) { + value = 0; + } else { + if (locales[options.currentLocale].delimiters.decimal !== '.') { + string = string.replace(/\./g, '').replace(locales[options.currentLocale].delimiters.decimal, '.'); + } + + // see if abbreviations are there so that we can multiply to the correct number + thousandRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.thousand + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); + millionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.million + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); + billionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.billion + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); + trillionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.trillion + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); + + // see if bytes are there so that we can multiply to the correct number + for (power = 1; power <= config.bytes.decimal.suffixes.length; power++) { + bytesMultiplier = ((string.includes(config.bytes.decimal.suffixes[power])) || (string.includes(config.bytes.binary.suffixes[power])))? Math.pow(1024, power) : false; + + if (bytesMultiplier) { + break; + } + } + + // do some math to create our number + value = bytesMultiplier ? bytesMultiplier : 1; + value *= stringOriginal.match(thousandRegExp) ? Math.pow(10, 3) : 1; + value *= stringOriginal.match(millionRegExp) ? Math.pow(10, 6) : 1; + value *= stringOriginal.match(billionRegExp) ? Math.pow(10, 9) : 1; + value *= stringOriginal.match(trillionRegExp) ? Math.pow(10, 12) : 1; + // check for percentage + value *= string.includes('%') ? 0.01 : 1; + // check for negative number + value *= (string.split('-').length + Math.min(string.split('(').length - 1, string.split(')').length - 1)) % 2 ? 1 : -1; + // remove non numbers + value *= Number(string.replace(/[^0-9\.]+/g, '')); + // round if we are talking about bytes + value = bytesMultiplier ? Math.ceil(value) : value; + } + } + + n._value = value; + + return n._value; + } + + 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); + } + + function unformatExponential(string) { + var parts = string.includes('e+') ? string.split('e+') : string.split('e-'), + value = Number(parts[0]), + power = Number(parts[1]); + + power = string.includes('e-') ? power *= -1 : power; + + function cback(accum, curr, currI, O) { + var corrFactor = correctionFactor(accum, curr), + num = (accum * corrFactor) * (curr * corrFactor) / (corrFactor * corrFactor); + return num; + } + + return [value, Math.pow(10, power)].reduce(cback, 1); + } + + /************************************ + Top Level Functions + ************************************/ + + numeral = function(input) { + if (numeral.isNumeral(input)) { + input = input.value(); + } else if (input === 0 || typeof input === 'undefined') { + input = 0; + } else if (input === null || Number.isNaN(input)) { + input = null; + } else if (!Number(input)) { + input = numeral.fn.unformat(input); + } else { + input = Number(input); + } + + return new Numeral(input); + }; + + // version number + numeral.version = VERSION; + + // compare numeral object + numeral.isNumeral = function(obj) { + return obj instanceof Numeral; + }; + + + // This function will load locales and then set the global locale. If + // no arguments are passed in, it will simply return the current global + // locale key. + numeral.locale = function(key, values) { + if (!key) { + return options.currentLocale; + } + + // standardize to lowercase + key = key.toLowerCase(); + + if (key && !values) { + if (!locales[key]) { + throw new Error('Unknown locale : ' + key); + } + + options.currentLocale = key; + } + + if (values || !locales[key]) { + loadLocale(key, values); + } + + return numeral; + }; + + // 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.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: '$' + } + }); + + 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.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; + }; + + /************************************ + Helpers + ************************************/ + + function loadLocale(key, values) { + locales[key] = values; + } + + // isNaN polyfill + Number.isNaN = Number.isNaN || function(value) { + return typeof value === 'number' && isNaN(value); + }; + + // String includes polyfill + String.prototype.includes = String.prototype.includes || function(search, start) { + return this.indexOf(search, start) !== -1; + }; + + // Production steps of ECMA-262, Edition 5, 15.4.4.21 + // Reference: http://es5.github.io/#x15.4.4.21 + if (!Array.prototype.reduce) { + Array.prototype.reduce = function(callback /*, initialValue*/) { + 'use strict'; + 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(this), len = t.length >>> 0, k = 0, value; + + if (arguments.length === 2) { + value = arguments[1]; + } 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. + */ + function multiplier(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. + */ + function correctionFactor() { + var args = Array.prototype.slice.call(arguments); + + return args.reduce(function(accum, next) { + var mn = multiplier(next); + return accum > mn ? accum : mn; + }, 1); + } + + + /************************************ + Numeral Prototype + ************************************/ + + + numeral.fn = Numeral.prototype = { + clone: function() { + return numeral(this); + }, + format: function (inputString, roundingFunction) { + return formatNumeral(this, + inputString ? inputString : options.defaultFormat, + roundingFunction !== undefined ? roundingFunction : Math.round + ); + }, + unformat: function (inputString) { + if (Object.prototype.toString.call(inputString) === '[object Number]') { + return inputString; + } + + return unformatNumeral(this, inputString ? inputString : options.defaultFormat); + }, + value: function() { + return this._value; + }, + valueOf: function() { + return this._value; + }, + 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 = [this._value, value].reduce(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 = [value].reduce(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 = [this._value, value].reduce(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 = [this._value, value].reduce(cback); + + return this; + }, + difference: function(value) { + return Math.abs(numeral(this._value).subtract(value).value()); + } + }; + + /************************************ + Exposing Numeral + ************************************/ + + // CommonJS module is defined + if (typeof module !== 'undefined' && module.exports) { + module.exports = numeral; + } + + /*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; + } + + /*global define:false */ + if (typeof define === 'function' && define.amd) { + define([], function() { + return numeral; + }); + } +}).call(this); diff --git a/src/numeral.js b/src/numeral.js index 00cc7086..b69558b4 100644 --- a/src/numeral.js +++ b/src/numeral.js @@ -13,9 +13,20 @@ ************************************/ var numeral, + _ = {}, VERSION = 'Edge', - // internal storage for locale config files + formats = {}, locales = {}, + // bytes = { + // 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'] + // } + // } defaults = { currentLocale: 'en', zeroFormat: null, @@ -27,18 +38,6 @@ zeroFormat: defaults.zeroFormat, nullFormat: defaults.nullFormat, defaultFormat: defaults.defaultFormat - }, - config = { - bytes: { - 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'] - } - } }; @@ -48,472 +47,391 @@ // Numeral prototype object - function Numeral(number) { + function Numeral(input, number) { + this._input = input; + 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, 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); - - //roundingFunction = (roundingFunction !== undefined ? roundingFunction : Math.round); - // Multiply up by precision, round accurately, then divide and use native toFixed(): - output = (roundingFunction(value * power) / power).toFixed(boundedPrecision); - - if (optionals > maxDecimals - boundedPrecision) { - optionalsRegExp = new RegExp('\\.?0{1,' + (optionals - (maxDecimals - boundedPrecision)) + '}$'); - output = output.replace(optionalsRegExp, ''); - } - - return output; - } /************************************ Formatting ************************************/ - // determine what type of formatting we need to do - function formatNumeral(n, format, roundingFunction) { - var value = n._value, - kind, - output, - formatFunction; - - if (value === 0 && options.zeroFormat !== null) { - output = options.zeroFormat; - } else if (value === null && options.nullFormat !== null) { - output = options.nullFormat; - } else { - kind = format.match(/(\$|%|:|[ai]?b|o|e\+|e-)/); - - switch (kind ? kind[0] : '') { - case '$': - formatFunction = formatCurrency; - break; - case '%': - formatFunction = formatPercentage; - break; - case ':': - formatFunction = formatTime; - break; - case 'b': - case 'ib': - formatFunction = formatBytes; - break; - case 'o': - formatFunction = formatOrdinal; - break; - case 'e+': - case 'e-': - formatFunction = formatExponential; - break; - default: - formatFunction = formatNumber; - } - - output = formatFunction(value, format, roundingFunction); - } - - return output; - } - - function formatCurrency(value, format, roundingFunction) { - var symbolIndex = format.indexOf('$'), - openParenIndex = format.indexOf('('), - minusSignIndex = format.indexOf('-'), - space = format.includes(' $') || format.includes('$ ') ? ' ' : '', - spliceIndex, - output; - - // strip format of spaces and $ - format = format.replace(/\s?\$\s?/, ''); + // formats.currency = { + // regexp: /(\$)/, + // format: function(value, format, roundingFunction) { + // var symbolIndex = format.indexOf('$'), + // openParenIndex = format.indexOf('('), + // minusSignIndex = format.indexOf('-'), + // space = _.includes(format, ' $') || _.includes(format, '$ ') ? ' ' : '', + // spliceIndex, + // output; + // + // // strip format of spaces and $ + // format = format.replace(/\s?\$\s?/, ''); + // + // // format the number + // output = formats.number(value, format, roundingFunction); + // + // // position the symbol + // if (symbolIndex <= 1) { + // if (_.includes(output, '(') || _.includes(output, '-')) { + // output = output.split(''); + // + // spliceIndex = symbolIndex < openParenIndex || symbolIndex < minusSignIndex ? 0 : 1; + // + // output.splice(spliceIndex, 0, locales[options.currentLocale].currency.symbol + space); + // + // output = output.join(''); + // } else { + // output = locales[options.currentLocale].currency.symbol + space + output; + // } + // } else { + // if (_.includes(output, ')')) { + // output = output.split(''); + // + // output.splice(-1, 0, space + locales[options.currentLocale].currency.symbol); + // + // output = output.join(''); + // } else { + // output = output + space + locales[options.currentLocale].currency.symbol; + // } + // } + // + // return output; + // } + // }; + + + // function formatPercentage(value, format, roundingFunction) { + // var space = _.includes(format, ' %') ? ' ' : '', + // output; + // + // value = value * 100; + // + // // check for space before % + // format = format.replace(/\s?\%/, ''); + // + // output = formatNumber(value, format, roundingFunction); + // + // if (_.includes(output, ')')) { + // output = output.split(''); + // + // output.splice(-1, 0, space + '%'); + // + // output = output.join(''); + // } else { + // output = output + space + '%'; + // } + // + // return output; + // } + // + // function formatBytes(value, format, roundingFunction) { + // var output, + // bytes = _.includes(format, 'ib') ? config.bytes.binary : config.bytes.decimal, + // suffix = _.includes(format, ' b') || _.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 = formatNumber(value, format, roundingFunction); + // + // return output + suffix; + // } + // + // function formatOrdinal(value, format, roundingFunction) { + // var output, + // ordinal = _.includes(format, ' o') ? ' ' : ''; + // + // // check for space before + // format = format.replace(/\s?o/, ''); + // + // ordinal += locales[options.currentLocale].ordinal(value); + // + // output = formatNumber(value, format, roundingFunction); + // + // return output + ordinal; + // } + // + // function formatExponential(value, format, roundingFunction) { + // var output, + // exponential = typeof value === 'number' && !_.isNaN(value) ? value.toExponential() : '0e+0', + // parts = exponential.split('e'); + // + // format = format.replace(/e[\+|\-]{1}0/, ''); + // + // output = formatNumber(Number(parts[0]), format, roundingFunction); + // + // return output + 'e' + parts[1]; + // } + // + // function formatTime(value) { + // 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); + // } - // format the number - output = formatNumber(value, format, roundingFunction); - // position the symbol - if (symbolIndex <= 1) { - if (output.includes('(') || output.includes('-')) { - output = output.split(''); - spliceIndex = symbolIndex < openParenIndex || symbolIndex < minusSignIndex ? 0 : 1; - - output.splice(spliceIndex, 0, locales[options.currentLocale].currency.symbol + space); - - output = output.join(''); - } else { - output = locales[options.currentLocale].currency.symbol + space + output; - } - } else { - if (output.includes(')')) { - output = output.split(''); - - output.splice(-1, 0, space + locales[options.currentLocale].currency.symbol); - - output = output.join(''); - } else { - output = output + space + locales[options.currentLocale].currency.symbol; - } - } - - return output; - } - - function formatPercentage(value, format, roundingFunction) { - var space = format.includes(' %') ? ' ' : '', - output; - - value = value * 100; - - // check for space before % - format = format.replace(/\s?\%/, ''); + /************************************ + Unformatting + ************************************/ - output = formatNumber(value, format, roundingFunction); + // // revert to number + // function unformatNumeral(n, string) { + // var stringOriginal = string, + // thousandRegExp, + // millionRegExp, + // billionRegExp, + // trillionRegExp, + // bytesMultiplier = false, + // power, + // value; + // + // if (_.includes(string, ':')) { + // value = unformatTime(string); + // } else if (_.includes(string, 'e+') || _.includes(string, 'e-')) { + // value = unformatExponential(string); + // } else { + // if (string === options.zeroFormat || string === options.nullFormat) { + // value = 0; + // } else { + // if (locales[options.currentLocale].delimiters.decimal !== '.') { + // string = string.replace(/\./g, '').replace(locales[options.currentLocale].delimiters.decimal, '.'); + // } + // + // // see if abbreviations are there so that we can multiply to the correct number + // thousandRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.thousand + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); + // millionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.million + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); + // billionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.billion + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); + // trillionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.trillion + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); + // + // // see if bytes are there so that we can multiply to the correct number + // for (power = 1; power <= config.bytes.decimal.suffixes.length; power++) { + // bytesMultiplier = ((_.includes(string, config.bytes.decimal.suffixes[power])) || (_.includes(string, config.bytes.binary.suffixes[power])))? Math.pow(1024, power) : false; + // + // if (bytesMultiplier) { + // break; + // } + // } + // + // // do some math to create our number + // value = bytesMultiplier ? bytesMultiplier : 1; + // value *= stringOriginal.match(thousandRegExp) ? Math.pow(10, 3) : 1; + // value *= stringOriginal.match(millionRegExp) ? Math.pow(10, 6) : 1; + // value *= stringOriginal.match(billionRegExp) ? Math.pow(10, 9) : 1; + // value *= stringOriginal.match(trillionRegExp) ? Math.pow(10, 12) : 1; + // // check for percentage + // value *= _.includes(string, '%') ? 0.01 : 1; + // // check for negative number + // value *= (string.split('-').length + Math.min(string.split('(').length - 1, string.split(')').length - 1)) % 2 ? 1 : -1; + // // remove non numbers + // value *= Number(string.replace(/[^0-9\.]+/g, '')); + // // round if we are talking about bytes + // value = bytesMultiplier ? Math.ceil(value) : value; + // } + // } + // + // n._value = value; + // + // return n._value; + // } + // + // 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); + // } + // + // function unformatExponential(string) { + // var parts = _.includes(string, 'e+') ? string.split('e+') : string.split('e-'), + // value = Number(parts[0]), + // power = Number(parts[1]); + // + // power = _.includes(string, 'e-') ? power *= -1 : power; + // + // function cback(accum, curr, currI, O) { + // var corrFactor = _.correctionFactor(accum, curr), + // num = (accum * corrFactor) * (curr * corrFactor) / (corrFactor * corrFactor); + // return num; + // } + // + // return [value, Math.pow(10, power)].reduce(cback, 1); + // } - if (output.includes(')')) { - output = output.split(''); + /************************************ + Top Level Functions + ************************************/ - output.splice(-1, 0, space + '%'); + numeral = function(input) { + var value; - output = output.join(''); + 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 { - output = output + space + '%'; + value = Number(input)|| null; } - return output; - } - - function formatBytes(value, format, roundingFunction) { - var output, - bytes = format.includes('ib') ? config.bytes.binary : config.bytes.decimal, - suffix = format.includes(' b') || format.includes(' 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 = formatNumber(value, format, roundingFunction); - - return output + suffix; - } - - function formatOrdinal(value, format, roundingFunction) { - var output, - ordinal = format.includes(' o') ? ' ' : ''; - - // check for space before - format = format.replace(/\s?o/, ''); - - ordinal += locales[options.currentLocale].ordinal(value); - - output = formatNumber(value, format, roundingFunction); - - return output + ordinal; - } - - function formatExponential(value, format, roundingFunction) { - var output, - exponential = typeof value === 'number' && !Number.isNaN(value) ? value.toExponential() : '0e+0', - parts = exponential.split('e'); - - format = format.replace(/e[\+|\-]{1}0/, ''); - - output = formatNumber(Number(parts[0]), format, roundingFunction); - - return output + 'e' + parts[1]; - } - - function formatTime(value) { - 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); - } - - function formatNumber(value, format, roundingFunction) { - var negP = false, - signed = false, - optDec = false, - abbr = '', - trillion = 1000000000000, - billion = 1000000000, - million = 1000000, - thousand = 1000, - abbrForce, // force abbreviation - abs, - min, - max, - power, - int, - precision, - thousands, - decimal = '', - neg = false; - - // 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 (format.includes('(')) { - negP = true; - format = format.slice(1, -1); - } else if (format.includes('+')) { - signed = true; - format = format.replace(/\+/g, ''); - } + return new Numeral(input, value); + }; - // see if abbreviation is wanted - if (format.includes('a')) { - abbrForce = format.match(/a(k|m|b|t)?/); + // version number + numeral.version = VERSION; - abbrForce = abbrForce ? abbrForce[1] : false; + // compare numeral object + numeral.isNumeral = function(obj) { + return obj instanceof Numeral; + }; - // check for space before abbreviation - if (format.includes(' a')) { - abbr = ' '; + // helper functions + numeral._ = _ = { + loadLocale: function (key, values) { + locales[key] = values; + }, + isNaN: function(value) { + return typeof value === 'number' && isNaN(value); + }, + includes: function(string, search) { + return string.indexOf(search) !== -1; + }, + reduce: function (array, callback) { + if (this === null) { + throw new TypeError('Array.prototype.reduce called on null or undefined'); } - format = format.replace(new RegExp(abbr + 'a[kmbt]?'), ''); - - if (abs >= trillion && !abbrForce || abbrForce === 't') { - // trillion - abbr += locales[options.currentLocale].abbreviations.trillion; - value = value / trillion; - } else if (abs < trillion && abs >= billion && !abbrForce || abbrForce === 'b') { - // billion - abbr += locales[options.currentLocale].abbreviations.billion; - value = value / billion; - } else if (abs < billion && abs >= million && !abbrForce || abbrForce === 'm') { - // million - abbr += locales[options.currentLocale].abbreviations.million; - value = value / million; - } else if (abs < million && abs >= thousand && !abbrForce || abbrForce === 'k') { - // thousand - abbr += locales[options.currentLocale].abbreviations.thousand; - value = value / thousand; + if (typeof callback !== 'function') { + throw new TypeError(callback + ' is not a function'); } - } - - if (format.includes('[.]')) { - optDec = true; - format = format.replace('[.]', '.'); - } - - int = value.toString().split('.')[0]; - precision = format.split('.')[1]; - thousands = format.indexOf(','); + var t = Object(this), len = t.length >>> 0, k = 0, value; - if (precision) { - if (precision.includes('[')) { - precision = precision.replace(']', ''); - precision = precision.split('['); - decimal = toFixed(value, (precision[0].length + precision[1].length), roundingFunction, precision[1].length); + if (arguments.length === 2) { + value = arguments[1]; } else { - decimal = toFixed(value, precision.length, roundingFunction); - } + while (k < len && !(k in t)) { + k++; + } - int = decimal.split('.')[0]; + if (k >= len) { + throw new TypeError('Reduce of empty array with no initial value'); + } - if (decimal.includes('.')) { - decimal = locales[options.currentLocale].delimiters.decimal + decimal.split('.')[1]; - } else { - decimal = ''; + value = t[k++]; } - - if (optDec && Number(decimal.slice(1)) === 0) { - decimal = ''; + for (; k < len; k++) { + if (k in t) { + value = callback(value, t[k], k, t); + } } - } else { - int = toFixed(value, null, roundingFunction); - } - - // format number - if (int.includes('-')) { - int = int.slice(1); - neg = true; - } - - if (thousands > -1) { - int = int.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + locales[options.currentLocale].delimiters.thousands); - } - - if (format.indexOf('.') === 0) { - int = ''; - } - - return (negP && neg ? '(' : '') + (!negP && neg ? '-' : '') + (!neg && signed ? '+' : '') + int + decimal + (abbr ? abbr : '') + (negP && neg ? ')' : ''); - } - - - /************************************ - Unformatting - ************************************/ - - // revert to number - function unformatNumeral(n, string) { - var stringOriginal = string, - thousandRegExp, - millionRegExp, - billionRegExp, - trillionRegExp, - bytesMultiplier = false, - power, - value; - - if (string.includes(':')) { - value = unformatTime(string); - } else if (string.includes('e+') || string.includes('e-')) { - value = unformatExponential(string); - } else { - if (string === options.zeroFormat || string === options.nullFormat) { - value = 0; + 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 { - if (locales[options.currentLocale].delimiters.decimal !== '.') { - string = string.replace(/\./g, '').replace(locales[options.currentLocale].delimiters.decimal, '.'); - } - - // see if abbreviations are there so that we can multiply to the correct number - thousandRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.thousand + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); - millionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.million + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); - billionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.billion + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); - trillionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.trillion + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); - - // see if bytes are there so that we can multiply to the correct number - for (power = 1; power <= config.bytes.decimal.suffixes.length; power++) { - bytesMultiplier = ((string.includes(config.bytes.decimal.suffixes[power])) || (string.includes(config.bytes.binary.suffixes[power])))? Math.pow(1024, power) : false; - - if (bytesMultiplier) { - break; - } - } - - // do some math to create our number - value = bytesMultiplier ? bytesMultiplier : 1; - value *= stringOriginal.match(thousandRegExp) ? Math.pow(10, 3) : 1; - value *= stringOriginal.match(millionRegExp) ? Math.pow(10, 6) : 1; - value *= stringOriginal.match(billionRegExp) ? Math.pow(10, 9) : 1; - value *= stringOriginal.match(trillionRegExp) ? Math.pow(10, 12) : 1; - // check for percentage - value *= string.includes('%') ? 0.01 : 1; - // check for negative number - value *= (string.split('-').length + Math.min(string.split('(').length - 1, string.split(')').length - 1)) % 2 ? 1 : -1; - // remove non numbers - value *= Number(string.replace(/[^0-9\.]+/g, '')); - // round if we are talking about bytes - value = bytesMultiplier ? Math.ceil(value) : value; + boundedPrecision = minDecimals; } - } - - n._value = value; - - return n._value; - } - - 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); - } - function unformatExponential(string) { - var parts = string.includes('e+') ? string.split('e+') : string.split('e-'), - value = Number(parts[0]), - power = Number(parts[1]); + power = Math.pow(10, boundedPrecision); - power = string.includes('e-') ? power *= -1 : power; + //roundingFunction = (roundingFunction !== undefined ? roundingFunction : Math.round); + // Multiply up by precision, round accurately, then divide and use native toFixed(): + output = (roundingFunction(value * power) / power).toFixed(boundedPrecision); - function cback(accum, curr, currI, O) { - var corrFactor = correctionFactor(accum, curr), - num = (accum * corrFactor) * (curr * corrFactor) / (corrFactor * corrFactor); - return num; - } - - return [value, Math.pow(10, power)].reduce(cback, 1); - } - - /************************************ - Top Level Functions - ************************************/ + if (optionals > maxDecimals - boundedPrecision) { + optionalsRegExp = new RegExp('\\.?0{1,' + (optionals - (maxDecimals - boundedPrecision)) + '}$'); + output = output.replace(optionalsRegExp, ''); + } - numeral = function(input) { - if (numeral.isNumeral(input)) { - input = input.value(); - } else if (input === 0 || typeof input === 'undefined') { - input = 0; - } else if (input === null || Number.isNaN(input)) { - input = null; - } else if (!Number(input)) { - input = numeral.fn.unformat(input); - } else { - input = Number(input); + return output; } - - return new Numeral(input); }; - // version number - numeral.version = VERSION; + // avaliable options + numeral.options = options; - // compare numeral object - numeral.isNumeral = function(obj) { - return obj instanceof Numeral; - }; + // avaliable formats + numeral.formats = formats; + // avaliable formats + numeral.locales = locales; // This function will load locales and then set the global locale. If // no arguments are passed in, it will simply return the current global @@ -535,7 +453,7 @@ } if (values || !locales[key]) { - loadLocale(key, values); + _.loadLocale(key, values); } return numeral; @@ -558,29 +476,6 @@ return locales[key]; }; - numeral.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: '$' - } - }); - numeral.reset = function() { for (var property in defaults) { options[property] = defaults[property]; @@ -599,256 +494,94 @@ options.defaultFormat = typeof(format) === 'string' ? format : '0.0'; }; - 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; + numeral.register = function(type, name, format) { + if (this[type + 's'][name]) { + throw new TypeError(name + ' ' + type + ' already registered.'); } - //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; - }; - - /************************************ - Helpers - ************************************/ - - function loadLocale(key, values) { - locales[key] = values; - } - - // isNaN polyfill - Number.isNaN = Number.isNaN || function(value) { - return typeof value === 'number' && isNaN(value); + this[type + 's'][name] = format; }; - // String includes polyfill - String.prototype.includes = String.prototype.includes || function(search, start) { - return this.indexOf(search, start) !== -1; - }; - - // Production steps of ECMA-262, Edition 5, 15.4.4.21 - // Reference: http://es5.github.io/#x15.4.4.21 - if (!Array.prototype.reduce) { - Array.prototype.reduce = function(callback /*, initialValue*/) { - 'use strict'; - 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(this), len = t.length >>> 0, k = 0, value; - - if (arguments.length === 2) { - value = arguments[1]; - } 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. - */ - function multiplier(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. - */ - function correctionFactor() { - var args = Array.prototype.slice.call(arguments); - - return args.reduce(function(accum, next) { - var mn = multiplier(next); - return accum > mn ? accum : mn; - }, 1); - } /************************************ Numeral Prototype ************************************/ - numeral.fn = Numeral.prototype = { clone: function() { return numeral(this); }, - format: function (inputString, roundingFunction) { - return formatNumeral(this, - inputString ? inputString : options.defaultFormat, - roundingFunction !== undefined ? roundingFunction : Math.round - ); - }, - unformat: function (inputString) { - if (Object.prototype.toString.call(inputString) === '[object Number]') { - return inputString; + 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 (kind.regexp && format.match(kind.regexp)) { + formatFunction = kind.format; + + break; + } + } + + formatFunction = formatFunction || formats.number.format; + + output = formatFunction(value, format, roundingFunction); } - return unformatNumeral(this, inputString ? inputString : options.defaultFormat); + return output; }, value: function() { return this._value; }, - valueOf: function() { - return this._value; - }, 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 = [this._value, value].reduce(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 = [value].reduce(cback, Math.round(this._value * corrFactor)) / corrFactor; + /************************************ + Default Locale + ************************************/ - return this; + numeral.locale('en', { + delimiters: { + thousands: ',', + decimal: '.' }, - 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 = [this._value, value].reduce(cback, 1); - - return this; + abbreviations: { + thousand: 'k', + million: 'm', + billion: 'b', + trillion: 't' }, - 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 = [this._value, value].reduce(cback); - - return this; + ordinal: function(number) { + var b = number % 10; + return (~~(number % 100 / 10) === 1) ? 'th' : + (b === 1) ? 'st' : + (b === 2) ? 'nd' : + (b === 3) ? 'rd' : 'th'; }, - difference: function(value) { - return Math.abs(numeral(this._value).subtract(value).value()); + currency: { + symbol: '$' } - }; + }); + /************************************ Exposing Numeral diff --git a/tests/formats/number.js b/tests/formats/number.js new file mode 100644 index 00000000..70ea52c6 --- /dev/null +++ b/tests/formats/number.js @@ -0,0 +1,75 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../src/numeral'); + var format = require('../../src/formats/number'); + var expect = require('chai').expect; +} + +console.log(format); + +describe('Format', function() { + after(function() { + numeral.reset(); + }); + + describe('Numbers', 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'], + [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'], + [3162.63,'0.0[00000000000000]','3162.63'], + [1.99,'0.[0]','2'], + [1.0501,'0.00[0]','1.05'], + // abbreviations + [2000000000,'0.0a','2.0b'], + [1230974,'0.0a','1.2m'], + [1460,'0a','1k'], + [-104000,'0 a','-104 k'], + // 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'); + } + }); + }); +}); diff --git a/tests/numeral/format.js b/tests/numeral/format.js index cb378f61..836eb503 100644 --- a/tests/numeral/format.js +++ b/tests/numeral/format.js @@ -102,44 +102,44 @@ describe('Format', function() { // }); // }); - describe('Currency', function() { - 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)','($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; - - for (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 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)','($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; + // + // for (i = 0; i < tests.length; i++) { + // expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + // } + // }); + // }); // // describe('Bytes', function() { // it('should format to bytes', function() { From a969dc1eee1221c8e8520fe7c6e75e6eb0417a6a Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 1 Dec 2016 13:59:29 -0800 Subject: [PATCH 092/150] manipulations back in core --- Gruntfile.js | 2 +- src/numeral.js | 182 +++++++++++++++++++++++- tests/formats/number.js | 75 ---------- tests/numeral.js | 306 ++++++++++++++++++++++++++++++++++++++++ tests/numeral/misc.js | 126 ----------------- 5 files changed, 483 insertions(+), 208 deletions(-) delete mode 100644 tests/formats/number.js create mode 100644 tests/numeral.js diff --git a/Gruntfile.js b/Gruntfile.js index 235055f0..4aaf51f5 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -26,7 +26,7 @@ module.exports = function(grunt) { grunt.initConfig({ mochaTest : { all: [ - 'tests/formats/number.js' + 'tests/numeral.js' // 'tests/locales/*.js' ] }, diff --git a/src/numeral.js b/src/numeral.js index b69558b4..971257f4 100644 --- a/src/numeral.js +++ b/src/numeral.js @@ -334,7 +334,7 @@ includes: function(string, search) { return string.indexOf(search) !== -1; }, - reduce: function (array, callback) { + reduce: function(array, callback /*, initialValue*/) { if (this === null) { throw new TypeError('Array.prototype.reduce called on null or undefined'); } @@ -343,10 +343,13 @@ throw new TypeError(callback + ' is not a function'); } - var t = Object(this), len = t.length >>> 0, k = 0, value; + var t = Object(array), + len = t.length >>> 0, + k = 0, + value; - if (arguments.length === 2) { - value = arguments[1]; + if (arguments.length === 3) { + value = arguments[2]; } else { while (k < len && !(k in t)) { k++; @@ -550,16 +553,61 @@ 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 + Default Locale && Format ************************************/ - numeral.locale('en', { + numeral.register('locale', 'en', { delimiters: { thousands: ',', decimal: '.' @@ -582,6 +630,128 @@ } }); + numeral.register('format', 'number', { + regexp: null, + format: function(value, format, roundingFunction) { + var locale = numeral.locales[numeral.options.currentLocale], + negP = false, + signed = false, + optDec = false, + abbr = '', + trillion = 1000000000000, + billion = 1000000000, + million = 1000000, + thousand = 1000, + abbrForce, // force abbreviation + abs, + min, + max, + power, + int, + precision, + thousands, + decimal = '', + neg = false; + + // 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.slice(1, -1); + } else if (numeral._.includes(format, '+')) { + signed = true; + 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; + } + } + + + if (numeral._.includes(format, '[.]')) { + optDec = true; + format = format.replace('[.]', '.'); + } + + int = value.toString().split('.')[0]; + precision = format.split('.')[1]; + thousands = format.indexOf(','); + + 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, null, roundingFunction); + } + + // format number + if (numeral._.includes(int, '-')) { + int = int.slice(1); + neg = true; + } + + if (thousands > -1) { + int = int.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + locale.delimiters.thousands); + } + + if (format.indexOf('.') === 0) { + int = ''; + } + + return (negP && neg ? '(' : '') + (!negP && neg ? '-' : '') + (!neg && signed ? '+' : '') + int + decimal + (abbr ? abbr : '') + (negP && neg ? ')' : ''); + } + }); + /************************************ Exposing Numeral diff --git a/tests/formats/number.js b/tests/formats/number.js deleted file mode 100644 index 70ea52c6..00000000 --- a/tests/formats/number.js +++ /dev/null @@ -1,75 +0,0 @@ -// Node -if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../src/numeral'); - var format = require('../../src/formats/number'); - var expect = require('chai').expect; -} - -console.log(format); - -describe('Format', function() { - after(function() { - numeral.reset(); - }); - - describe('Numbers', 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'], - [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'], - [3162.63,'0.0[00000000000000]','3162.63'], - [1.99,'0.[0]','2'], - [1.0501,'0.00[0]','1.05'], - // abbreviations - [2000000000,'0.0a','2.0b'], - [1230974,'0.0a','1.2m'], - [1460,'0a','1k'], - [-104000,'0 a','-104 k'], - // 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'); - } - }); - }); -}); diff --git a/tests/numeral.js b/tests/numeral.js new file mode 100644 index 00000000..431341c3 --- /dev/null +++ b/tests/numeral.js @@ -0,0 +1,306 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../src/numeral'); + var expect = require('chai').expect; +} + +describe('Numeral', function() { + afterEach(function() { + numeral.reset(); + }); + + 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', null], + ['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'], + [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'], + [3162.63,'0.0[00000000000000]','3162.63'], + [1.99,'0.[0]','2'], + [1.0501,'0.00[0]','1.05'], + // abbreviations + [2000000000,'0.0a','2.0b'], + [1230974,'0.0a','1.2m'], + [1460,'0a','1k'], + [-104000,'0 a','-104 k'], + // 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('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]); + } + }); + }); + }); +}); diff --git a/tests/numeral/misc.js b/tests/numeral/misc.js index fba3f2db..5bc4d622 100644 --- a/tests/numeral/misc.js +++ b/tests/numeral/misc.js @@ -9,132 +9,6 @@ describe('Misc', function() { numeral.reset(); }); - 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', 0] - ], - 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,null,'$0.00','$0.00'], - [0,null,'0 b','0 B'], - [0,null,'0:00','0:00:00'], - [0,'N/A','0','N/A'], - [0,'N/A','$0.00','N/A'], - [0,'N/A','0 b','N/A'], - [0,'N/A','0:00','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,null,'$0.00','$0.00'], - [null,null,'0 b','0 B'], - [null,null,'0:00','0:00:00'], - [null,'N/A','0','N/A'], - [null,'N/A','$0.00','N/A'], - [null,'N/A','0 b','N/A'], - [null,'N/A','0:00','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('Locale Data', function() { it('should use custom locale data', function() { var cOld = '$', From 34a78673d3b1012230db737845c4152dfb5323c4 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 1 Dec 2016 22:43:34 -0800 Subject: [PATCH 093/150] numeral tests passing --- Gruntfile.js | 7 +- src/formats/currency.js | 113 +++++++++++++++--------------- src/formats/number.js | 143 -------------------------------------- tests/formats/currency.js | 52 ++++++++++++++ tests/numeral.js | 30 ++++++++ tests/numeral/format.js | 42 +++++------ 6 files changed, 163 insertions(+), 224 deletions(-) delete mode 100644 src/formats/number.js create mode 100644 tests/formats/currency.js diff --git a/Gruntfile.js b/Gruntfile.js index 4aaf51f5..0ea6670d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -27,16 +27,17 @@ module.exports = function(grunt) { mochaTest : { all: [ 'tests/numeral.js' + // 'tests/formats/*.js' // 'tests/locales/*.js' ] }, karma: { options: { files: [ - 'src/core.js', - 'tests/numeral/format.js' + 'src/numeral.js', + // 'tests/formats/format.js' // 'src/locales/*.js', - // 'tests/numeral/*.js', + 'tests/numeral.js' // 'tests/locales/*.js' ], frameworks: [ diff --git a/src/formats/currency.js b/src/formats/currency.js index f27ecbe6..cc3064fb 100644 --- a/src/formats/currency.js +++ b/src/formats/currency.js @@ -3,65 +3,64 @@ * format : currency * author : Adam Draper : https://github.com/adamwdraper */ +(function () { + var numeral, + format; + // get numeral from environment + if (typeof window !== 'undefined' && this.numeral) { + // Browser + numeral = this.numeral; + } else if (typeof module !== 'undefined' && module.exports) { + // Node + numeral = require('../numeral'); + } + format = { + regexp: /(\$)/, + format: function(value, format, roundingFunction) { + var locale = numeral.locales[numeral.options.currentLocale], + symbolIndex = format.indexOf('$'), + openParenIndex = format.indexOf('('), + minusSignIndex = format.indexOf('-'), + space = numeral._.includes(format, ' $') || numeral._.includes(format, '$ ') ? ' ' : '', + spliceIndex, + output; + // strip format of spaces and $ + format = format.replace(/\s?\$\s?/, ''); -(function () { - // var numeral; - // var currency = { - // regexp: /(\$)/, - // format: function(value, format, roundingFunction) { - // var symbolIndex = format.indexOf('$'), - // openParenIndex = format.indexOf('('), - // minusSignIndex = format.indexOf('-'), - // space = _.includes(format, ' $') || _.includes(format, '$ ') ? ' ' : '', - // spliceIndex, - // output; - // - // // strip format of spaces and $ - // format = format.replace(/\s?\$\s?/, ''); - // - // // format the number - // output = formatNumber(value, format, roundingFunction); - // - // // position the symbol - // if (symbolIndex <= 1) { - // if (_.includes(output, '(') || _.includes(output, '-')) { - // output = output.split(''); - // - // spliceIndex = symbolIndex < openParenIndex || symbolIndex < minusSignIndex ? 0 : 1; - // - // output.splice(spliceIndex, 0, locales[options.currentLocale].currency.symbol + space); - // - // output = output.join(''); - // } else { - // output = locales[options.currentLocale].currency.symbol + space + output; - // } - // } else { - // if (_.includes(output, ')')) { - // output = output.split(''); - // - // output.splice(-1, 0, space + locales[options.currentLocale].currency.symbol); - // - // output = output.join(''); - // } else { - // output = output + space + locales[options.currentLocale].currency.symbol; - // } - // } - // - // return output; - // } - // }; - // - // // get numeral from environment - // if (typeof window !== 'undefined' && this.numeral) { - // // Browser - // numeral = this.numeral; - // } else if (typeof module !== 'undefined' && module.exports) { - // // Node - // numeral = require('../numeral'); - // } - // - // numeral.register('format', 'currency', currency); + // format the number + output = numeral.format(value, format, roundingFunction); + + // position the symbol + if (symbolIndex <= 1) { + if (numeral._.includes(output, '(') || numeral._.includes(output, '-')) { + output = output.split(''); + + spliceIndex = symbolIndex < openParenIndex || symbolIndex < minusSignIndex ? 0 : 1; + + output.splice(spliceIndex, 0, locale.currency.symbol + space); + + output = output.join(''); + } else { + output = locale.currency.symbol + space + output; + } + } else { + if (numeral._.includes(output, ')')) { + output = output.split(''); + + output.splice(-1, 0, space + locale.currency.symbol); + + output = output.join(''); + } else { + output = output + space + locale.currency.symbol; + } + } + + return output; + } + }; + + numeral.register('format', 'currency', format); }()); diff --git a/src/formats/number.js b/src/formats/number.js deleted file mode 100644 index 98b695ff..00000000 --- a/src/formats/number.js +++ /dev/null @@ -1,143 +0,0 @@ -/* - * numeral.js format configuration - * format : currency - * author : Adam Draper : https://github.com/adamwdraper - */ - -(function () { - var numeral, - format; - - // get numeral from environment - if (typeof window !== 'undefined' && this.numeral) { - // Browser - numeral = this.numeral; - } else if (typeof module !== 'undefined' && module.exports) { - // Node - numeral = require('../numeral'); - } - - format = { - regexp: null, - format: function(value, format, roundingFunction) { - var locale = numeral.locales[numeral.options.currentLocale], - negP = false, - signed = false, - optDec = false, - abbr = '', - trillion = 1000000000000, - billion = 1000000000, - million = 1000000, - thousand = 1000, - abbrForce, // force abbreviation - abs, - min, - max, - power, - int, - precision, - thousands, - decimal = '', - neg = false; - - // 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.slice(1, -1); - } else if (numeral._.includes(format, '+')) { - signed = true; - 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; - } - } - - - if (numeral._.includes(format, '[.]')) { - optDec = true; - format = format.replace('[.]', '.'); - } - - int = value.toString().split('.')[0]; - precision = format.split('.')[1]; - thousands = format.indexOf(','); - - 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, null, roundingFunction); - } - - // format number - if (numeral._.includes(int, '-')) { - int = int.slice(1); - neg = true; - } - - if (thousands > -1) { - int = int.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + locale.delimiters.thousands); - } - - if (format.indexOf('.') === 0) { - int = ''; - } - - return (negP && neg ? '(' : '') + (!negP && neg ? '-' : '') + (!neg && signed ? '+' : '') + int + decimal + (abbr ? abbr : '') + (negP && neg ? ')' : ''); - } - }; - - numeral.register('format', 'number', format); -}()); diff --git a/tests/formats/currency.js b/tests/formats/currency.js new file mode 100644 index 00000000..00d9af1b --- /dev/null +++ b/tests/formats/currency.js @@ -0,0 +1,52 @@ + +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../src/numeral'); + var numeral = require('../../src/formats/currency'); + var expect = require('chai').expect; +} + +describe('Format', function() { + after(function() { + numeral.reset(); + }); + + describe('Currency', function() { + 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)','($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; + + for (i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); +}); diff --git a/tests/numeral.js b/tests/numeral.js index 431341c3..463089c9 100644 --- a/tests/numeral.js +++ b/tests/numeral.js @@ -9,6 +9,14 @@ describe('Numeral', 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 = [ @@ -302,5 +310,27 @@ describe('Numeral', function() { } }); }); + + 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]); + } + }); + }); }); }); diff --git a/tests/numeral/format.js b/tests/numeral/format.js index 836eb503..3fff8e3a 100644 --- a/tests/numeral/format.js +++ b/tests/numeral/format.js @@ -225,25 +225,25 @@ describe('Format', function() { // }); // }); // - // 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.974878234,'0.000%','97.487%','97.488%'], - // [-0.433,'0 %','-44 %', '-43 %'] - // ], - // 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('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.974878234,'0.000%','97.487%','97.488%'], + [-0.433,'0 %','-44 %', '-43 %'] + ], + 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]); + } + }); + }); }); From 6d1d0fd5ed9ab1415b6d661e3750b5f12876d29a Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 1 Dec 2016 23:09:12 -0800 Subject: [PATCH 094/150] percentage format --- Gruntfile.js | 9 +- src/formats/currency.js | 11 +- src/formats/percentage.js | 44 ++++ src/numeral.js | 507 +++++++++--------------------------- tests/formats/currency.js | 70 +++-- tests/formats/percentage.js | 29 +++ tests/numeral/format.js | 277 ++++++++++---------- 7 files changed, 369 insertions(+), 578 deletions(-) create mode 100644 src/formats/percentage.js create mode 100644 tests/formats/percentage.js diff --git a/Gruntfile.js b/Gruntfile.js index 0ea6670d..eec2ea13 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -26,8 +26,8 @@ module.exports = function(grunt) { grunt.initConfig({ mochaTest : { all: [ - 'tests/numeral.js' - // 'tests/formats/*.js' + 'tests/numeral.js', + 'tests/formats/*.js' // 'tests/locales/*.js' ] }, @@ -35,9 +35,10 @@ module.exports = function(grunt) { options: { files: [ 'src/numeral.js', - // 'tests/formats/format.js' + 'src/formats/*.js', // 'src/locales/*.js', - 'tests/numeral.js' + 'tests/numeral.js', + 'tests/formats/*.js' // 'tests/locales/*.js' ], frameworks: [ diff --git a/src/formats/currency.js b/src/formats/currency.js index cc3064fb..9944e2c5 100644 --- a/src/formats/currency.js +++ b/src/formats/currency.js @@ -4,8 +4,7 @@ * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var numeral, - format; + var numeral; // get numeral from environment if (typeof window !== 'undefined' && this.numeral) { @@ -16,7 +15,7 @@ numeral = require('../numeral'); } - format = { + numeral.register('format', 'currency', { regexp: /(\$)/, format: function(value, format, roundingFunction) { var locale = numeral.locales[numeral.options.currentLocale], @@ -31,7 +30,7 @@ format = format.replace(/\s?\$\s?/, ''); // format the number - output = numeral.format(value, format, roundingFunction); + output = numeral._.formatNumber(value, format, roundingFunction); // position the symbol if (symbolIndex <= 1) { @@ -60,7 +59,5 @@ return output; } - }; - - numeral.register('format', 'currency', format); + }); }()); diff --git a/src/formats/percentage.js b/src/formats/percentage.js new file mode 100644 index 00000000..6f8a90ae --- /dev/null +++ b/src/formats/percentage.js @@ -0,0 +1,44 @@ +/* + * numeral.js format configuration + * format : currency + * author : Adam Draper : https://github.com/adamwdraper + */ +(function () { + var numeral; + + // get numeral from environment + if (typeof window !== 'undefined' && this.numeral) { + // Browser + numeral = this.numeral; + } else if (typeof module !== 'undefined' && module.exports) { + // Node + numeral = require('../numeral'); + } + + numeral.register('format', 'percentage', { + regexp: /(%)/, + format: function(value, format, roundingFunction) { + var space = numeral._.includes(format, ' %') ? ' ' : '', + output; + + value = value * 100; + + // check for space before % + format = format.replace(/\s?\%/, ''); + + output = numeral._.formatNumber(value, format, roundingFunction); + + if (numeral._.includes(output, ')')) { + output = output.split(''); + + output.splice(-1, 0, space + '%'); + + output = output.join(''); + } else { + output = output + space + '%'; + } + + return output; + } + }); +}()); diff --git a/src/numeral.js b/src/numeral.js index 971257f4..69d3ea61 100644 --- a/src/numeral.js +++ b/src/numeral.js @@ -13,20 +13,10 @@ ************************************/ var numeral, - _ = {}, + _, VERSION = 'Edge', formats = {}, locales = {}, - // bytes = { - // 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'] - // } - // } defaults = { currentLocale: 'en', zeroFormat: null, @@ -45,7 +35,6 @@ Constructors ************************************/ - // Numeral prototype object function Numeral(input, number) { this._input = input; @@ -53,252 +42,6 @@ this._value = number; } - - /************************************ - Formatting - ************************************/ - - // formats.currency = { - // regexp: /(\$)/, - // format: function(value, format, roundingFunction) { - // var symbolIndex = format.indexOf('$'), - // openParenIndex = format.indexOf('('), - // minusSignIndex = format.indexOf('-'), - // space = _.includes(format, ' $') || _.includes(format, '$ ') ? ' ' : '', - // spliceIndex, - // output; - // - // // strip format of spaces and $ - // format = format.replace(/\s?\$\s?/, ''); - // - // // format the number - // output = formats.number(value, format, roundingFunction); - // - // // position the symbol - // if (symbolIndex <= 1) { - // if (_.includes(output, '(') || _.includes(output, '-')) { - // output = output.split(''); - // - // spliceIndex = symbolIndex < openParenIndex || symbolIndex < minusSignIndex ? 0 : 1; - // - // output.splice(spliceIndex, 0, locales[options.currentLocale].currency.symbol + space); - // - // output = output.join(''); - // } else { - // output = locales[options.currentLocale].currency.symbol + space + output; - // } - // } else { - // if (_.includes(output, ')')) { - // output = output.split(''); - // - // output.splice(-1, 0, space + locales[options.currentLocale].currency.symbol); - // - // output = output.join(''); - // } else { - // output = output + space + locales[options.currentLocale].currency.symbol; - // } - // } - // - // return output; - // } - // }; - - - // function formatPercentage(value, format, roundingFunction) { - // var space = _.includes(format, ' %') ? ' ' : '', - // output; - // - // value = value * 100; - // - // // check for space before % - // format = format.replace(/\s?\%/, ''); - // - // output = formatNumber(value, format, roundingFunction); - // - // if (_.includes(output, ')')) { - // output = output.split(''); - // - // output.splice(-1, 0, space + '%'); - // - // output = output.join(''); - // } else { - // output = output + space + '%'; - // } - // - // return output; - // } - // - // function formatBytes(value, format, roundingFunction) { - // var output, - // bytes = _.includes(format, 'ib') ? config.bytes.binary : config.bytes.decimal, - // suffix = _.includes(format, ' b') || _.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 = formatNumber(value, format, roundingFunction); - // - // return output + suffix; - // } - // - // function formatOrdinal(value, format, roundingFunction) { - // var output, - // ordinal = _.includes(format, ' o') ? ' ' : ''; - // - // // check for space before - // format = format.replace(/\s?o/, ''); - // - // ordinal += locales[options.currentLocale].ordinal(value); - // - // output = formatNumber(value, format, roundingFunction); - // - // return output + ordinal; - // } - // - // function formatExponential(value, format, roundingFunction) { - // var output, - // exponential = typeof value === 'number' && !_.isNaN(value) ? value.toExponential() : '0e+0', - // parts = exponential.split('e'); - // - // format = format.replace(/e[\+|\-]{1}0/, ''); - // - // output = formatNumber(Number(parts[0]), format, roundingFunction); - // - // return output + 'e' + parts[1]; - // } - // - // function formatTime(value) { - // 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); - // } - - - - /************************************ - Unformatting - ************************************/ - - // // revert to number - // function unformatNumeral(n, string) { - // var stringOriginal = string, - // thousandRegExp, - // millionRegExp, - // billionRegExp, - // trillionRegExp, - // bytesMultiplier = false, - // power, - // value; - // - // if (_.includes(string, ':')) { - // value = unformatTime(string); - // } else if (_.includes(string, 'e+') || _.includes(string, 'e-')) { - // value = unformatExponential(string); - // } else { - // if (string === options.zeroFormat || string === options.nullFormat) { - // value = 0; - // } else { - // if (locales[options.currentLocale].delimiters.decimal !== '.') { - // string = string.replace(/\./g, '').replace(locales[options.currentLocale].delimiters.decimal, '.'); - // } - // - // // see if abbreviations are there so that we can multiply to the correct number - // thousandRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.thousand + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); - // millionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.million + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); - // billionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.billion + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); - // trillionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.trillion + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); - // - // // see if bytes are there so that we can multiply to the correct number - // for (power = 1; power <= config.bytes.decimal.suffixes.length; power++) { - // bytesMultiplier = ((_.includes(string, config.bytes.decimal.suffixes[power])) || (_.includes(string, config.bytes.binary.suffixes[power])))? Math.pow(1024, power) : false; - // - // if (bytesMultiplier) { - // break; - // } - // } - // - // // do some math to create our number - // value = bytesMultiplier ? bytesMultiplier : 1; - // value *= stringOriginal.match(thousandRegExp) ? Math.pow(10, 3) : 1; - // value *= stringOriginal.match(millionRegExp) ? Math.pow(10, 6) : 1; - // value *= stringOriginal.match(billionRegExp) ? Math.pow(10, 9) : 1; - // value *= stringOriginal.match(trillionRegExp) ? Math.pow(10, 12) : 1; - // // check for percentage - // value *= _.includes(string, '%') ? 0.01 : 1; - // // check for negative number - // value *= (string.split('-').length + Math.min(string.split('(').length - 1, string.split(')').length - 1)) % 2 ? 1 : -1; - // // remove non numbers - // value *= Number(string.replace(/[^0-9\.]+/g, '')); - // // round if we are talking about bytes - // value = bytesMultiplier ? Math.ceil(value) : value; - // } - // } - // - // n._value = value; - // - // return n._value; - // } - // - // 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); - // } - // - // function unformatExponential(string) { - // var parts = _.includes(string, 'e+') ? string.split('e+') : string.split('e-'), - // value = Number(parts[0]), - // power = Number(parts[1]); - // - // power = _.includes(string, 'e-') ? power *= -1 : power; - // - // function cback(accum, curr, currI, O) { - // var corrFactor = _.correctionFactor(accum, curr), - // num = (accum * corrFactor) * (curr * corrFactor) / (corrFactor * corrFactor); - // return num; - // } - // - // return [value, Math.pow(10, power)].reduce(cback, 1); - // } - - /************************************ - Top Level Functions - ************************************/ - numeral = function(input) { var value; @@ -325,6 +68,124 @@ // helper functions numeral._ = _ = { + formatNumber: function(value, format, roundingFunction) { + var locale = numeral.locales[numeral.options.currentLocale], + negP = false, + signed = false, + optDec = false, + abbr = '', + trillion = 1000000000000, + billion = 1000000000, + million = 1000000, + thousand = 1000, + abbrForce, // force abbreviation + abs, + min, + max, + power, + int, + precision, + thousands, + decimal = '', + neg = false; + + // 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.slice(1, -1); + } else if (numeral._.includes(format, '+')) { + signed = true; + 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; + } + } + + + if (numeral._.includes(format, '[.]')) { + optDec = true; + format = format.replace('[.]', '.'); + } + + int = value.toString().split('.')[0]; + precision = format.split('.')[1]; + thousands = format.indexOf(','); + + 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, null, roundingFunction); + } + + // format number + if (numeral._.includes(int, '-')) { + int = int.slice(1); + neg = true; + } + + if (thousands > -1) { + int = int.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + locale.delimiters.thousands); + } + + if (format.indexOf('.') === 0) { + int = ''; + } + + return (negP && neg ? '(' : '') + (!negP && neg ? '-' : '') + (!neg && signed ? '+' : '') + int + decimal + (abbr ? abbr : '') + (negP && neg ? ')' : ''); + }, loadLocale: function (key, values) { locales[key] = values; }, @@ -532,14 +393,14 @@ output = options.nullFormat; } else { for (kind in formats) { - if (kind.regexp && format.match(kind.regexp)) { - formatFunction = kind.format; + if (formats[kind].regexp && format.match(formats[kind].regexp)) { + formatFunction = formats[kind].format; break; } } - formatFunction = formatFunction || formats.number.format; + formatFunction = formatFunction || numeral._.formatNumber; output = formatFunction(value, format, roundingFunction); } @@ -601,8 +462,6 @@ } }; - - /************************************ Default Locale && Format ************************************/ @@ -630,128 +489,6 @@ } }); - numeral.register('format', 'number', { - regexp: null, - format: function(value, format, roundingFunction) { - var locale = numeral.locales[numeral.options.currentLocale], - negP = false, - signed = false, - optDec = false, - abbr = '', - trillion = 1000000000000, - billion = 1000000000, - million = 1000000, - thousand = 1000, - abbrForce, // force abbreviation - abs, - min, - max, - power, - int, - precision, - thousands, - decimal = '', - neg = false; - - // 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.slice(1, -1); - } else if (numeral._.includes(format, '+')) { - signed = true; - 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; - } - } - - - if (numeral._.includes(format, '[.]')) { - optDec = true; - format = format.replace('[.]', '.'); - } - - int = value.toString().split('.')[0]; - precision = format.split('.')[1]; - thousands = format.indexOf(','); - - 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, null, roundingFunction); - } - - // format number - if (numeral._.includes(int, '-')) { - int = int.slice(1); - neg = true; - } - - if (thousands > -1) { - int = int.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + locale.delimiters.thousands); - } - - if (format.indexOf('.') === 0) { - int = ''; - } - - return (negP && neg ? '(' : '') + (!negP && neg ? '-' : '') + (!neg && signed ? '+' : '') + int + decimal + (abbr ? abbr : '') + (negP && neg ? ')' : ''); - } - }); - /************************************ Exposing Numeral diff --git a/tests/formats/currency.js b/tests/formats/currency.js index 00d9af1b..eaf25fde 100644 --- a/tests/formats/currency.js +++ b/tests/formats/currency.js @@ -2,51 +2,49 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../src/numeral'); - var numeral = require('../../src/formats/currency'); + var format = require('../../src/formats/currency'); var expect = require('chai').expect; } -describe('Format', function() { +describe('Currency', function() { after(function() { numeral.reset(); }); - describe('Currency', function() { - 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)','($1,000)'], - [-1000.234,'(0,0$)','(1,000$)'], - [-1000.234,'$0.00','-$1000.23'], - [1230974,'($0.00 a)','$1.23 m'], + 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)','($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'], + // 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; + [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]); - } - }); + for (i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } }); }); diff --git a/tests/formats/percentage.js b/tests/formats/percentage.js new file mode 100644 index 00000000..4671c1fc --- /dev/null +++ b/tests/formats/percentage.js @@ -0,0 +1,29 @@ + +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../src/numeral'); + var format = require('../../src/formats/percentage'); + var expect = require('chai').expect; +} + +describe('Percentage', function() { + after(function() { + numeral.reset(); + }); + + it('should format to percentages', 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]); + } + }); +}); diff --git a/tests/numeral/format.js b/tests/numeral/format.js index 3fff8e3a..90f93366 100644 --- a/tests/numeral/format.js +++ b/tests/numeral/format.js @@ -78,153 +78,138 @@ describe('Format', function() { } }); }); - // describe('Ordinals', function() { - // 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'); - // } - // }); - // }); + describe('Ordinals', function() { + 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'); + } + }); + }); + + describe('Currency', function() { + 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)','($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; + + for (i = 0; i < tests.length; i++) { + expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); + } + }); + }); + + describe('Bytes', function() { + 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]); + } + }); + }); + + describe('Percentages', function() { + }); + + describe('Times', function() { + it('should format to times', 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]); + } + + }); + }); + + describe('Exponential', function() { + 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]); + } + + }); + }); - // describe('Currency', function() { - // 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)','($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; - // - // for (i = 0; i < tests.length; i++) { - // expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); - // } - // }); - // }); - // - // describe('Bytes', function() { - // 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]); - // } - // }); - // }); - // - // describe('Percentages', function() { - // it('should format to percentages', 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]); - // } - // }); - // }); - // - // describe('Times', function() { - // it('should format to times', 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]); - // } - // - // }); - // }); - // - // describe('Exponential', function() { - // 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]); - // } - // - // }); - // }); - // describe('Rounding', function() { it('should format with rounding', function() { var tests = [ From d4dc06a6ed78e7192899e645de5d5110c9035375 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 1 Dec 2016 23:14:24 -0800 Subject: [PATCH 095/150] add ordinal --- src/formats/ordinal.js | 35 +++++++++++++++++++++++++++++++++++ src/formats/percentage.js | 2 +- tests/formats/ordinal.js | 35 +++++++++++++++++++++++++++++++++++ tests/numeral/format.js | 21 --------------------- 4 files changed, 71 insertions(+), 22 deletions(-) create mode 100644 src/formats/ordinal.js create mode 100644 tests/formats/ordinal.js diff --git a/src/formats/ordinal.js b/src/formats/ordinal.js new file mode 100644 index 00000000..9f5b85f0 --- /dev/null +++ b/src/formats/ordinal.js @@ -0,0 +1,35 @@ +/* + * numeral.js format configuration + * format : ordinal + * author : Adam Draper : https://github.com/adamwdraper + */ +(function () { + var numeral; + + // get numeral from environment + if (typeof window !== 'undefined' && this.numeral) { + // Browser + numeral = this.numeral; + } else if (typeof module !== 'undefined' && module.exports) { + // Node + numeral = require('../numeral'); + } + + numeral.register('format', 'ordinal', { + regexp: /(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._.formatNumber(value, format, roundingFunction); + + return output + ordinal; + } + }); +}()); diff --git a/src/formats/percentage.js b/src/formats/percentage.js index 6f8a90ae..242f0a4e 100644 --- a/src/formats/percentage.js +++ b/src/formats/percentage.js @@ -1,6 +1,6 @@ /* * numeral.js format configuration - * format : currency + * format : percentage * author : Adam Draper : https://github.com/adamwdraper */ (function () { diff --git a/tests/formats/ordinal.js b/tests/formats/ordinal.js new file mode 100644 index 00000000..3493f44b --- /dev/null +++ b/tests/formats/ordinal.js @@ -0,0 +1,35 @@ + +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../src/numeral'); + var format = require('../../src/formats/ordinal'); + 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'); + } + }); +}); diff --git a/tests/numeral/format.js b/tests/numeral/format.js index 90f93366..bd42537a 100644 --- a/tests/numeral/format.js +++ b/tests/numeral/format.js @@ -79,27 +79,6 @@ describe('Format', function() { }); }); describe('Ordinals', function() { - 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'); - } - }); }); describe('Currency', function() { From 5112704d807d004b6dfde5e5b04a125aa9cb70e2 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 1 Dec 2016 23:45:18 -0800 Subject: [PATCH 096/150] bytes format --- src/formats/bytes.js | 59 +++++++++++++++ tests/formats/bytes.js | 38 ++++++++++ tests/numeral/format.js | 140 ------------------------------------ tests/numeral/manipulate.js | 128 --------------------------------- 4 files changed, 97 insertions(+), 268 deletions(-) create mode 100644 src/formats/bytes.js create mode 100644 tests/formats/bytes.js delete mode 100644 tests/numeral/manipulate.js diff --git a/src/formats/bytes.js b/src/formats/bytes.js new file mode 100644 index 00000000..43dcccdd --- /dev/null +++ b/src/formats/bytes.js @@ -0,0 +1,59 @@ +/* + * numeral.js format configuration + * format : bytes + * author : Adam Draper : https://github.com/adamwdraper + */ +(function () { + var numeral, + 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'] + }; + + // get numeral from environment + if (typeof window !== 'undefined' && this.numeral) { + // Browser + numeral = this.numeral; + } else if (typeof module !== 'undefined' && module.exports) { + // Node + numeral = require('../numeral'); + } + + numeral.register('format', 'bytes', { + regexp: /([0\s]i?b)/, + 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._.formatNumber(value, format, roundingFunction); + + return output + suffix; + } + }); +}()); diff --git a/tests/formats/bytes.js b/tests/formats/bytes.js new file mode 100644 index 00000000..bf8c74be --- /dev/null +++ b/tests/formats/bytes.js @@ -0,0 +1,38 @@ + +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../src/numeral'); + var format = require('../../src/formats/bytes'); + 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]); + } + }); +}); diff --git a/tests/numeral/format.js b/tests/numeral/format.js index bd42537a..2f7ea1cc 100644 --- a/tests/numeral/format.js +++ b/tests/numeral/format.js @@ -10,146 +10,6 @@ describe('Format', 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('Numbers', 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'], - [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'], - [3162.63,'0.0[00000000000000]','3162.63'], - [1.99,'0.[0]','2'], - [1.0501,'0.00[0]','1.05'], - // abbreviations - [2000000000,'0.0a','2.0b'], - [1230974,'0.0a','1.2m'], - [1460,'0a','1k'], - [-104000,'0 a','-104 k'], - // 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('Ordinals', function() { - }); - - describe('Currency', function() { - 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)','($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; - - for (i = 0; i < tests.length; i++) { - expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); - } - }); - }); - - describe('Bytes', function() { - 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]); - } - }); - }); - - describe('Percentages', function() { - }); - describe('Times', function() { it('should format to times', function() { var tests = [ diff --git a/tests/numeral/manipulate.js b/tests/numeral/manipulate.js deleted file mode 100644 index 4a6a60cd..00000000 --- a/tests/numeral/manipulate.js +++ /dev/null @@ -1,128 +0,0 @@ -// Node -if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../src/numeral'); - var expect = require('chai').expect; -} - -describe('Manipulate', function() { - after(function() { - numeral.reset(); - }); - - 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]); - } - }); - }); -}); From 9e5e8fb82611ff41473a3832a219b6280345bdda Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 1 Dec 2016 23:49:58 -0800 Subject: [PATCH 097/150] exponential format --- src/formats/exponential.js | 32 ++++++++++++++++++++++++++++++++ tests/formats/exponential.js | 32 ++++++++++++++++++++++++++++++++ tests/numeral/format.js | 21 --------------------- 3 files changed, 64 insertions(+), 21 deletions(-) create mode 100644 src/formats/exponential.js create mode 100644 tests/formats/exponential.js diff --git a/src/formats/exponential.js b/src/formats/exponential.js new file mode 100644 index 00000000..c8a44caf --- /dev/null +++ b/src/formats/exponential.js @@ -0,0 +1,32 @@ +/* + * numeral.js format configuration + * format : exponential + * author : Adam Draper : https://github.com/adamwdraper + */ +(function () { + var numeral; + + // get numeral from environment + if (typeof window !== 'undefined' && this.numeral) { + // Browser + numeral = this.numeral; + } else if (typeof module !== 'undefined' && module.exports) { + // Node + numeral = require('../numeral'); + } + + numeral.register('format', 'exponential', { + regexp: /(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._.formatNumber(Number(parts[0]), format, roundingFunction); + + return output + 'e' + parts[1]; + } + }); +}()); diff --git a/tests/formats/exponential.js b/tests/formats/exponential.js new file mode 100644 index 00000000..4b3ad458 --- /dev/null +++ b/tests/formats/exponential.js @@ -0,0 +1,32 @@ + +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../src/numeral'); + var format = require('../../src/formats/exponential'); + 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]); + } + + }); +}); diff --git a/tests/numeral/format.js b/tests/numeral/format.js index 2f7ea1cc..5d6cd6e7 100644 --- a/tests/numeral/format.js +++ b/tests/numeral/format.js @@ -28,27 +28,6 @@ describe('Format', function() { }); }); - describe('Exponential', function() { - 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]); - } - - }); - }); - describe('Rounding', function() { it('should format with rounding', function() { var tests = [ From 8aeab9a9d13ba4c55c52407f78170957884d3827 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 1 Dec 2016 23:54:15 -0800 Subject: [PATCH 098/150] time format --- src/formats/time.js | 28 ++++++++++++++++++++++ tests/formats/time.js | 28 ++++++++++++++++++++++ tests/numeral/format.js | 52 ----------------------------------------- 3 files changed, 56 insertions(+), 52 deletions(-) create mode 100644 src/formats/time.js create mode 100644 tests/formats/time.js delete mode 100644 tests/numeral/format.js diff --git a/src/formats/time.js b/src/formats/time.js new file mode 100644 index 00000000..5bcae269 --- /dev/null +++ b/src/formats/time.js @@ -0,0 +1,28 @@ +/* + * numeral.js format configuration + * format : time + * author : Adam Draper : https://github.com/adamwdraper + */ +(function () { + var numeral; + + // get numeral from environment + if (typeof window !== 'undefined' && this.numeral) { + // Browser + numeral = this.numeral; + } else if (typeof module !== 'undefined' && module.exports) { + // Node + numeral = require('../numeral'); + } + + numeral.register('format', 'time', { + regexp: /(:)/, + 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); + } + }); +}()); diff --git a/tests/formats/time.js b/tests/formats/time.js new file mode 100644 index 00000000..254e0df0 --- /dev/null +++ b/tests/formats/time.js @@ -0,0 +1,28 @@ + +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../src/numeral'); + var format = require('../../src/formats/time'); + 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]); + } + }); +}); diff --git a/tests/numeral/format.js b/tests/numeral/format.js deleted file mode 100644 index 5d6cd6e7..00000000 --- a/tests/numeral/format.js +++ /dev/null @@ -1,52 +0,0 @@ - -// Node -if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../src/core'); - var expect = require('chai').expect; -} - -describe('Format', function() { - after(function() { - numeral.reset(); - }); - - describe('Times', function() { - it('should format to times', 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]); - } - - }); - }); - - 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.974878234,'0.000%','97.487%','97.488%'], - [-0.433,'0 %','-44 %', '-43 %'] - ], - 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]); - } - }); - }); -}); From f8f26962fadd79e5b69cc1cb3818824c4b163b7f Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Fri, 2 Dec 2016 00:01:49 -0800 Subject: [PATCH 099/150] build --- Gruntfile.js | 14 +- min/numeral-with-locales.min.js | 2 +- min/numeral.min.js | 2 +- numeral-with-locales.js | 1185 ++++++++++++++----------------- numeral.js | 1185 ++++++++++++++----------------- 5 files changed, 1102 insertions(+), 1286 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index eec2ea13..9d4ab088 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -27,8 +27,8 @@ module.exports = function(grunt) { mochaTest : { all: [ 'tests/numeral.js', - 'tests/formats/*.js' - // 'tests/locales/*.js' + 'tests/formats/*.js', + 'tests/locales/*.js' ] }, karma: { @@ -36,10 +36,10 @@ module.exports = function(grunt) { files: [ 'src/numeral.js', 'src/formats/*.js', - // 'src/locales/*.js', + 'src/locales/*.js', 'tests/numeral.js', - 'tests/formats/*.js' - // 'tests/locales/*.js' + 'tests/formats/*.js', + 'tests/locales/*.js' ], frameworks: [ 'mocha', @@ -69,7 +69,8 @@ module.exports = function(grunt) { concat: { numeral: { src: [ - 'src/numeral.js' + 'src/numeral.js', + 'src/formats/*.js' ], dest: 'numeral.js' }, @@ -82,6 +83,7 @@ module.exports = function(grunt) { numeralWithLocales: { src: [ 'src/numeral.js', + 'src/formats/*.js', 'src/locales/*.js' ], dest: 'numeral-with-locales.js' diff --git a/min/numeral-with-locales.min.js b/min/numeral-with-locales.min.js index e34ee341..50e8d205 100644 --- a/min/numeral-with-locales.min.js +++ b/min/numeral-with-locales.min.js @@ -5,4 +5,4 @@ * 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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i=b.includes(" $")||b.includes("$ ")?" ":"";return b=b.replace(/\s?\$\s?/,""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=g>f||h>f?0:1,e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e=b.includes(" %")?" ":"";return a=100*a,b=b.replace(/\s?\%/,""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i=b.includes(" b")||b.includes(" ib")?" ":"";for(b=b.replace(/\s?i?b/,""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e=b.includes(" o")?" ":"";return b=b.replace(/\s?o/,""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.replace(/e[\+|\-]{1}0/,""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i,j=!1,k=!1,l=!1,m="",n=1e12,o=1e9,p=1e6,q=1e3,r="",t=!1;return a=a||0,f=Math.abs(a),c.includes("(")?(j=!0,c=c.slice(1,-1)):c.includes("+")&&(k=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(e=c.match(/a(k|m|b|t)?/),e=e?e[1]:!1,c.includes(" a")&&(m=" "),c=c.replace(new RegExp(m+"a[kmbt]?"),""),f>=n&&!e||"t"===e?(m+=s[u.currentLocale].abbreviations.trillion,a/=n):n>f&&f>=o&&!e||"b"===e?(m+=s[u.currentLocale].abbreviations.billion,a/=o):o>f&&f>=p&&!e||"m"===e?(m+=s[u.currentLocale].abbreviations.million,a/=p):(p>f&&f>=q&&!e||"k"===e)&&(m+=s[u.currentLocale].abbreviations.thousand,a/=q)),c.includes("[.]")&&(l=!0,c=c.replace("[.]",".")),g=a.toString().split(".")[0],h=c.split(".")[1],i=c.indexOf(","),h?(h.includes("[")?(h=h.replace("]",""),h=h.split("["),r=b(a,h[0].length+h[1].length,d,h[1].length)):r=b(a,h.length,d),g=r.split(".")[0],r=r.includes(".")?s[u.currentLocale].delimiters.decimal+r.split(".")[1]:"",l&&0===Number(r.slice(1))&&(r="")):g=b(a,null,d),g.includes("-")&&(g=g.slice(1),t=!0),i>-1&&(g=g.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(g=""),(j&&t?"(":"")+(!j&&t?"-":"")+(!t&&k?"+":"")+g+r+(m?m:"")+(j&&t?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="Edge",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.reset=function(){for(var a in t)u[a]=t[a]},q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes=String.prototype.includes||function(a,b){return-1!==this.indexOf(a,b)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this),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.locale&&this.numeral.locale("be-nl",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("bg",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("chs",a)}(),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.locale&&this.numeral.locale("cs",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mia",trillion:"b"},ordinal:function(a){return"."},currency:{symbol:"DKK"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("da-dk",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"CHF"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de-ch",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de",a)}(),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.locale&&this.numeral.locale("en-au",a)}(),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.locale&&this.numeral.locale("en-gb",a)}(),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:"R"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("en-za",a)}(),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.locale&&this.numeral.locale("es-es",a)}(),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.locale&&this.numeral.locale("es",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("et",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("fi",a)}(),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.locale&&this.numeral.locale("fr-ca",a)}(),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.locale&&this.numeral.locale("fr-ch",a)}(),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.locale&&this.numeral.locale("fr",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("hu",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("it",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("ja",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("lv",a)}(),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.locale&&this.numeral.locale("nl-nl",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&(this.numeral.locale("nb-no",a),this.numeral.locale("nn-no",a),this.numeral.locale("no",a),this.numeral.locale("nb",a),this.numeral.locale("nn",a))}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pl",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mil",million:"milhões",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"R$"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pt-br",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("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.locale&&this.numeral.locale("ru-ua",a)}(),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.locale&&this.numeral.locale("ru",a)}(),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.locale&&this.numeral.locale("sk",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("th",a)}(),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.locale&&this.numeral.locale("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.locale&&this.numeral.locale("uk-ua",a)}(); \ No newline at end of file +(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="Edge",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};b=function(d){var e;return e=b.isNumeral(d)?d.value():0===d||"undefined"==typeof d?0:null===d||c.isNaN(d)?null:Number(d)||null,new a(d,e)},b.version=d,b.isNumeral=function(b){return b instanceof a},b._=c={formatNumber:function(a,c,d){var e,f,g,h,i,j=b.locales[b.options.currentLocale],k=!1,l=!1,m=!1,n="",o=1e12,p=1e9,q=1e6,r=1e3,s="",t=!1;return a=a||0,f=Math.abs(a),b._.includes(c,"(")?(k=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(l=!0,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")&&(n=" "),c=c.replace(new RegExp(n+"a[kmbt]?"),""),f>=o&&!e||"t"===e?(n+=j.abbreviations.trillion,a/=o):o>f&&f>=p&&!e||"b"===e?(n+=j.abbreviations.billion,a/=p):p>f&&f>=q&&!e||"m"===e?(n+=j.abbreviations.million,a/=q):(q>f&&f>=r&&!e||"k"===e)&&(n+=j.abbreviations.thousand,a/=r)),b._.includes(c,"[.]")&&(m=!0,c=c.replace("[.]",".")),g=a.toString().split(".")[0],h=c.split(".")[1],i=c.indexOf(","),h?(b._.includes(h,"[")?(h=h.replace("]",""),h=h.split("["),s=b._.toFixed(a,h[0].length+h[1].length,d,h[1].length)):s=b._.toFixed(a,h.length,d),g=s.split(".")[0],s=b._.includes(s,".")?j.delimiters.decimal+s.split(".")[1]:"",m&&0===Number(s.slice(1))&&(s="")):g=b._.toFixed(a,null,d),b._.includes(g,"-")&&(g=g.slice(1),t=!0),i>-1&&(g=g.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+j.delimiters.thousands)),0===c.indexOf(".")&&(g=""),(k&&t?"(":"")+(!k&&t?"-":"")+(!t&&l?"+":"")+g+s+(n?n:"")+(k&&t?")":"")},loadLocale:function(a,b){f[a]=b},isNaN:function(a){return"number"==typeof a&&isNaN(a)},includes:function(a,b){return-1!==a.indexOf(b)},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*g)/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,d){if(!a)return h.currentLocale;if(a=a.toLowerCase(),a&&!d){if(!f[a])throw new Error("Unknown locale : "+a);h.currentLocale=a}return(d||!f[a])&&c.loadLocale(a,d),b},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(this[a+"s"][b])throw new TypeError(b+" "+a+" already registered.");this[a+"s"][b]=c},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(e[d].regexp&&j.match(e[d].regexp)){g=e[d].format;break}g=g||b._.formatNumber,f=g(i,j,c)}return f},value:function(){return this._value},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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a,b={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"]};"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","bytes",{regexp:/([0\s]i?b)/,format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.formatNumber(d,e,f),g+l}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","currency",{regexp:/(\$)/,format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.formatNumber(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","exponential",{regexp:/(e\+|e-)/,format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.formatNumber(Number(g[0]),c,d),e+"e"+g[1]}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexp:/(o)/,format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.formatNumber(b,c,d),e+g}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","percentage",{regexp:/(%)/,format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.formatNumber(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","time",{regexp:/(:)/,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)}})}(),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.locale&&this.numeral.locale("be-nl",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("bg",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("chs",a)}(),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.locale&&this.numeral.locale("cs",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mia",trillion:"b"},ordinal:function(a){return"."},currency:{symbol:"DKK"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("da-dk",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"CHF"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de-ch",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de",a)}(),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.locale&&this.numeral.locale("en-au",a)}(),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.locale&&this.numeral.locale("en-gb",a)}(),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:"R"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("en-za",a)}(),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.locale&&this.numeral.locale("es-es",a)}(),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.locale&&this.numeral.locale("es",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("et",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("fi",a)}(),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.locale&&this.numeral.locale("fr-ca",a)}(),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.locale&&this.numeral.locale("fr-ch",a)}(),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.locale&&this.numeral.locale("fr",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("hu",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("it",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("ja",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("lv",a)}(),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.locale&&this.numeral.locale("nl-nl",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&(this.numeral.locale("nb-no",a),this.numeral.locale("nn-no",a),this.numeral.locale("no",a),this.numeral.locale("nb",a),this.numeral.locale("nn",a))}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pl",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mil",million:"milhões",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"R$"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pt-br",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("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.locale&&this.numeral.locale("ru-ua",a)}(),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.locale&&this.numeral.locale("ru",a)}(),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.locale&&this.numeral.locale("sk",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("th",a)}(),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.locale&&this.numeral.locale("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.locale&&this.numeral.locale("uk-ua",a)}(); \ No newline at end of file diff --git a/min/numeral.min.js b/min/numeral.min.js index ad752619..784709ea 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * 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,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*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var k,l,m,n=a._value;if(0===n&&null!==u.zeroFormat)l=u.zeroFormat;else if(null===n&&null!==u.nullFormat)l=u.nullFormat;else{switch(k=b.match(/(\$|%|:|[ai]?b|o|e\+|e-)/),k?k[0]:""){case"$":m=d;break;case"%":m=e;break;case":":m=i;break;case"b":case"ib":m=f;break;case"o":m=g;break;case"e+":case"e-":m=h;break;default:m=j}l=m(n,b,c)}return l}function d(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),i=b.includes(" $")||b.includes("$ ")?" ":"";return b=b.replace(/\s?\$\s?/,""),e=j(a,b,c),1>=f?e.includes("(")||e.includes("-")?(e=e.split(""),d=g>f||h>f?0:1,e.splice(d,0,s[u.currentLocale].currency.symbol+i),e=e.join("")):e=s[u.currentLocale].currency.symbol+i+e:e.includes(")")?(e=e.split(""),e.splice(-1,0,i+s[u.currentLocale].currency.symbol),e=e.join("")):e=e+i+s[u.currentLocale].currency.symbol,e}function e(a,b,c){var d,e=b.includes(" %")?" ":"";return a=100*a,b=b.replace(/\s?\%/,""),d=j(a,b,c),d.includes(")")?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function f(a,b,c){var d,e,f,g,h=b.includes("ib")?v.bytes.binary:v.bytes.decimal,i=b.includes(" b")||b.includes(" ib")?" ":"";for(b=b.replace(/\s?i?b/,""),e=0;e<=h.suffixes.length;e++)if(f=Math.pow(h.base,e),g=Math.pow(h.base,e+1),null===a||0===a||a>=f&&g>a){i+=h.suffixes[e],f>0&&(a/=f);break}return d=j(a,b,c),d+i}function g(a,b,c){var d,e=b.includes(" o")?" ":"";return b=b.replace(/\s?o/,""),e+=s[u.currentLocale].ordinal(a),d=j(a,b,c),d+e}function h(a,b,c){var d,e="number"!=typeof a||Number.isNaN(a)?"0e+0":a.toExponential(),f=e.split("e");return b=b.replace(/e[\+|\-]{1}0/,""),d=j(Number(f[0]),b,c),d+"e"+f[1]}function i(a){var b=Math.floor(a/60/60),c=Math.floor((a-60*b*60)/60),d=Math.round(a-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function j(a,c,d){var e,f,g,h,i,j=!1,k=!1,l=!1,m="",n=1e12,o=1e9,p=1e6,q=1e3,r="",t=!1;return a=a||0,f=Math.abs(a),c.includes("(")?(j=!0,c=c.slice(1,-1)):c.includes("+")&&(k=!0,c=c.replace(/\+/g,"")),c.includes("a")&&(e=c.match(/a(k|m|b|t)?/),e=e?e[1]:!1,c.includes(" a")&&(m=" "),c=c.replace(new RegExp(m+"a[kmbt]?"),""),f>=n&&!e||"t"===e?(m+=s[u.currentLocale].abbreviations.trillion,a/=n):n>f&&f>=o&&!e||"b"===e?(m+=s[u.currentLocale].abbreviations.billion,a/=o):o>f&&f>=p&&!e||"m"===e?(m+=s[u.currentLocale].abbreviations.million,a/=p):(p>f&&f>=q&&!e||"k"===e)&&(m+=s[u.currentLocale].abbreviations.thousand,a/=q)),c.includes("[.]")&&(l=!0,c=c.replace("[.]",".")),g=a.toString().split(".")[0],h=c.split(".")[1],i=c.indexOf(","),h?(h.includes("[")?(h=h.replace("]",""),h=h.split("["),r=b(a,h[0].length+h[1].length,d,h[1].length)):r=b(a,h.length,d),g=r.split(".")[0],r=r.includes(".")?s[u.currentLocale].delimiters.decimal+r.split(".")[1]:"",l&&0===Number(r.slice(1))&&(r="")):g=b(a,null,d),g.includes("-")&&(g=g.slice(1),t=!0),i>-1&&(g=g.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+s[u.currentLocale].delimiters.thousands)),0===c.indexOf(".")&&(g=""),(j&&t?"(":"")+(!j&&t?"-":"")+(!t&&k?"+":"")+g+r+(m?m:"")+(j&&t?")":"")}function k(a,b){var c,d,e,f,g,h,i=b,j=!1;if(b.includes(":"))h=l(b);else if(b.includes("e+")||b.includes("e-"))h=m(b);else if(b===u.zeroFormat||b===u.nullFormat)h=0;else{for("."!==s[u.currentLocale].delimiters.decimal&&(b=b.replace(/\./g,"").replace(s[u.currentLocale].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.thousand+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.million+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.billion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+s[u.currentLocale].abbreviations.trillion+"(?:\\)|(\\"+s[u.currentLocale].currency.symbol+")?(?:\\))?)?$"),g=1;g<=v.bytes.decimal.suffixes.length&&!(j=b.includes(v.bytes.decimal.suffixes[g])||b.includes(v.bytes.binary.suffixes[g])?Math.pow(1024,g):!1);g++);h=j?j:1,h*=i.match(c)?Math.pow(10,3):1,h*=i.match(d)?Math.pow(10,6):1,h*=i.match(e)?Math.pow(10,9):1,h*=i.match(f)?Math.pow(10,12):1,h*=b.includes("%")?.01:1,h*=(b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1,h*=Number(b.replace(/[^0-9\.]+/g,"")),h=j?Math.ceil(h):h}return a._value=h,a._value}function l(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 m(a){function b(a,b,c,d){var e=p(a,b),f=a*e*(b*e)/(e*e);return f}var c=a.includes("e+")?a.split("e+"):a.split("e-"),d=Number(c[0]),e=Number(c[1]);return e=a.includes("e-")?e*=-1:e,[d,Math.pow(10,e)].reduce(b,1)}function n(a,b){s[a]=b}function o(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function p(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=o(b);return a>c?a:c},1)}var q,r="Edge",s={},t={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},u={currentLocale:t.currentLocale,zeroFormat:t.zeroFormat,nullFormat:t.nullFormat,defaultFormat:t.defaultFormat},v={bytes:{decimal:{base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},binary:{base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}}};q=function(b){return b=q.isNumeral(b)?b.value():0===b||"undefined"==typeof b?0:null===b||Number.isNaN(b)?null:Number(b)?Number(b):q.fn.unformat(b),new a(b)},q.version=r,q.isNumeral=function(b){return b instanceof a},q.locale=function(a,b){if(!a)return u.currentLocale;if(a=a.toLowerCase(),a&&!b){if(!s[a])throw new Error("Unknown locale : "+a);u.currentLocale=a}return(b||!s[a])&&n(a,b),q},q.localeData=function(a){if(!a)return s[u.currentLocale];if(a=a.toLowerCase(),!s[a])throw new Error("Unknown locale : "+a);return s[a]},q.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:"$"}}),q.reset=function(){for(var a in t)u[a]=t[a]},q.zeroFormat=function(a){u.zeroFormat="string"==typeof a?a:null},q.nullFormat=function(a){u.nullFormat="string"==typeof a?a:null},q.defaultFormat=function(a){u.defaultFormat="string"==typeof a?a:"0.0"},q.validate=function(a,b){var c,d,e,f,g,h,i,j;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{i=q.localeData(b)}catch(k){i=q.localeData(q.locale())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Number.isNaN=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)},String.prototype.includes=String.prototype.includes||function(a,b){return-1!==this.indexOf(a,b)},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===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 b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),q.fn=a.prototype={clone:function(){return q(this)},format:function(a,b){return c(this,a?a:u.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:k(this,a?a:u.defaultFormat)},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,d,e){return a+Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-Math.round(c*b)}var c=p.call(null,this._value,a);return this._value=[a].reduce(b,Math.round(this._value*c))/c,this},multiply:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)*Math.round(b*e)/Math.round(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=p(a,b);return Math.round(a*e)/Math.round(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(q(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=q),"undefined"==typeof ender&&(this.numeral=q),"function"==typeof define&&define.amd&&define([],function(){return q})}).call(this); \ No newline at end of file +(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="Edge",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};b=function(d){var e;return e=b.isNumeral(d)?d.value():0===d||"undefined"==typeof d?0:null===d||c.isNaN(d)?null:Number(d)||null,new a(d,e)},b.version=d,b.isNumeral=function(b){return b instanceof a},b._=c={formatNumber:function(a,c,d){var e,f,g,h,i,j=b.locales[b.options.currentLocale],k=!1,l=!1,m=!1,n="",o=1e12,p=1e9,q=1e6,r=1e3,s="",t=!1;return a=a||0,f=Math.abs(a),b._.includes(c,"(")?(k=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(l=!0,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")&&(n=" "),c=c.replace(new RegExp(n+"a[kmbt]?"),""),f>=o&&!e||"t"===e?(n+=j.abbreviations.trillion,a/=o):o>f&&f>=p&&!e||"b"===e?(n+=j.abbreviations.billion,a/=p):p>f&&f>=q&&!e||"m"===e?(n+=j.abbreviations.million,a/=q):(q>f&&f>=r&&!e||"k"===e)&&(n+=j.abbreviations.thousand,a/=r)),b._.includes(c,"[.]")&&(m=!0,c=c.replace("[.]",".")),g=a.toString().split(".")[0],h=c.split(".")[1],i=c.indexOf(","),h?(b._.includes(h,"[")?(h=h.replace("]",""),h=h.split("["),s=b._.toFixed(a,h[0].length+h[1].length,d,h[1].length)):s=b._.toFixed(a,h.length,d),g=s.split(".")[0],s=b._.includes(s,".")?j.delimiters.decimal+s.split(".")[1]:"",m&&0===Number(s.slice(1))&&(s="")):g=b._.toFixed(a,null,d),b._.includes(g,"-")&&(g=g.slice(1),t=!0),i>-1&&(g=g.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+j.delimiters.thousands)),0===c.indexOf(".")&&(g=""),(k&&t?"(":"")+(!k&&t?"-":"")+(!t&&l?"+":"")+g+s+(n?n:"")+(k&&t?")":"")},loadLocale:function(a,b){f[a]=b},isNaN:function(a){return"number"==typeof a&&isNaN(a)},includes:function(a,b){return-1!==a.indexOf(b)},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*g)/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,d){if(!a)return h.currentLocale;if(a=a.toLowerCase(),a&&!d){if(!f[a])throw new Error("Unknown locale : "+a);h.currentLocale=a}return(d||!f[a])&&c.loadLocale(a,d),b},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(this[a+"s"][b])throw new TypeError(b+" "+a+" already registered.");this[a+"s"][b]=c},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(e[d].regexp&&j.match(e[d].regexp)){g=e[d].format;break}g=g||b._.formatNumber,f=g(i,j,c)}return f},value:function(){return this._value},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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a,b={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"]};"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","bytes",{regexp:/([0\s]i?b)/,format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.formatNumber(d,e,f),g+l}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","currency",{regexp:/(\$)/,format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.formatNumber(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","exponential",{regexp:/(e\+|e-)/,format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.formatNumber(Number(g[0]),c,d),e+"e"+g[1]}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexp:/(o)/,format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.formatNumber(b,c,d),e+g}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","percentage",{regexp:/(%)/,format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.formatNumber(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","time",{regexp:/(:)/,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)}})}(); \ No newline at end of file diff --git a/numeral-with-locales.js b/numeral-with-locales.js index f3a04c7d..61b0a3f8 100644 --- a/numeral-with-locales.js +++ b/numeral-with-locales.js @@ -13,8 +13,9 @@ ************************************/ var numeral, + _, VERSION = 'Edge', - // internal storage for locale config files + formats = {}, locales = {}, defaults = { currentLocale: 'en', @@ -27,18 +28,6 @@ zeroFormat: defaults.zeroFormat, nullFormat: defaults.nullFormat, defaultFormat: defaults.defaultFormat - }, - config = { - bytes: { - 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'] - } - } }; @@ -46,474 +35,267 @@ 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, 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); - - //roundingFunction = (roundingFunction !== undefined ? roundingFunction : Math.round); - // Multiply up by precision, round accurately, then divide and use native toFixed(): - output = (roundingFunction(value * power) / power).toFixed(boundedPrecision); - - if (optionals > maxDecimals - boundedPrecision) { - optionalsRegExp = new RegExp('\\.?0{1,' + (optionals - (maxDecimals - boundedPrecision)) + '}$'); - output = output.replace(optionalsRegExp, ''); - } + function Numeral(input, number) { + this._input = input; - return output; + this._value = number; } - /************************************ - Formatting - ************************************/ + numeral = function(input) { + var value; - // determine what type of formatting we need to do - function formatNumeral(n, format, roundingFunction) { - var value = n._value, - kind, - output, - formatFunction; - - if (value === 0 && options.zeroFormat !== null) { - output = options.zeroFormat; - } else if (value === null && options.nullFormat !== null) { - output = options.nullFormat; + 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 { - kind = format.match(/(\$|%|:|[ai]?b|o|e\+|e-)/); - - switch (kind ? kind[0] : '') { - case '$': - formatFunction = formatCurrency; - break; - case '%': - formatFunction = formatPercentage; - break; - case ':': - formatFunction = formatTime; - break; - case 'b': - case 'ib': - formatFunction = formatBytes; - break; - case 'o': - formatFunction = formatOrdinal; - break; - case 'e+': - case 'e-': - formatFunction = formatExponential; - break; - default: - formatFunction = formatNumber; - } - - output = formatFunction(value, format, roundingFunction); + value = Number(input)|| null; } - return output; - } + return new Numeral(input, value); + }; - function formatCurrency(value, format, roundingFunction) { - var symbolIndex = format.indexOf('$'), - openParenIndex = format.indexOf('('), - minusSignIndex = format.indexOf('-'), - space = format.includes(' $') || format.includes('$ ') ? ' ' : '', - spliceIndex, - output; + // version number + numeral.version = VERSION; - // strip format of spaces and $ - format = format.replace(/\s?\$\s?/, ''); + // compare numeral object + numeral.isNumeral = function(obj) { + return obj instanceof Numeral; + }; - // format the number - output = formatNumber(value, format, roundingFunction); + // helper functions + numeral._ = _ = { + formatNumber: function(value, format, roundingFunction) { + var locale = numeral.locales[numeral.options.currentLocale], + negP = false, + signed = false, + optDec = false, + abbr = '', + trillion = 1000000000000, + billion = 1000000000, + million = 1000000, + thousand = 1000, + abbrForce, // force abbreviation + abs, + min, + max, + power, + int, + precision, + thousands, + decimal = '', + neg = false; + + // 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.slice(1, -1); + } else if (numeral._.includes(format, '+')) { + signed = true; + format = format.replace(/\+/g, ''); + } - // position the symbol - if (symbolIndex <= 1) { - if (output.includes('(') || output.includes('-')) { - output = output.split(''); + // see if abbreviation is wanted + if (numeral._.includes(format, 'a')) { + abbrForce = format.match(/a(k|m|b|t)?/); - spliceIndex = symbolIndex < openParenIndex || symbolIndex < minusSignIndex ? 0 : 1; + abbrForce = abbrForce ? abbrForce[1] : false; - output.splice(spliceIndex, 0, locales[options.currentLocale].currency.symbol + space); + // check for space before abbreviation + if (numeral._.includes(format, ' a')) { + abbr = ' '; + } - output = output.join(''); - } else { - output = locales[options.currentLocale].currency.symbol + space + output; + 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; + } } - } else { - if (output.includes(')')) { - output = output.split(''); - output.splice(-1, 0, space + locales[options.currentLocale].currency.symbol); - output = output.join(''); - } else { - output = output + space + locales[options.currentLocale].currency.symbol; + if (numeral._.includes(format, '[.]')) { + optDec = true; + format = format.replace('[.]', '.'); } - } - - return output; - } - - function formatPercentage(value, format, roundingFunction) { - var space = format.includes(' %') ? ' ' : '', - output; - value = value * 100; + int = value.toString().split('.')[0]; + precision = format.split('.')[1]; + thousands = format.indexOf(','); - // check for space before % - format = format.replace(/\s?\%/, ''); - - output = formatNumber(value, format, roundingFunction); - - if (output.includes(')')) { - output = output.split(''); - - output.splice(-1, 0, space + '%'); - - output = output.join(''); - } else { - output = output + space + '%'; - } - - return output; - } - - function formatBytes(value, format, roundingFunction) { - var output, - bytes = format.includes('ib') ? config.bytes.binary : config.bytes.decimal, - suffix = format.includes(' b') || format.includes(' 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 (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); + } - if (value === null || value === 0 || value >= min && value < max) { - suffix += bytes.suffixes[power]; + int = decimal.split('.')[0]; - if (min > 0) { - value = value / min; + if (numeral._.includes(decimal, '.')) { + decimal = locale.delimiters.decimal + decimal.split('.')[1]; + } else { + decimal = ''; } - break; + if (optDec && Number(decimal.slice(1)) === 0) { + decimal = ''; + } + } else { + int = numeral._.toFixed(value, null, roundingFunction); } - } - - output = formatNumber(value, format, roundingFunction); - - return output + suffix; - } - - function formatOrdinal(value, format, roundingFunction) { - var output, - ordinal = format.includes(' o') ? ' ' : ''; - - // check for space before - format = format.replace(/\s?o/, ''); - ordinal += locales[options.currentLocale].ordinal(value); - - output = formatNumber(value, format, roundingFunction); - - return output + ordinal; - } - - function formatExponential(value, format, roundingFunction) { - var output, - exponential = typeof value === 'number' && !Number.isNaN(value) ? value.toExponential() : '0e+0', - parts = exponential.split('e'); - - format = format.replace(/e[\+|\-]{1}0/, ''); - - output = formatNumber(Number(parts[0]), format, roundingFunction); - - return output + 'e' + parts[1]; - } - - function formatTime(value) { - 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); - } - - function formatNumber(value, format, roundingFunction) { - var negP = false, - signed = false, - optDec = false, - abbr = '', - trillion = 1000000000000, - billion = 1000000000, - million = 1000000, - thousand = 1000, - abbrForce, // force abbreviation - abs, - min, - max, - power, - int, - precision, - thousands, - decimal = '', - neg = false; - - // 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 (format.includes('(')) { - negP = true; - format = format.slice(1, -1); - } else if (format.includes('+')) { - signed = true; - format = format.replace(/\+/g, ''); - } - - // see if abbreviation is wanted - if (format.includes('a')) { - abbrForce = format.match(/a(k|m|b|t)?/); - - abbrForce = abbrForce ? abbrForce[1] : false; - - // check for space before abbreviation - if (format.includes(' a')) { - abbr = ' '; + // format number + if (numeral._.includes(int, '-')) { + int = int.slice(1); + neg = true; } - format = format.replace(new RegExp(abbr + 'a[kmbt]?'), ''); - - if (abs >= trillion && !abbrForce || abbrForce === 't') { - // trillion - abbr += locales[options.currentLocale].abbreviations.trillion; - value = value / trillion; - } else if (abs < trillion && abs >= billion && !abbrForce || abbrForce === 'b') { - // billion - abbr += locales[options.currentLocale].abbreviations.billion; - value = value / billion; - } else if (abs < billion && abs >= million && !abbrForce || abbrForce === 'm') { - // million - abbr += locales[options.currentLocale].abbreviations.million; - value = value / million; - } else if (abs < million && abs >= thousand && !abbrForce || abbrForce === 'k') { - // thousand - abbr += locales[options.currentLocale].abbreviations.thousand; - value = value / thousand; + if (thousands > -1) { + int = int.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + locale.delimiters.thousands); } - } - - if (format.includes('[.]')) { - optDec = true; - format = format.replace('[.]', '.'); - } - - int = value.toString().split('.')[0]; - precision = format.split('.')[1]; - thousands = format.indexOf(','); - - if (precision) { - if (precision.includes('[')) { - precision = precision.replace(']', ''); - precision = precision.split('['); - decimal = toFixed(value, (precision[0].length + precision[1].length), roundingFunction, precision[1].length); - } else { - decimal = toFixed(value, precision.length, roundingFunction); + if (format.indexOf('.') === 0) { + int = ''; } - int = decimal.split('.')[0]; - - if (decimal.includes('.')) { - decimal = locales[options.currentLocale].delimiters.decimal + decimal.split('.')[1]; - } else { - decimal = ''; + return (negP && neg ? '(' : '') + (!negP && neg ? '-' : '') + (!neg && signed ? '+' : '') + int + decimal + (abbr ? abbr : '') + (negP && neg ? ')' : ''); + }, + loadLocale: function (key, values) { + locales[key] = values; + }, + isNaN: function(value) { + return typeof value === 'number' && isNaN(value); + }, + includes: function(string, search) { + return string.indexOf(search) !== -1; + }, + reduce: function(array, callback /*, initialValue*/) { + if (this === null) { + throw new TypeError('Array.prototype.reduce called on null or undefined'); } - if (optDec && Number(decimal.slice(1)) === 0) { - decimal = ''; + if (typeof callback !== 'function') { + throw new TypeError(callback + ' is not a function'); } - } else { - int = toFixed(value, null, roundingFunction); - } - // format number - if (int.includes('-')) { - int = int.slice(1); - neg = true; - } - - if (thousands > -1) { - int = int.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + locales[options.currentLocale].delimiters.thousands); - } + var t = Object(array), + len = t.length >>> 0, + k = 0, + value; - if (format.indexOf('.') === 0) { - int = ''; - } - - return (negP && neg ? '(' : '') + (!negP && neg ? '-' : '') + (!neg && signed ? '+' : '') + int + decimal + (abbr ? abbr : '') + (negP && neg ? ')' : ''); - } - - - /************************************ - Unformatting - ************************************/ - - // revert to number - function unformatNumeral(n, string) { - var stringOriginal = string, - thousandRegExp, - millionRegExp, - billionRegExp, - trillionRegExp, - bytesMultiplier = false, - power, - value; - - if (string.includes(':')) { - value = unformatTime(string); - } else if (string.includes('e+') || string.includes('e-')) { - value = unformatExponential(string); - } else { - if (string === options.zeroFormat || string === options.nullFormat) { - value = 0; + if (arguments.length === 3) { + value = arguments[2]; } else { - if (locales[options.currentLocale].delimiters.decimal !== '.') { - string = string.replace(/\./g, '').replace(locales[options.currentLocale].delimiters.decimal, '.'); + while (k < len && !(k in t)) { + k++; } - // see if abbreviations are there so that we can multiply to the correct number - thousandRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.thousand + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); - millionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.million + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); - billionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.billion + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); - trillionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.trillion + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); - - // see if bytes are there so that we can multiply to the correct number - for (power = 1; power <= config.bytes.decimal.suffixes.length; power++) { - bytesMultiplier = ((string.includes(config.bytes.decimal.suffixes[power])) || (string.includes(config.bytes.binary.suffixes[power])))? Math.pow(1024, power) : false; - - if (bytesMultiplier) { - break; - } + if (k >= len) { + throw new TypeError('Reduce of empty array with no initial value'); } - // do some math to create our number - value = bytesMultiplier ? bytesMultiplier : 1; - value *= stringOriginal.match(thousandRegExp) ? Math.pow(10, 3) : 1; - value *= stringOriginal.match(millionRegExp) ? Math.pow(10, 6) : 1; - value *= stringOriginal.match(billionRegExp) ? Math.pow(10, 9) : 1; - value *= stringOriginal.match(trillionRegExp) ? Math.pow(10, 12) : 1; - // check for percentage - value *= string.includes('%') ? 0.01 : 1; - // check for negative number - value *= (string.split('-').length + Math.min(string.split('(').length - 1, string.split(')').length - 1)) % 2 ? 1 : -1; - // remove non numbers - value *= Number(string.replace(/[^0-9\.]+/g, '')); - // round if we are talking about bytes - value = bytesMultiplier ? Math.ceil(value) : 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; } - } - - n._value = value; - - return n._value; - } - - 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); - } - - function unformatExponential(string) { - var parts = string.includes('e+') ? string.split('e+') : string.split('e-'), - value = Number(parts[0]), - power = Number(parts[1]); - - power = string.includes('e-') ? power *= -1 : power; - function cback(accum, curr, currI, O) { - var corrFactor = correctionFactor(accum, curr), - num = (accum * corrFactor) * (curr * corrFactor) / (corrFactor * corrFactor); - return num; - } + power = Math.pow(10, boundedPrecision); - return [value, Math.pow(10, power)].reduce(cback, 1); - } + //roundingFunction = (roundingFunction !== undefined ? roundingFunction : Math.round); + // Multiply up by precision, round accurately, then divide and use native toFixed(): + output = (roundingFunction(value * power) / power).toFixed(boundedPrecision); - /************************************ - Top Level Functions - ************************************/ + if (optionals > maxDecimals - boundedPrecision) { + optionalsRegExp = new RegExp('\\.?0{1,' + (optionals - (maxDecimals - boundedPrecision)) + '}$'); + output = output.replace(optionalsRegExp, ''); + } - numeral = function(input) { - if (numeral.isNumeral(input)) { - input = input.value(); - } else if (input === 0 || typeof input === 'undefined') { - input = 0; - } else if (input === null || Number.isNaN(input)) { - input = null; - } else if (!Number(input)) { - input = numeral.fn.unformat(input); - } else { - input = Number(input); + return output; } - - return new Numeral(input); }; - // version number - numeral.version = VERSION; + // avaliable options + numeral.options = options; - // compare numeral object - numeral.isNumeral = function(obj) { - return obj instanceof Numeral; - }; + // avaliable formats + numeral.formats = formats; + // avaliable formats + numeral.locales = locales; // This function will load locales and then set the global locale. If // no arguments are passed in, it will simply return the current global @@ -535,7 +317,7 @@ } if (values || !locales[key]) { - loadLocale(key, values); + _.loadLocale(key, values); } return numeral; @@ -558,29 +340,6 @@ return locales[key]; }; - numeral.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: '$' - } - }); - numeral.reset = function() { for (var property in defaults) { options[property] = defaults[property]; @@ -599,249 +358,102 @@ options.defaultFormat = typeof(format) === 'string' ? format : '0.0'; }; - 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; - } + numeral.register = function(type, name, format) { + if (this[type + 's'][name]) { + throw new TypeError(name + ' ' + type + ' already registered.'); } - _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; + this[type + 's'][name] = format; }; - /************************************ - Helpers - ************************************/ - - function loadLocale(key, values) { - locales[key] = values; - } - - // isNaN polyfill - Number.isNaN = Number.isNaN || function(value) { - return typeof value === 'number' && isNaN(value); - }; - - // String includes polyfill - String.prototype.includes = String.prototype.includes || function(search, start) { - return this.indexOf(search, start) !== -1; - }; - - // Production steps of ECMA-262, Edition 5, 15.4.4.21 - // Reference: http://es5.github.io/#x15.4.4.21 - if (!Array.prototype.reduce) { - Array.prototype.reduce = function(callback /*, initialValue*/) { - 'use strict'; - 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(this), len = t.length >>> 0, k = 0, value; - - if (arguments.length === 2) { - value = arguments[1]; - } 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. - */ - function multiplier(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. - */ - function correctionFactor() { - var args = Array.prototype.slice.call(arguments); - - return args.reduce(function(accum, next) { - var mn = multiplier(next); - return accum > mn ? accum : mn; - }, 1); - } /************************************ Numeral Prototype ************************************/ - numeral.fn = Numeral.prototype = { clone: function() { return numeral(this); }, - format: function (inputString, roundingFunction) { - return formatNumeral(this, - inputString ? inputString : options.defaultFormat, - roundingFunction !== undefined ? roundingFunction : Math.round - ); - }, - unformat: function (inputString) { - if (Object.prototype.toString.call(inputString) === '[object Number]') { - return inputString; + 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 (formats[kind].regexp && format.match(formats[kind].regexp)) { + formatFunction = formats[kind].format; + + break; + } + } + + formatFunction = formatFunction || numeral._.formatNumber; + + output = formatFunction(value, format, roundingFunction); } - return unformatNumeral(this, inputString ? inputString : options.defaultFormat); + return output; }, value: function() { return this._value; }, - valueOf: function() { - return this._value; - }, set: function(value) { this._value = Number(value); return this; }, add: function(value) { - var corrFactor = correctionFactor.call(null, this._value, value); + var corrFactor = _.correctionFactor.call(null, this._value, value); function cback(accum, curr, currI, O) { return accum + Math.round(corrFactor * curr); } - this._value = [this._value, value].reduce(cback, 0) / corrFactor; + this._value = _.reduce([this._value, value], cback, 0) / corrFactor; return this; }, subtract: function(value) { - var corrFactor = correctionFactor.call(null, this._value, value); + var corrFactor = _.correctionFactor.call(null, this._value, value); function cback(accum, curr, currI, O) { return accum - Math.round(corrFactor * curr); } - this._value = [value].reduce(cback, Math.round(this._value * corrFactor)) / corrFactor; + 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); + var corrFactor = _.correctionFactor(accum, curr); return Math.round(accum * corrFactor) * Math.round(curr * corrFactor) / Math.round(corrFactor * corrFactor); } - this._value = [this._value, value].reduce(cback, 1); + this._value = _.reduce([this._value, value], cback, 1); return this; }, divide: function(value) { function cback(accum, curr, currI, O) { - var corrFactor = correctionFactor(accum, curr); + var corrFactor = _.correctionFactor(accum, curr); return Math.round(accum * corrFactor) / Math.round(curr * corrFactor); } - this._value = [this._value, value].reduce(cback); + this._value = _.reduce([this._value, value], cback); return this; }, @@ -850,6 +462,34 @@ } }; + /************************************ + 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: '$' + } + }); + + /************************************ Exposing Numeral ************************************/ @@ -875,6 +515,273 @@ } }).call(this); +/* + * numeral.js format configuration + * format : bytes + * author : Adam Draper : https://github.com/adamwdraper + */ +(function () { + var numeral, + 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'] + }; + + // get numeral from environment + if (typeof window !== 'undefined' && this.numeral) { + // Browser + numeral = this.numeral; + } else if (typeof module !== 'undefined' && module.exports) { + // Node + numeral = require('../numeral'); + } + + numeral.register('format', 'bytes', { + regexp: /([0\s]i?b)/, + 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._.formatNumber(value, format, roundingFunction); + + return output + suffix; + } + }); +}()); + +/* + * numeral.js format configuration + * format : currency + * author : Adam Draper : https://github.com/adamwdraper + */ +(function () { + var numeral; + + // get numeral from environment + if (typeof window !== 'undefined' && this.numeral) { + // Browser + numeral = this.numeral; + } else if (typeof module !== 'undefined' && module.exports) { + // Node + numeral = require('../numeral'); + } + + numeral.register('format', 'currency', { + regexp: /(\$)/, + format: function(value, format, roundingFunction) { + var locale = numeral.locales[numeral.options.currentLocale], + symbolIndex = format.indexOf('$'), + openParenIndex = format.indexOf('('), + minusSignIndex = format.indexOf('-'), + space = numeral._.includes(format, ' $') || numeral._.includes(format, '$ ') ? ' ' : '', + spliceIndex, + output; + + // strip format of spaces and $ + format = format.replace(/\s?\$\s?/, ''); + + // format the number + output = numeral._.formatNumber(value, format, roundingFunction); + + // position the symbol + if (symbolIndex <= 1) { + if (numeral._.includes(output, '(') || numeral._.includes(output, '-')) { + output = output.split(''); + + spliceIndex = symbolIndex < openParenIndex || symbolIndex < minusSignIndex ? 0 : 1; + + output.splice(spliceIndex, 0, locale.currency.symbol + space); + + output = output.join(''); + } else { + output = locale.currency.symbol + space + output; + } + } else { + if (numeral._.includes(output, ')')) { + output = output.split(''); + + output.splice(-1, 0, space + locale.currency.symbol); + + output = output.join(''); + } else { + output = output + space + locale.currency.symbol; + } + } + + return output; + } + }); +}()); + +/* + * numeral.js format configuration + * format : exponential + * author : Adam Draper : https://github.com/adamwdraper + */ +(function () { + var numeral; + + // get numeral from environment + if (typeof window !== 'undefined' && this.numeral) { + // Browser + numeral = this.numeral; + } else if (typeof module !== 'undefined' && module.exports) { + // Node + numeral = require('../numeral'); + } + + numeral.register('format', 'exponential', { + regexp: /(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._.formatNumber(Number(parts[0]), format, roundingFunction); + + return output + 'e' + parts[1]; + } + }); +}()); + +/* + * numeral.js format configuration + * format : ordinal + * author : Adam Draper : https://github.com/adamwdraper + */ +(function () { + var numeral; + + // get numeral from environment + if (typeof window !== 'undefined' && this.numeral) { + // Browser + numeral = this.numeral; + } else if (typeof module !== 'undefined' && module.exports) { + // Node + numeral = require('../numeral'); + } + + numeral.register('format', 'ordinal', { + regexp: /(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._.formatNumber(value, format, roundingFunction); + + return output + ordinal; + } + }); +}()); + +/* + * numeral.js format configuration + * format : percentage + * author : Adam Draper : https://github.com/adamwdraper + */ +(function () { + var numeral; + + // get numeral from environment + if (typeof window !== 'undefined' && this.numeral) { + // Browser + numeral = this.numeral; + } else if (typeof module !== 'undefined' && module.exports) { + // Node + numeral = require('../numeral'); + } + + numeral.register('format', 'percentage', { + regexp: /(%)/, + format: function(value, format, roundingFunction) { + var space = numeral._.includes(format, ' %') ? ' ' : '', + output; + + value = value * 100; + + // check for space before % + format = format.replace(/\s?\%/, ''); + + output = numeral._.formatNumber(value, format, roundingFunction); + + if (numeral._.includes(output, ')')) { + output = output.split(''); + + output.splice(-1, 0, space + '%'); + + output = output.join(''); + } else { + output = output + space + '%'; + } + + return output; + } + }); +}()); + +/* + * numeral.js format configuration + * format : time + * author : Adam Draper : https://github.com/adamwdraper + */ +(function () { + var numeral; + + // get numeral from environment + if (typeof window !== 'undefined' && this.numeral) { + // Browser + numeral = this.numeral; + } else if (typeof module !== 'undefined' && module.exports) { + // Node + numeral = require('../numeral'); + } + + numeral.register('format', 'time', { + regexp: /(:)/, + 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); + } + }); +}()); + /* * numeral.js locale configuration * locale : belgium-dutch (be-nl) diff --git a/numeral.js b/numeral.js index 00cc7086..a86497d2 100644 --- a/numeral.js +++ b/numeral.js @@ -13,8 +13,9 @@ ************************************/ var numeral, + _, VERSION = 'Edge', - // internal storage for locale config files + formats = {}, locales = {}, defaults = { currentLocale: 'en', @@ -27,18 +28,6 @@ zeroFormat: defaults.zeroFormat, nullFormat: defaults.nullFormat, defaultFormat: defaults.defaultFormat - }, - config = { - bytes: { - 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'] - } - } }; @@ -46,474 +35,267 @@ 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, 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); - - //roundingFunction = (roundingFunction !== undefined ? roundingFunction : Math.round); - // Multiply up by precision, round accurately, then divide and use native toFixed(): - output = (roundingFunction(value * power) / power).toFixed(boundedPrecision); - - if (optionals > maxDecimals - boundedPrecision) { - optionalsRegExp = new RegExp('\\.?0{1,' + (optionals - (maxDecimals - boundedPrecision)) + '}$'); - output = output.replace(optionalsRegExp, ''); - } + function Numeral(input, number) { + this._input = input; - return output; + this._value = number; } - /************************************ - Formatting - ************************************/ + numeral = function(input) { + var value; - // determine what type of formatting we need to do - function formatNumeral(n, format, roundingFunction) { - var value = n._value, - kind, - output, - formatFunction; - - if (value === 0 && options.zeroFormat !== null) { - output = options.zeroFormat; - } else if (value === null && options.nullFormat !== null) { - output = options.nullFormat; + 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 { - kind = format.match(/(\$|%|:|[ai]?b|o|e\+|e-)/); - - switch (kind ? kind[0] : '') { - case '$': - formatFunction = formatCurrency; - break; - case '%': - formatFunction = formatPercentage; - break; - case ':': - formatFunction = formatTime; - break; - case 'b': - case 'ib': - formatFunction = formatBytes; - break; - case 'o': - formatFunction = formatOrdinal; - break; - case 'e+': - case 'e-': - formatFunction = formatExponential; - break; - default: - formatFunction = formatNumber; - } - - output = formatFunction(value, format, roundingFunction); + value = Number(input)|| null; } - return output; - } + return new Numeral(input, value); + }; - function formatCurrency(value, format, roundingFunction) { - var symbolIndex = format.indexOf('$'), - openParenIndex = format.indexOf('('), - minusSignIndex = format.indexOf('-'), - space = format.includes(' $') || format.includes('$ ') ? ' ' : '', - spliceIndex, - output; + // version number + numeral.version = VERSION; - // strip format of spaces and $ - format = format.replace(/\s?\$\s?/, ''); + // compare numeral object + numeral.isNumeral = function(obj) { + return obj instanceof Numeral; + }; - // format the number - output = formatNumber(value, format, roundingFunction); + // helper functions + numeral._ = _ = { + formatNumber: function(value, format, roundingFunction) { + var locale = numeral.locales[numeral.options.currentLocale], + negP = false, + signed = false, + optDec = false, + abbr = '', + trillion = 1000000000000, + billion = 1000000000, + million = 1000000, + thousand = 1000, + abbrForce, // force abbreviation + abs, + min, + max, + power, + int, + precision, + thousands, + decimal = '', + neg = false; + + // 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.slice(1, -1); + } else if (numeral._.includes(format, '+')) { + signed = true; + format = format.replace(/\+/g, ''); + } - // position the symbol - if (symbolIndex <= 1) { - if (output.includes('(') || output.includes('-')) { - output = output.split(''); + // see if abbreviation is wanted + if (numeral._.includes(format, 'a')) { + abbrForce = format.match(/a(k|m|b|t)?/); - spliceIndex = symbolIndex < openParenIndex || symbolIndex < minusSignIndex ? 0 : 1; + abbrForce = abbrForce ? abbrForce[1] : false; - output.splice(spliceIndex, 0, locales[options.currentLocale].currency.symbol + space); + // check for space before abbreviation + if (numeral._.includes(format, ' a')) { + abbr = ' '; + } - output = output.join(''); - } else { - output = locales[options.currentLocale].currency.symbol + space + output; + 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; + } } - } else { - if (output.includes(')')) { - output = output.split(''); - output.splice(-1, 0, space + locales[options.currentLocale].currency.symbol); - output = output.join(''); - } else { - output = output + space + locales[options.currentLocale].currency.symbol; + if (numeral._.includes(format, '[.]')) { + optDec = true; + format = format.replace('[.]', '.'); } - } - return output; - } - - function formatPercentage(value, format, roundingFunction) { - var space = format.includes(' %') ? ' ' : '', - output; - - value = value * 100; - - // check for space before % - format = format.replace(/\s?\%/, ''); - - output = formatNumber(value, format, roundingFunction); - - if (output.includes(')')) { - output = output.split(''); - - output.splice(-1, 0, space + '%'); - - output = output.join(''); - } else { - output = output + space + '%'; - } - - return output; - } + int = value.toString().split('.')[0]; + precision = format.split('.')[1]; + thousands = format.indexOf(','); - function formatBytes(value, format, roundingFunction) { - var output, - bytes = format.includes('ib') ? config.bytes.binary : config.bytes.decimal, - suffix = format.includes(' b') || format.includes(' 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 (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); + } - if (value === null || value === 0 || value >= min && value < max) { - suffix += bytes.suffixes[power]; + int = decimal.split('.')[0]; - if (min > 0) { - value = value / min; + if (numeral._.includes(decimal, '.')) { + decimal = locale.delimiters.decimal + decimal.split('.')[1]; + } else { + decimal = ''; } - break; + if (optDec && Number(decimal.slice(1)) === 0) { + decimal = ''; + } + } else { + int = numeral._.toFixed(value, null, roundingFunction); } - } - - output = formatNumber(value, format, roundingFunction); - - return output + suffix; - } - - function formatOrdinal(value, format, roundingFunction) { - var output, - ordinal = format.includes(' o') ? ' ' : ''; - // check for space before - format = format.replace(/\s?o/, ''); - - ordinal += locales[options.currentLocale].ordinal(value); - - output = formatNumber(value, format, roundingFunction); - - return output + ordinal; - } - - function formatExponential(value, format, roundingFunction) { - var output, - exponential = typeof value === 'number' && !Number.isNaN(value) ? value.toExponential() : '0e+0', - parts = exponential.split('e'); - - format = format.replace(/e[\+|\-]{1}0/, ''); - - output = formatNumber(Number(parts[0]), format, roundingFunction); - - return output + 'e' + parts[1]; - } - - function formatTime(value) { - 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); - } - - function formatNumber(value, format, roundingFunction) { - var negP = false, - signed = false, - optDec = false, - abbr = '', - trillion = 1000000000000, - billion = 1000000000, - million = 1000000, - thousand = 1000, - abbrForce, // force abbreviation - abs, - min, - max, - power, - int, - precision, - thousands, - decimal = '', - neg = false; - - // 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 (format.includes('(')) { - negP = true; - format = format.slice(1, -1); - } else if (format.includes('+')) { - signed = true; - format = format.replace(/\+/g, ''); - } - - // see if abbreviation is wanted - if (format.includes('a')) { - abbrForce = format.match(/a(k|m|b|t)?/); - - abbrForce = abbrForce ? abbrForce[1] : false; - - // check for space before abbreviation - if (format.includes(' a')) { - abbr = ' '; + // format number + if (numeral._.includes(int, '-')) { + int = int.slice(1); + neg = true; } - format = format.replace(new RegExp(abbr + 'a[kmbt]?'), ''); - - if (abs >= trillion && !abbrForce || abbrForce === 't') { - // trillion - abbr += locales[options.currentLocale].abbreviations.trillion; - value = value / trillion; - } else if (abs < trillion && abs >= billion && !abbrForce || abbrForce === 'b') { - // billion - abbr += locales[options.currentLocale].abbreviations.billion; - value = value / billion; - } else if (abs < billion && abs >= million && !abbrForce || abbrForce === 'm') { - // million - abbr += locales[options.currentLocale].abbreviations.million; - value = value / million; - } else if (abs < million && abs >= thousand && !abbrForce || abbrForce === 'k') { - // thousand - abbr += locales[options.currentLocale].abbreviations.thousand; - value = value / thousand; + if (thousands > -1) { + int = int.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + locale.delimiters.thousands); } - } - - if (format.includes('[.]')) { - optDec = true; - format = format.replace('[.]', '.'); - } - - int = value.toString().split('.')[0]; - precision = format.split('.')[1]; - thousands = format.indexOf(','); - - if (precision) { - if (precision.includes('[')) { - precision = precision.replace(']', ''); - precision = precision.split('['); - decimal = toFixed(value, (precision[0].length + precision[1].length), roundingFunction, precision[1].length); - } else { - decimal = toFixed(value, precision.length, roundingFunction); + if (format.indexOf('.') === 0) { + int = ''; } - int = decimal.split('.')[0]; - - if (decimal.includes('.')) { - decimal = locales[options.currentLocale].delimiters.decimal + decimal.split('.')[1]; - } else { - decimal = ''; + return (negP && neg ? '(' : '') + (!negP && neg ? '-' : '') + (!neg && signed ? '+' : '') + int + decimal + (abbr ? abbr : '') + (negP && neg ? ')' : ''); + }, + loadLocale: function (key, values) { + locales[key] = values; + }, + isNaN: function(value) { + return typeof value === 'number' && isNaN(value); + }, + includes: function(string, search) { + return string.indexOf(search) !== -1; + }, + reduce: function(array, callback /*, initialValue*/) { + if (this === null) { + throw new TypeError('Array.prototype.reduce called on null or undefined'); } - if (optDec && Number(decimal.slice(1)) === 0) { - decimal = ''; + if (typeof callback !== 'function') { + throw new TypeError(callback + ' is not a function'); } - } else { - int = toFixed(value, null, roundingFunction); - } - // format number - if (int.includes('-')) { - int = int.slice(1); - neg = true; - } - - if (thousands > -1) { - int = int.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + locales[options.currentLocale].delimiters.thousands); - } - - if (format.indexOf('.') === 0) { - int = ''; - } - - return (negP && neg ? '(' : '') + (!negP && neg ? '-' : '') + (!neg && signed ? '+' : '') + int + decimal + (abbr ? abbr : '') + (negP && neg ? ')' : ''); - } - - - /************************************ - Unformatting - ************************************/ + var t = Object(array), + len = t.length >>> 0, + k = 0, + value; - // revert to number - function unformatNumeral(n, string) { - var stringOriginal = string, - thousandRegExp, - millionRegExp, - billionRegExp, - trillionRegExp, - bytesMultiplier = false, - power, - value; - - if (string.includes(':')) { - value = unformatTime(string); - } else if (string.includes('e+') || string.includes('e-')) { - value = unformatExponential(string); - } else { - if (string === options.zeroFormat || string === options.nullFormat) { - value = 0; + if (arguments.length === 3) { + value = arguments[2]; } else { - if (locales[options.currentLocale].delimiters.decimal !== '.') { - string = string.replace(/\./g, '').replace(locales[options.currentLocale].delimiters.decimal, '.'); + while (k < len && !(k in t)) { + k++; } - // see if abbreviations are there so that we can multiply to the correct number - thousandRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.thousand + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); - millionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.million + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); - billionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.billion + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); - trillionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.trillion + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); - - // see if bytes are there so that we can multiply to the correct number - for (power = 1; power <= config.bytes.decimal.suffixes.length; power++) { - bytesMultiplier = ((string.includes(config.bytes.decimal.suffixes[power])) || (string.includes(config.bytes.binary.suffixes[power])))? Math.pow(1024, power) : false; - - if (bytesMultiplier) { - break; - } + if (k >= len) { + throw new TypeError('Reduce of empty array with no initial value'); } - // do some math to create our number - value = bytesMultiplier ? bytesMultiplier : 1; - value *= stringOriginal.match(thousandRegExp) ? Math.pow(10, 3) : 1; - value *= stringOriginal.match(millionRegExp) ? Math.pow(10, 6) : 1; - value *= stringOriginal.match(billionRegExp) ? Math.pow(10, 9) : 1; - value *= stringOriginal.match(trillionRegExp) ? Math.pow(10, 12) : 1; - // check for percentage - value *= string.includes('%') ? 0.01 : 1; - // check for negative number - value *= (string.split('-').length + Math.min(string.split('(').length - 1, string.split(')').length - 1)) % 2 ? 1 : -1; - // remove non numbers - value *= Number(string.replace(/[^0-9\.]+/g, '')); - // round if we are talking about bytes - value = bytesMultiplier ? Math.ceil(value) : 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; } - } - - n._value = value; - - return n._value; - } - - 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); - } - - function unformatExponential(string) { - var parts = string.includes('e+') ? string.split('e+') : string.split('e-'), - value = Number(parts[0]), - power = Number(parts[1]); - - power = string.includes('e-') ? power *= -1 : power; - function cback(accum, curr, currI, O) { - var corrFactor = correctionFactor(accum, curr), - num = (accum * corrFactor) * (curr * corrFactor) / (corrFactor * corrFactor); - return num; - } + power = Math.pow(10, boundedPrecision); - return [value, Math.pow(10, power)].reduce(cback, 1); - } + //roundingFunction = (roundingFunction !== undefined ? roundingFunction : Math.round); + // Multiply up by precision, round accurately, then divide and use native toFixed(): + output = (roundingFunction(value * power) / power).toFixed(boundedPrecision); - /************************************ - Top Level Functions - ************************************/ + if (optionals > maxDecimals - boundedPrecision) { + optionalsRegExp = new RegExp('\\.?0{1,' + (optionals - (maxDecimals - boundedPrecision)) + '}$'); + output = output.replace(optionalsRegExp, ''); + } - numeral = function(input) { - if (numeral.isNumeral(input)) { - input = input.value(); - } else if (input === 0 || typeof input === 'undefined') { - input = 0; - } else if (input === null || Number.isNaN(input)) { - input = null; - } else if (!Number(input)) { - input = numeral.fn.unformat(input); - } else { - input = Number(input); + return output; } - - return new Numeral(input); }; - // version number - numeral.version = VERSION; + // avaliable options + numeral.options = options; - // compare numeral object - numeral.isNumeral = function(obj) { - return obj instanceof Numeral; - }; + // avaliable formats + numeral.formats = formats; + // avaliable formats + numeral.locales = locales; // This function will load locales and then set the global locale. If // no arguments are passed in, it will simply return the current global @@ -535,7 +317,7 @@ } if (values || !locales[key]) { - loadLocale(key, values); + _.loadLocale(key, values); } return numeral; @@ -558,29 +340,6 @@ return locales[key]; }; - numeral.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: '$' - } - }); - numeral.reset = function() { for (var property in defaults) { options[property] = defaults[property]; @@ -599,249 +358,102 @@ options.defaultFormat = typeof(format) === 'string' ? format : '0.0'; }; - 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+$/)); - } - } - } + numeral.register = function(type, name, format) { + if (this[type + 's'][name]) { + throw new TypeError(name + ' ' + type + ' already registered.'); } - return false; + this[type + 's'][name] = format; }; - /************************************ - Helpers - ************************************/ - - function loadLocale(key, values) { - locales[key] = values; - } - - // isNaN polyfill - Number.isNaN = Number.isNaN || function(value) { - return typeof value === 'number' && isNaN(value); - }; - - // String includes polyfill - String.prototype.includes = String.prototype.includes || function(search, start) { - return this.indexOf(search, start) !== -1; - }; - - // Production steps of ECMA-262, Edition 5, 15.4.4.21 - // Reference: http://es5.github.io/#x15.4.4.21 - if (!Array.prototype.reduce) { - Array.prototype.reduce = function(callback /*, initialValue*/) { - 'use strict'; - 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(this), len = t.length >>> 0, k = 0, value; - - if (arguments.length === 2) { - value = arguments[1]; - } 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. - */ - function multiplier(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. - */ - function correctionFactor() { - var args = Array.prototype.slice.call(arguments); - - return args.reduce(function(accum, next) { - var mn = multiplier(next); - return accum > mn ? accum : mn; - }, 1); - } /************************************ Numeral Prototype ************************************/ - numeral.fn = Numeral.prototype = { clone: function() { return numeral(this); }, - format: function (inputString, roundingFunction) { - return formatNumeral(this, - inputString ? inputString : options.defaultFormat, - roundingFunction !== undefined ? roundingFunction : Math.round - ); - }, - unformat: function (inputString) { - if (Object.prototype.toString.call(inputString) === '[object Number]') { - return inputString; + 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 (formats[kind].regexp && format.match(formats[kind].regexp)) { + formatFunction = formats[kind].format; + + break; + } + } + + formatFunction = formatFunction || numeral._.formatNumber; + + output = formatFunction(value, format, roundingFunction); } - return unformatNumeral(this, inputString ? inputString : options.defaultFormat); + return output; }, value: function() { return this._value; }, - valueOf: function() { - return this._value; - }, set: function(value) { this._value = Number(value); return this; }, add: function(value) { - var corrFactor = correctionFactor.call(null, this._value, value); + var corrFactor = _.correctionFactor.call(null, this._value, value); function cback(accum, curr, currI, O) { return accum + Math.round(corrFactor * curr); } - this._value = [this._value, value].reduce(cback, 0) / corrFactor; + this._value = _.reduce([this._value, value], cback, 0) / corrFactor; return this; }, subtract: function(value) { - var corrFactor = correctionFactor.call(null, this._value, value); + var corrFactor = _.correctionFactor.call(null, this._value, value); function cback(accum, curr, currI, O) { return accum - Math.round(corrFactor * curr); } - this._value = [value].reduce(cback, Math.round(this._value * corrFactor)) / corrFactor; + 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); + var corrFactor = _.correctionFactor(accum, curr); return Math.round(accum * corrFactor) * Math.round(curr * corrFactor) / Math.round(corrFactor * corrFactor); } - this._value = [this._value, value].reduce(cback, 1); + this._value = _.reduce([this._value, value], cback, 1); return this; }, divide: function(value) { function cback(accum, curr, currI, O) { - var corrFactor = correctionFactor(accum, curr); + var corrFactor = _.correctionFactor(accum, curr); return Math.round(accum * corrFactor) / Math.round(curr * corrFactor); } - this._value = [this._value, value].reduce(cback); + this._value = _.reduce([this._value, value], cback); return this; }, @@ -850,6 +462,34 @@ } }; + /************************************ + 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: '$' + } + }); + + /************************************ Exposing Numeral ************************************/ @@ -874,3 +514,270 @@ }); } }).call(this); + +/* + * numeral.js format configuration + * format : bytes + * author : Adam Draper : https://github.com/adamwdraper + */ +(function () { + var numeral, + 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'] + }; + + // get numeral from environment + if (typeof window !== 'undefined' && this.numeral) { + // Browser + numeral = this.numeral; + } else if (typeof module !== 'undefined' && module.exports) { + // Node + numeral = require('../numeral'); + } + + numeral.register('format', 'bytes', { + regexp: /([0\s]i?b)/, + 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._.formatNumber(value, format, roundingFunction); + + return output + suffix; + } + }); +}()); + +/* + * numeral.js format configuration + * format : currency + * author : Adam Draper : https://github.com/adamwdraper + */ +(function () { + var numeral; + + // get numeral from environment + if (typeof window !== 'undefined' && this.numeral) { + // Browser + numeral = this.numeral; + } else if (typeof module !== 'undefined' && module.exports) { + // Node + numeral = require('../numeral'); + } + + numeral.register('format', 'currency', { + regexp: /(\$)/, + format: function(value, format, roundingFunction) { + var locale = numeral.locales[numeral.options.currentLocale], + symbolIndex = format.indexOf('$'), + openParenIndex = format.indexOf('('), + minusSignIndex = format.indexOf('-'), + space = numeral._.includes(format, ' $') || numeral._.includes(format, '$ ') ? ' ' : '', + spliceIndex, + output; + + // strip format of spaces and $ + format = format.replace(/\s?\$\s?/, ''); + + // format the number + output = numeral._.formatNumber(value, format, roundingFunction); + + // position the symbol + if (symbolIndex <= 1) { + if (numeral._.includes(output, '(') || numeral._.includes(output, '-')) { + output = output.split(''); + + spliceIndex = symbolIndex < openParenIndex || symbolIndex < minusSignIndex ? 0 : 1; + + output.splice(spliceIndex, 0, locale.currency.symbol + space); + + output = output.join(''); + } else { + output = locale.currency.symbol + space + output; + } + } else { + if (numeral._.includes(output, ')')) { + output = output.split(''); + + output.splice(-1, 0, space + locale.currency.symbol); + + output = output.join(''); + } else { + output = output + space + locale.currency.symbol; + } + } + + return output; + } + }); +}()); + +/* + * numeral.js format configuration + * format : exponential + * author : Adam Draper : https://github.com/adamwdraper + */ +(function () { + var numeral; + + // get numeral from environment + if (typeof window !== 'undefined' && this.numeral) { + // Browser + numeral = this.numeral; + } else if (typeof module !== 'undefined' && module.exports) { + // Node + numeral = require('../numeral'); + } + + numeral.register('format', 'exponential', { + regexp: /(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._.formatNumber(Number(parts[0]), format, roundingFunction); + + return output + 'e' + parts[1]; + } + }); +}()); + +/* + * numeral.js format configuration + * format : ordinal + * author : Adam Draper : https://github.com/adamwdraper + */ +(function () { + var numeral; + + // get numeral from environment + if (typeof window !== 'undefined' && this.numeral) { + // Browser + numeral = this.numeral; + } else if (typeof module !== 'undefined' && module.exports) { + // Node + numeral = require('../numeral'); + } + + numeral.register('format', 'ordinal', { + regexp: /(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._.formatNumber(value, format, roundingFunction); + + return output + ordinal; + } + }); +}()); + +/* + * numeral.js format configuration + * format : percentage + * author : Adam Draper : https://github.com/adamwdraper + */ +(function () { + var numeral; + + // get numeral from environment + if (typeof window !== 'undefined' && this.numeral) { + // Browser + numeral = this.numeral; + } else if (typeof module !== 'undefined' && module.exports) { + // Node + numeral = require('../numeral'); + } + + numeral.register('format', 'percentage', { + regexp: /(%)/, + format: function(value, format, roundingFunction) { + var space = numeral._.includes(format, ' %') ? ' ' : '', + output; + + value = value * 100; + + // check for space before % + format = format.replace(/\s?\%/, ''); + + output = numeral._.formatNumber(value, format, roundingFunction); + + if (numeral._.includes(output, ')')) { + output = output.split(''); + + output.splice(-1, 0, space + '%'); + + output = output.join(''); + } else { + output = output + space + '%'; + } + + return output; + } + }); +}()); + +/* + * numeral.js format configuration + * format : time + * author : Adam Draper : https://github.com/adamwdraper + */ +(function () { + var numeral; + + // get numeral from environment + if (typeof window !== 'undefined' && this.numeral) { + // Browser + numeral = this.numeral; + } else if (typeof module !== 'undefined' && module.exports) { + // Node + numeral = require('../numeral'); + } + + numeral.register('format', 'time', { + regexp: /(:)/, + 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); + } + }); +}()); From 7e086fe9f3b4a074c40784ea95ce571fc5c7326f Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Fri, 2 Dec 2016 23:25:22 -0800 Subject: [PATCH 100/150] move unformat to stringToNumber --- Gruntfile.js | 10 +++--- README.md | 4 +++ min/numeral-with-locales.min.js | 2 +- min/numeral.min.js | 2 +- numeral-with-locales.js | 12 +++---- numeral.js | 12 +++---- src/formats/bytes.js | 2 +- src/formats/currency.js | 2 +- src/formats/exponential.js | 2 +- src/formats/ordinal.js | 2 +- src/formats/percentage.js | 2 +- src/numeral.js | 60 +++++++++++++++++++++++++++++++-- tests/numeral.js | 36 +++++++++++++++++++- tests/numeral/unformat.js | 4 --- 14 files changed, 120 insertions(+), 32 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 9d4ab088..f1524257 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -27,8 +27,8 @@ module.exports = function(grunt) { mochaTest : { all: [ 'tests/numeral.js', - 'tests/formats/*.js', - 'tests/locales/*.js' + 'tests/formats/*.js' + // 'tests/locales/*.js' ] }, karma: { @@ -36,10 +36,10 @@ module.exports = function(grunt) { files: [ 'src/numeral.js', 'src/formats/*.js', - 'src/locales/*.js', + // 'src/locales/*.js', 'tests/numeral.js', - 'tests/formats/*.js', - 'tests/locales/*.js' + 'tests/formats/*.js' + // 'tests/locales/*.js' ], frameworks: [ 'mocha', diff --git a/README.md b/README.md index 1364b521..5b82f696 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,10 @@ See [the english unit tests](https://github.com/adamwdraper/Numeral-js/blob/mast ### 2.0.0 +Breaking change: The unformat function has been removed `numeral().unformat(string)` and now happens on numeral init `numeral(string)` + +Breaking change: All formats are now separate files like locales. The built numeral.js will contain them all, but this will also allow for custom builds that only include certain types of formats. + Breaking change: All `language` now renamed to `locale` and standardized to all lowercase filenames Breaking change: Bytes are now formatted as: `b` (base 1000) and `ib` (base 1024) diff --git a/min/numeral-with-locales.min.js b/min/numeral-with-locales.min.js index 50e8d205..0a523d60 100644 --- a/min/numeral-with-locales.min.js +++ b/min/numeral-with-locales.min.js @@ -5,4 +5,4 @@ * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="Edge",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};b=function(d){var e;return e=b.isNumeral(d)?d.value():0===d||"undefined"==typeof d?0:null===d||c.isNaN(d)?null:Number(d)||null,new a(d,e)},b.version=d,b.isNumeral=function(b){return b instanceof a},b._=c={formatNumber:function(a,c,d){var e,f,g,h,i,j=b.locales[b.options.currentLocale],k=!1,l=!1,m=!1,n="",o=1e12,p=1e9,q=1e6,r=1e3,s="",t=!1;return a=a||0,f=Math.abs(a),b._.includes(c,"(")?(k=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(l=!0,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")&&(n=" "),c=c.replace(new RegExp(n+"a[kmbt]?"),""),f>=o&&!e||"t"===e?(n+=j.abbreviations.trillion,a/=o):o>f&&f>=p&&!e||"b"===e?(n+=j.abbreviations.billion,a/=p):p>f&&f>=q&&!e||"m"===e?(n+=j.abbreviations.million,a/=q):(q>f&&f>=r&&!e||"k"===e)&&(n+=j.abbreviations.thousand,a/=r)),b._.includes(c,"[.]")&&(m=!0,c=c.replace("[.]",".")),g=a.toString().split(".")[0],h=c.split(".")[1],i=c.indexOf(","),h?(b._.includes(h,"[")?(h=h.replace("]",""),h=h.split("["),s=b._.toFixed(a,h[0].length+h[1].length,d,h[1].length)):s=b._.toFixed(a,h.length,d),g=s.split(".")[0],s=b._.includes(s,".")?j.delimiters.decimal+s.split(".")[1]:"",m&&0===Number(s.slice(1))&&(s="")):g=b._.toFixed(a,null,d),b._.includes(g,"-")&&(g=g.slice(1),t=!0),i>-1&&(g=g.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+j.delimiters.thousands)),0===c.indexOf(".")&&(g=""),(k&&t?"(":"")+(!k&&t?"-":"")+(!t&&l?"+":"")+g+s+(n?n:"")+(k&&t?")":"")},loadLocale:function(a,b){f[a]=b},isNaN:function(a){return"number"==typeof a&&isNaN(a)},includes:function(a,b){return-1!==a.indexOf(b)},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*g)/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,d){if(!a)return h.currentLocale;if(a=a.toLowerCase(),a&&!d){if(!f[a])throw new Error("Unknown locale : "+a);h.currentLocale=a}return(d||!f[a])&&c.loadLocale(a,d),b},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(this[a+"s"][b])throw new TypeError(b+" "+a+" already registered.");this[a+"s"][b]=c},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(e[d].regexp&&j.match(e[d].regexp)){g=e[d].format;break}g=g||b._.formatNumber,f=g(i,j,c)}return f},value:function(){return this._value},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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a,b={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"]};"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","bytes",{regexp:/([0\s]i?b)/,format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.formatNumber(d,e,f),g+l}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","currency",{regexp:/(\$)/,format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.formatNumber(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","exponential",{regexp:/(e\+|e-)/,format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.formatNumber(Number(g[0]),c,d),e+"e"+g[1]}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexp:/(o)/,format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.formatNumber(b,c,d),e+g}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","percentage",{regexp:/(%)/,format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.formatNumber(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","time",{regexp:/(:)/,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)}})}(),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.locale&&this.numeral.locale("be-nl",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("bg",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("chs",a)}(),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.locale&&this.numeral.locale("cs",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mia",trillion:"b"},ordinal:function(a){return"."},currency:{symbol:"DKK"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("da-dk",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"CHF"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de-ch",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de",a)}(),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.locale&&this.numeral.locale("en-au",a)}(),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.locale&&this.numeral.locale("en-gb",a)}(),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:"R"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("en-za",a)}(),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.locale&&this.numeral.locale("es-es",a)}(),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.locale&&this.numeral.locale("es",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("et",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("fi",a)}(),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.locale&&this.numeral.locale("fr-ca",a)}(),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.locale&&this.numeral.locale("fr-ch",a)}(),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.locale&&this.numeral.locale("fr",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("hu",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("it",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("ja",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("lv",a)}(),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.locale&&this.numeral.locale("nl-nl",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&(this.numeral.locale("nb-no",a),this.numeral.locale("nn-no",a),this.numeral.locale("no",a),this.numeral.locale("nb",a),this.numeral.locale("nn",a))}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pl",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mil",million:"milhões",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"R$"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pt-br",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("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.locale&&this.numeral.locale("ru-ua",a)}(),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.locale&&this.numeral.locale("ru",a)}(),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.locale&&this.numeral.locale("sk",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("th",a)}(),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.locale&&this.numeral.locale("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.locale&&this.numeral.locale("uk-ua",a)}(); \ No newline at end of file +(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="Edge",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};b=function(d){var e;return e=b.isNumeral(d)?d.value():0===d||"undefined"==typeof d?0:null===d||c.isNaN(d)?null:Number(d)||null,new a(d,e)},b.version=d,b.isNumeral=function(b){return b instanceof a},b._=c={formatNumber:function(a,c,d){var e,f,g,h,i,j=b.locales[b.options.currentLocale],k=!1,l=!1,m=!1,n="",o=1e12,p=1e9,q=1e6,r=1e3,s="",t=!1;return a=a||0,f=Math.abs(a),b._.includes(c,"(")?(k=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(l=!0,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")&&(n=" "),c=c.replace(new RegExp(n+"a[kmbt]?"),""),f>=o&&!e||"t"===e?(n+=j.abbreviations.trillion,a/=o):o>f&&f>=p&&!e||"b"===e?(n+=j.abbreviations.billion,a/=p):p>f&&f>=q&&!e||"m"===e?(n+=j.abbreviations.million,a/=q):(q>f&&f>=r&&!e||"k"===e)&&(n+=j.abbreviations.thousand,a/=r)),b._.includes(c,"[.]")&&(m=!0,c=c.replace("[.]",".")),g=a.toString().split(".")[0],h=c.split(".")[1],i=c.indexOf(","),h?(b._.includes(h,"[")?(h=h.replace("]",""),h=h.split("["),s=b._.toFixed(a,h[0].length+h[1].length,d,h[1].length)):s=b._.toFixed(a,h.length,d),g=s.split(".")[0],s=b._.includes(s,".")?j.delimiters.decimal+s.split(".")[1]:"",m&&0===Number(s.slice(1))&&(s="")):g=b._.toFixed(a,null,d),b._.includes(g,"-")&&(g=g.slice(1),t=!0),i>-1&&(g=g.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+j.delimiters.thousands)),0===c.indexOf(".")&&(g=""),(k&&t?"(":"")+(!k&&t?"-":"")+(!t&&l?"+":"")+g+s+(n?n:"")+(k&&t?")":"")},loadLocale:function(a,b){f[a]=b},isNaN:function(a){return"number"==typeof a&&isNaN(a)},includes:function(a,b){return-1!==a.indexOf(b)},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*g)/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,d){if(!a)return h.currentLocale;if(a=a.toLowerCase(),a&&!d){if(!f[a])throw new Error("Unknown locale : "+a);h.currentLocale=a}return(d||!f[a])&&c.loadLocale(a,d),b},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(this[a+"s"][b])throw new TypeError(b+" "+a+" already registered.");this[a+"s"][b]=c},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(e[d].regexp&&j.match(e[d].regexp)){g=e[d].format;break}g=g||b._.numberToFormat,f=g(i,j,c)}return f},value:function(){return this._value},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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a,b={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"]};"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","bytes",{regexp:/([0\s]i?b)/,format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.numberToFormat(d,e,f),g+l}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","currency",{regexp:/(\$)/,format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","exponential",{regexp:/(e\+|e-)/,format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexp:/(o)/,format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.numberToFormat(b,c,d),e+g}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","percentage",{regexp:/(%)/,format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.numberToFormat(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","time",{regexp:/(:)/,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)}})}(),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.locale&&this.numeral.locale("be-nl",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("bg",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("chs",a)}(),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.locale&&this.numeral.locale("cs",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mia",trillion:"b"},ordinal:function(a){return"."},currency:{symbol:"DKK"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("da-dk",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"CHF"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de-ch",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de",a)}(),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.locale&&this.numeral.locale("en-au",a)}(),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.locale&&this.numeral.locale("en-gb",a)}(),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:"R"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("en-za",a)}(),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.locale&&this.numeral.locale("es-es",a)}(),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.locale&&this.numeral.locale("es",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("et",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("fi",a)}(),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.locale&&this.numeral.locale("fr-ca",a)}(),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.locale&&this.numeral.locale("fr-ch",a)}(),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.locale&&this.numeral.locale("fr",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("hu",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("it",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("ja",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("lv",a)}(),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.locale&&this.numeral.locale("nl-nl",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&(this.numeral.locale("nb-no",a),this.numeral.locale("nn-no",a),this.numeral.locale("no",a),this.numeral.locale("nb",a),this.numeral.locale("nn",a))}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pl",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mil",million:"milhões",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"R$"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pt-br",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("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.locale&&this.numeral.locale("ru-ua",a)}(),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.locale&&this.numeral.locale("ru",a)}(),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.locale&&this.numeral.locale("sk",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("th",a)}(),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.locale&&this.numeral.locale("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.locale&&this.numeral.locale("uk-ua",a)}(); \ No newline at end of file diff --git a/min/numeral.min.js b/min/numeral.min.js index 784709ea..1db020d8 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="Edge",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};b=function(d){var e;return e=b.isNumeral(d)?d.value():0===d||"undefined"==typeof d?0:null===d||c.isNaN(d)?null:Number(d)||null,new a(d,e)},b.version=d,b.isNumeral=function(b){return b instanceof a},b._=c={formatNumber:function(a,c,d){var e,f,g,h,i,j=b.locales[b.options.currentLocale],k=!1,l=!1,m=!1,n="",o=1e12,p=1e9,q=1e6,r=1e3,s="",t=!1;return a=a||0,f=Math.abs(a),b._.includes(c,"(")?(k=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(l=!0,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")&&(n=" "),c=c.replace(new RegExp(n+"a[kmbt]?"),""),f>=o&&!e||"t"===e?(n+=j.abbreviations.trillion,a/=o):o>f&&f>=p&&!e||"b"===e?(n+=j.abbreviations.billion,a/=p):p>f&&f>=q&&!e||"m"===e?(n+=j.abbreviations.million,a/=q):(q>f&&f>=r&&!e||"k"===e)&&(n+=j.abbreviations.thousand,a/=r)),b._.includes(c,"[.]")&&(m=!0,c=c.replace("[.]",".")),g=a.toString().split(".")[0],h=c.split(".")[1],i=c.indexOf(","),h?(b._.includes(h,"[")?(h=h.replace("]",""),h=h.split("["),s=b._.toFixed(a,h[0].length+h[1].length,d,h[1].length)):s=b._.toFixed(a,h.length,d),g=s.split(".")[0],s=b._.includes(s,".")?j.delimiters.decimal+s.split(".")[1]:"",m&&0===Number(s.slice(1))&&(s="")):g=b._.toFixed(a,null,d),b._.includes(g,"-")&&(g=g.slice(1),t=!0),i>-1&&(g=g.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+j.delimiters.thousands)),0===c.indexOf(".")&&(g=""),(k&&t?"(":"")+(!k&&t?"-":"")+(!t&&l?"+":"")+g+s+(n?n:"")+(k&&t?")":"")},loadLocale:function(a,b){f[a]=b},isNaN:function(a){return"number"==typeof a&&isNaN(a)},includes:function(a,b){return-1!==a.indexOf(b)},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*g)/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,d){if(!a)return h.currentLocale;if(a=a.toLowerCase(),a&&!d){if(!f[a])throw new Error("Unknown locale : "+a);h.currentLocale=a}return(d||!f[a])&&c.loadLocale(a,d),b},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(this[a+"s"][b])throw new TypeError(b+" "+a+" already registered.");this[a+"s"][b]=c},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(e[d].regexp&&j.match(e[d].regexp)){g=e[d].format;break}g=g||b._.formatNumber,f=g(i,j,c)}return f},value:function(){return this._value},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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a,b={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"]};"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","bytes",{regexp:/([0\s]i?b)/,format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.formatNumber(d,e,f),g+l}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","currency",{regexp:/(\$)/,format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.formatNumber(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","exponential",{regexp:/(e\+|e-)/,format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.formatNumber(Number(g[0]),c,d),e+"e"+g[1]}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexp:/(o)/,format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.formatNumber(b,c,d),e+g}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","percentage",{regexp:/(%)/,format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.formatNumber(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","time",{regexp:/(:)/,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)}})}(); \ No newline at end of file +(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="Edge",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};b=function(d){var e;return e=b.isNumeral(d)?d.value():0===d||"undefined"==typeof d?0:null===d||c.isNaN(d)?null:Number(d)||null,new a(d,e)},b.version=d,b.isNumeral=function(b){return b instanceof a},b._=c={formatNumber:function(a,c,d){var e,f,g,h,i,j=b.locales[b.options.currentLocale],k=!1,l=!1,m=!1,n="",o=1e12,p=1e9,q=1e6,r=1e3,s="",t=!1;return a=a||0,f=Math.abs(a),b._.includes(c,"(")?(k=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(l=!0,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")&&(n=" "),c=c.replace(new RegExp(n+"a[kmbt]?"),""),f>=o&&!e||"t"===e?(n+=j.abbreviations.trillion,a/=o):o>f&&f>=p&&!e||"b"===e?(n+=j.abbreviations.billion,a/=p):p>f&&f>=q&&!e||"m"===e?(n+=j.abbreviations.million,a/=q):(q>f&&f>=r&&!e||"k"===e)&&(n+=j.abbreviations.thousand,a/=r)),b._.includes(c,"[.]")&&(m=!0,c=c.replace("[.]",".")),g=a.toString().split(".")[0],h=c.split(".")[1],i=c.indexOf(","),h?(b._.includes(h,"[")?(h=h.replace("]",""),h=h.split("["),s=b._.toFixed(a,h[0].length+h[1].length,d,h[1].length)):s=b._.toFixed(a,h.length,d),g=s.split(".")[0],s=b._.includes(s,".")?j.delimiters.decimal+s.split(".")[1]:"",m&&0===Number(s.slice(1))&&(s="")):g=b._.toFixed(a,null,d),b._.includes(g,"-")&&(g=g.slice(1),t=!0),i>-1&&(g=g.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+j.delimiters.thousands)),0===c.indexOf(".")&&(g=""),(k&&t?"(":"")+(!k&&t?"-":"")+(!t&&l?"+":"")+g+s+(n?n:"")+(k&&t?")":"")},loadLocale:function(a,b){f[a]=b},isNaN:function(a){return"number"==typeof a&&isNaN(a)},includes:function(a,b){return-1!==a.indexOf(b)},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*g)/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,d){if(!a)return h.currentLocale;if(a=a.toLowerCase(),a&&!d){if(!f[a])throw new Error("Unknown locale : "+a);h.currentLocale=a}return(d||!f[a])&&c.loadLocale(a,d),b},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(this[a+"s"][b])throw new TypeError(b+" "+a+" already registered.");this[a+"s"][b]=c},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(e[d].regexp&&j.match(e[d].regexp)){g=e[d].format;break}g=g||b._.numberToFormat,f=g(i,j,c)}return f},value:function(){return this._value},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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a,b={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"]};"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","bytes",{regexp:/([0\s]i?b)/,format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.numberToFormat(d,e,f),g+l}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","currency",{regexp:/(\$)/,format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","exponential",{regexp:/(e\+|e-)/,format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexp:/(o)/,format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.numberToFormat(b,c,d),e+g}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","percentage",{regexp:/(%)/,format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.numberToFormat(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","time",{regexp:/(:)/,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)}})}(); \ No newline at end of file diff --git a/numeral-with-locales.js b/numeral-with-locales.js index 61b0a3f8..0d56f0bb 100644 --- a/numeral-with-locales.js +++ b/numeral-with-locales.js @@ -400,7 +400,7 @@ } } - formatFunction = formatFunction || numeral._.formatNumber; + formatFunction = formatFunction || numeral._.numberToFormat; output = formatFunction(value, format, roundingFunction); } @@ -568,7 +568,7 @@ } } - output = numeral._.formatNumber(value, format, roundingFunction); + output = numeral._.numberToFormat(value, format, roundingFunction); return output + suffix; } @@ -607,7 +607,7 @@ format = format.replace(/\s?\$\s?/, ''); // format the number - output = numeral._.formatNumber(value, format, roundingFunction); + output = numeral._.numberToFormat(value, format, roundingFunction); // position the symbol if (symbolIndex <= 1) { @@ -665,7 +665,7 @@ format = format.replace(/e[\+|\-]{1}0/, ''); - output = numeral._.formatNumber(Number(parts[0]), format, roundingFunction); + output = numeral._.numberToFormat(Number(parts[0]), format, roundingFunction); return output + 'e' + parts[1]; } @@ -701,7 +701,7 @@ ordinal += locale.ordinal(value); - output = numeral._.formatNumber(value, format, roundingFunction); + output = numeral._.numberToFormat(value, format, roundingFunction); return output + ordinal; } @@ -736,7 +736,7 @@ // check for space before % format = format.replace(/\s?\%/, ''); - output = numeral._.formatNumber(value, format, roundingFunction); + output = numeral._.numberToFormat(value, format, roundingFunction); if (numeral._.includes(output, ')')) { output = output.split(''); diff --git a/numeral.js b/numeral.js index a86497d2..a4086430 100644 --- a/numeral.js +++ b/numeral.js @@ -400,7 +400,7 @@ } } - formatFunction = formatFunction || numeral._.formatNumber; + formatFunction = formatFunction || numeral._.numberToFormat; output = formatFunction(value, format, roundingFunction); } @@ -568,7 +568,7 @@ } } - output = numeral._.formatNumber(value, format, roundingFunction); + output = numeral._.numberToFormat(value, format, roundingFunction); return output + suffix; } @@ -607,7 +607,7 @@ format = format.replace(/\s?\$\s?/, ''); // format the number - output = numeral._.formatNumber(value, format, roundingFunction); + output = numeral._.numberToFormat(value, format, roundingFunction); // position the symbol if (symbolIndex <= 1) { @@ -665,7 +665,7 @@ format = format.replace(/e[\+|\-]{1}0/, ''); - output = numeral._.formatNumber(Number(parts[0]), format, roundingFunction); + output = numeral._.numberToFormat(Number(parts[0]), format, roundingFunction); return output + 'e' + parts[1]; } @@ -701,7 +701,7 @@ ordinal += locale.ordinal(value); - output = numeral._.formatNumber(value, format, roundingFunction); + output = numeral._.numberToFormat(value, format, roundingFunction); return output + ordinal; } @@ -736,7 +736,7 @@ // check for space before % format = format.replace(/\s?\%/, ''); - output = numeral._.formatNumber(value, format, roundingFunction); + output = numeral._.numberToFormat(value, format, roundingFunction); if (numeral._.includes(output, ')')) { output = output.split(''); diff --git a/src/formats/bytes.js b/src/formats/bytes.js index 43dcccdd..8f1592fe 100644 --- a/src/formats/bytes.js +++ b/src/formats/bytes.js @@ -51,7 +51,7 @@ } } - output = numeral._.formatNumber(value, format, roundingFunction); + output = numeral._.numberToFormat(value, format, roundingFunction); return output + suffix; } diff --git a/src/formats/currency.js b/src/formats/currency.js index 9944e2c5..406b1a4f 100644 --- a/src/formats/currency.js +++ b/src/formats/currency.js @@ -30,7 +30,7 @@ format = format.replace(/\s?\$\s?/, ''); // format the number - output = numeral._.formatNumber(value, format, roundingFunction); + output = numeral._.numberToFormat(value, format, roundingFunction); // position the symbol if (symbolIndex <= 1) { diff --git a/src/formats/exponential.js b/src/formats/exponential.js index c8a44caf..fee03c24 100644 --- a/src/formats/exponential.js +++ b/src/formats/exponential.js @@ -24,7 +24,7 @@ format = format.replace(/e[\+|\-]{1}0/, ''); - output = numeral._.formatNumber(Number(parts[0]), format, roundingFunction); + output = numeral._.numberToFormat(Number(parts[0]), format, roundingFunction); return output + 'e' + parts[1]; } diff --git a/src/formats/ordinal.js b/src/formats/ordinal.js index 9f5b85f0..fe9da6ec 100644 --- a/src/formats/ordinal.js +++ b/src/formats/ordinal.js @@ -27,7 +27,7 @@ ordinal += locale.ordinal(value); - output = numeral._.formatNumber(value, format, roundingFunction); + output = numeral._.numberToFormat(value, format, roundingFunction); return output + ordinal; } diff --git a/src/formats/percentage.js b/src/formats/percentage.js index 242f0a4e..5c9c2365 100644 --- a/src/formats/percentage.js +++ b/src/formats/percentage.js @@ -26,7 +26,7 @@ // check for space before % format = format.replace(/\s?\%/, ''); - output = numeral._.formatNumber(value, format, roundingFunction); + output = numeral._.numberToFormat(value, format, roundingFunction); if (numeral._.includes(output, ')')) { output = output.split(''); diff --git a/src/numeral.js b/src/numeral.js index 69d3ea61..fc640f7d 100644 --- a/src/numeral.js +++ b/src/numeral.js @@ -51,6 +51,9 @@ value = 0; } else if (input === null || _.isNaN(input)) { value = null; + } else if (typeof input === 'string') { + console.log('string', input); + value = numeral._.stringToNumber(input); } else { value = Number(input)|| null; } @@ -68,8 +71,9 @@ // helper functions numeral._ = _ = { - formatNumber: function(value, format, roundingFunction) { - var locale = numeral.locales[numeral.options.currentLocale], + // formats numbers separators, decimals places, signs, abbreviations + numberToFormat: function(value, format, roundingFunction) { + var locale = locales[numeral.options.currentLocale], negP = false, signed = false, optDec = false, @@ -186,6 +190,56 @@ return (negP && neg ? '(' : '') + (!negP && neg ? '-' : '') + (!neg && signed ? '+' : '') + int + decimal + (abbr ? abbr : '') + (negP && neg ? ')' : ''); }, + // 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, + power, + value, + i, + regexp; + + if (string === options.zeroFormat) { + value = 0; + } else if (string === options.nullFormat || !string.replace(/[^0-9]+/g, '')) { + value = null; + } else { + value = 1; + + if (locale.delimiters.decimal !== '.') { + string = string.replace(/\./g, '').replace(locale.delimiters.decimal, '.'); + } + + for (abbreviation in abbreviations) { + regexp = new RegExp(locale.abbreviations[abbreviation] + '$'); + + 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); + } + + // loop through formats for furthur + + return value; + }, loadLocale: function (key, values) { locales[key] = values; }, @@ -400,7 +454,7 @@ } } - formatFunction = formatFunction || numeral._.formatNumber; + formatFunction = formatFunction || numeral._.numberToFormat; output = formatFunction(value, format, roundingFunction); } diff --git a/tests/numeral.js b/tests/numeral.js index 463089c9..e1e33a75 100644 --- a/tests/numeral.js +++ b/tests/numeral.js @@ -29,6 +29,7 @@ describe('Numeral', function() { i; for (i = 0; i < tests.length; i++) { + console.log(tests[i][0]); expect(typeof numeral(tests[i][0]).value()).to.equal(tests[i][1]); } }); @@ -40,7 +41,7 @@ describe('Numeral', function() { [1000, 1000], [0.5, 0.5], [null, null], - ['1,000', null], + ['1,000', 1000], ['not a number', null] ], num; @@ -192,6 +193,39 @@ describe('Numeral', function() { }); }); + 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', null], + ['', 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('Manipulate', function() { describe('Add', function() { diff --git a/tests/numeral/unformat.js b/tests/numeral/unformat.js index 25b4bd46..5d17cb3d 100644 --- a/tests/numeral/unformat.js +++ b/tests/numeral/unformat.js @@ -21,11 +21,7 @@ describe('Unformat', function() { ['10,000.123', 10000.123], ['(0.12345)', -0.12345], ['((--0.12345))', 0.12345], - ['23rd', 23], - ['31st', 31], - ['1.23t', 1230000000000], ['N/A', 0], - [null, 0], ['', 0], // Pass Through for Numbers [0, 0], From 103a81726ab185e19da8f492e41367243ae5d830 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sat, 3 Dec 2016 17:22:43 -0800 Subject: [PATCH 101/150] unformed on construct --- src/numeral.js | 7 +++---- tests/numeral.js | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/numeral.js b/src/numeral.js index fc640f7d..8920ca09 100644 --- a/src/numeral.js +++ b/src/numeral.js @@ -52,7 +52,6 @@ } else if (input === null || _.isNaN(input)) { value = null; } else if (typeof input === 'string') { - console.log('string', input); value = numeral._.stringToNumber(input); } else { value = Number(input)|| null; @@ -206,9 +205,9 @@ i, regexp; - if (string === options.zeroFormat) { + if (options.zeroFormat && string === options.zeroFormat) { value = 0; - } else if (string === options.nullFormat || !string.replace(/[^0-9]+/g, '')) { + } else if (options.nullFormat && string === options.nullFormat || !string.replace(/[^0-9]+/g, '').length) { value = null; } else { value = 1; @@ -236,7 +235,7 @@ value *= Number(string); } - // loop through formats for furthur + // loop through formats for furthur return value; }, diff --git a/tests/numeral.js b/tests/numeral.js index e1e33a75..09346e00 100644 --- a/tests/numeral.js +++ b/tests/numeral.js @@ -209,7 +209,7 @@ describe('Numeral', function() { ['(0.12345)', -0.12345], ['((--0.12345))', 0.12345], ['1.23t', 1230000000000], - ['N/A', null], + ['N/A', 0], ['', null], // Pass Through for Numbers [0, 0], From 34878bcfed93748c5cf306fcd0816c91a18c01fb Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sat, 3 Dec 2016 20:23:47 -0800 Subject: [PATCH 102/150] unformat for bytes --- README.md | 4 +- min/numeral-with-locales.min.js | 2 +- min/numeral.min.js | 2 +- numeral-with-locales.js | 133 +++++++++++++++++++++++++++++--- numeral.js | 133 +++++++++++++++++++++++++++++--- src/formats/bytes.js | 30 ++++++- src/formats/currency.js | 4 +- src/formats/exponential.js | 4 +- src/formats/ordinal.js | 4 +- src/formats/percentage.js | 4 +- src/formats/time.js | 4 +- src/numeral.js | 26 +++++-- tests/formats/bytes.js | 25 ++++++ tests/numeral.js | 1 - 14 files changed, 340 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 5b82f696..afb482fe 100644 --- a/README.md +++ b/README.md @@ -49,9 +49,9 @@ See [the english unit tests](https://github.com/adamwdraper/Numeral-js/blob/mast ### 2.0.0 -Breaking change: The unformat function has been removed `numeral().unformat(string)` and now happens on numeral init `numeral(string)` +Breaking change: The `unformat` function has been removed `numeral().unformat(string)` and now happens on numeral init `numeral(string)` -Breaking change: All formats are now separate files like locales. The built numeral.js will contain them all, but this will also allow for custom builds that only include certain types of formats. +Breaking change: All formats are now separate files. The built numeral.js will contain them all, but this will also allow for custom builds that only include certain types of formats. Breaking change: All `language` now renamed to `locale` and standardized to all lowercase filenames diff --git a/min/numeral-with-locales.min.js b/min/numeral-with-locales.min.js index 0a523d60..78b33ea7 100644 --- a/min/numeral-with-locales.min.js +++ b/min/numeral-with-locales.min.js @@ -5,4 +5,4 @@ * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="Edge",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};b=function(d){var e;return e=b.isNumeral(d)?d.value():0===d||"undefined"==typeof d?0:null===d||c.isNaN(d)?null:Number(d)||null,new a(d,e)},b.version=d,b.isNumeral=function(b){return b instanceof a},b._=c={formatNumber:function(a,c,d){var e,f,g,h,i,j=b.locales[b.options.currentLocale],k=!1,l=!1,m=!1,n="",o=1e12,p=1e9,q=1e6,r=1e3,s="",t=!1;return a=a||0,f=Math.abs(a),b._.includes(c,"(")?(k=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(l=!0,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")&&(n=" "),c=c.replace(new RegExp(n+"a[kmbt]?"),""),f>=o&&!e||"t"===e?(n+=j.abbreviations.trillion,a/=o):o>f&&f>=p&&!e||"b"===e?(n+=j.abbreviations.billion,a/=p):p>f&&f>=q&&!e||"m"===e?(n+=j.abbreviations.million,a/=q):(q>f&&f>=r&&!e||"k"===e)&&(n+=j.abbreviations.thousand,a/=r)),b._.includes(c,"[.]")&&(m=!0,c=c.replace("[.]",".")),g=a.toString().split(".")[0],h=c.split(".")[1],i=c.indexOf(","),h?(b._.includes(h,"[")?(h=h.replace("]",""),h=h.split("["),s=b._.toFixed(a,h[0].length+h[1].length,d,h[1].length)):s=b._.toFixed(a,h.length,d),g=s.split(".")[0],s=b._.includes(s,".")?j.delimiters.decimal+s.split(".")[1]:"",m&&0===Number(s.slice(1))&&(s="")):g=b._.toFixed(a,null,d),b._.includes(g,"-")&&(g=g.slice(1),t=!0),i>-1&&(g=g.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+j.delimiters.thousands)),0===c.indexOf(".")&&(g=""),(k&&t?"(":"")+(!k&&t?"-":"")+(!t&&l?"+":"")+g+s+(n?n:"")+(k&&t?")":"")},loadLocale:function(a,b){f[a]=b},isNaN:function(a){return"number"==typeof a&&isNaN(a)},includes:function(a,b){return-1!==a.indexOf(b)},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*g)/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,d){if(!a)return h.currentLocale;if(a=a.toLowerCase(),a&&!d){if(!f[a])throw new Error("Unknown locale : "+a);h.currentLocale=a}return(d||!f[a])&&c.loadLocale(a,d),b},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(this[a+"s"][b])throw new TypeError(b+" "+a+" already registered.");this[a+"s"][b]=c},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(e[d].regexp&&j.match(e[d].regexp)){g=e[d].format;break}g=g||b._.numberToFormat,f=g(i,j,c)}return f},value:function(){return this._value},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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a,b={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"]};"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","bytes",{regexp:/([0\s]i?b)/,format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.numberToFormat(d,e,f),g+l}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","currency",{regexp:/(\$)/,format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","exponential",{regexp:/(e\+|e-)/,format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexp:/(o)/,format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.numberToFormat(b,c,d),e+g}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","percentage",{regexp:/(%)/,format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.numberToFormat(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","time",{regexp:/(:)/,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)}})}(),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.locale&&this.numeral.locale("be-nl",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("bg",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("chs",a)}(),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.locale&&this.numeral.locale("cs",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mia",trillion:"b"},ordinal:function(a){return"."},currency:{symbol:"DKK"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("da-dk",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"CHF"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de-ch",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de",a)}(),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.locale&&this.numeral.locale("en-au",a)}(),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.locale&&this.numeral.locale("en-gb",a)}(),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:"R"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("en-za",a)}(),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.locale&&this.numeral.locale("es-es",a)}(),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.locale&&this.numeral.locale("es",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("et",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("fi",a)}(),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.locale&&this.numeral.locale("fr-ca",a)}(),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.locale&&this.numeral.locale("fr-ch",a)}(),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.locale&&this.numeral.locale("fr",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("hu",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("it",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("ja",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("lv",a)}(),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.locale&&this.numeral.locale("nl-nl",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&(this.numeral.locale("nb-no",a),this.numeral.locale("nn-no",a),this.numeral.locale("no",a),this.numeral.locale("nb",a),this.numeral.locale("nn",a))}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pl",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mil",million:"milhões",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"R$"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pt-br",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("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.locale&&this.numeral.locale("ru-ua",a)}(),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.locale&&this.numeral.locale("ru",a)}(),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.locale&&this.numeral.locale("sk",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("th",a)}(),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.locale&&this.numeral.locale("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.locale&&this.numeral.locale("uk-ua",a)}(); \ No newline at end of file +(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="Edge",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};b=function(d){var f,g,i;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(d.match(e[g].regexps.unformat)){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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,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")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):p>g&&g>=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):q>g&&g>=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(r>g&&g>=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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(e.abbreviations[b]+"$"),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},loadLocale:function(a,b){f[a]=b},isNaN:function(a){return"number"==typeof a&&isNaN(a)},includes:function(a,b){return-1!==a.indexOf(b)},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*g)/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,d){if(!a)return h.currentLocale;if(a=a.toLowerCase(),a&&!d){if(!f[a])throw new Error("Unknown locale : "+a);h.currentLocale=a}return(d||!f[a])&&c.loadLocale(a,d),b},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(this[a+"s"][b])throw new TypeError(b+" "+a+" already registered.");this[a+"s"][b]=c},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},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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a,b={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"]};"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(console.log("unformating",new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")),g){for(e=0;e<=b.suffixes.length;e++){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e),console.log("jflsekjf");break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e),console.log("gergsegserse");break}}g*=f||1}return console.log(d,g,f),g}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","exponential",{regexps:{format:/(e\+|e-)/},format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexps:{format:/(o)/},format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.numberToFormat(b,c,d),e+g}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","percentage",{regexps:{format:/(%)/},format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.numberToFormat(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","time",{regexps:{format:/(:)/},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)}})}(),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.locale&&this.numeral.locale("be-nl",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("bg",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("chs",a)}(),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.locale&&this.numeral.locale("cs",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mia",trillion:"b"},ordinal:function(a){return"."},currency:{symbol:"DKK"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("da-dk",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"CHF"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de-ch",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de",a)}(),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.locale&&this.numeral.locale("en-au",a)}(),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.locale&&this.numeral.locale("en-gb",a)}(),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:"R"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("en-za",a)}(),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.locale&&this.numeral.locale("es-es",a)}(),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.locale&&this.numeral.locale("es",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("et",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("fi",a)}(),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.locale&&this.numeral.locale("fr-ca",a)}(),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.locale&&this.numeral.locale("fr-ch",a)}(),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.locale&&this.numeral.locale("fr",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("hu",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("it",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("ja",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("lv",a)}(),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.locale&&this.numeral.locale("nl-nl",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&(this.numeral.locale("nb-no",a),this.numeral.locale("nn-no",a),this.numeral.locale("no",a),this.numeral.locale("nb",a),this.numeral.locale("nn",a))}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pl",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mil",million:"milhões",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"R$"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pt-br",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("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.locale&&this.numeral.locale("ru-ua",a)}(),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.locale&&this.numeral.locale("ru",a)}(),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.locale&&this.numeral.locale("sk",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("th",a)}(),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.locale&&this.numeral.locale("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.locale&&this.numeral.locale("uk-ua",a)}(); \ No newline at end of file diff --git a/min/numeral.min.js b/min/numeral.min.js index 1db020d8..d1a67f65 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="Edge",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};b=function(d){var e;return e=b.isNumeral(d)?d.value():0===d||"undefined"==typeof d?0:null===d||c.isNaN(d)?null:Number(d)||null,new a(d,e)},b.version=d,b.isNumeral=function(b){return b instanceof a},b._=c={formatNumber:function(a,c,d){var e,f,g,h,i,j=b.locales[b.options.currentLocale],k=!1,l=!1,m=!1,n="",o=1e12,p=1e9,q=1e6,r=1e3,s="",t=!1;return a=a||0,f=Math.abs(a),b._.includes(c,"(")?(k=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(l=!0,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")&&(n=" "),c=c.replace(new RegExp(n+"a[kmbt]?"),""),f>=o&&!e||"t"===e?(n+=j.abbreviations.trillion,a/=o):o>f&&f>=p&&!e||"b"===e?(n+=j.abbreviations.billion,a/=p):p>f&&f>=q&&!e||"m"===e?(n+=j.abbreviations.million,a/=q):(q>f&&f>=r&&!e||"k"===e)&&(n+=j.abbreviations.thousand,a/=r)),b._.includes(c,"[.]")&&(m=!0,c=c.replace("[.]",".")),g=a.toString().split(".")[0],h=c.split(".")[1],i=c.indexOf(","),h?(b._.includes(h,"[")?(h=h.replace("]",""),h=h.split("["),s=b._.toFixed(a,h[0].length+h[1].length,d,h[1].length)):s=b._.toFixed(a,h.length,d),g=s.split(".")[0],s=b._.includes(s,".")?j.delimiters.decimal+s.split(".")[1]:"",m&&0===Number(s.slice(1))&&(s="")):g=b._.toFixed(a,null,d),b._.includes(g,"-")&&(g=g.slice(1),t=!0),i>-1&&(g=g.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+j.delimiters.thousands)),0===c.indexOf(".")&&(g=""),(k&&t?"(":"")+(!k&&t?"-":"")+(!t&&l?"+":"")+g+s+(n?n:"")+(k&&t?")":"")},loadLocale:function(a,b){f[a]=b},isNaN:function(a){return"number"==typeof a&&isNaN(a)},includes:function(a,b){return-1!==a.indexOf(b)},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*g)/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,d){if(!a)return h.currentLocale;if(a=a.toLowerCase(),a&&!d){if(!f[a])throw new Error("Unknown locale : "+a);h.currentLocale=a}return(d||!f[a])&&c.loadLocale(a,d),b},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(this[a+"s"][b])throw new TypeError(b+" "+a+" already registered.");this[a+"s"][b]=c},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(e[d].regexp&&j.match(e[d].regexp)){g=e[d].format;break}g=g||b._.numberToFormat,f=g(i,j,c)}return f},value:function(){return this._value},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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a,b={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"]};"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","bytes",{regexp:/([0\s]i?b)/,format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.numberToFormat(d,e,f),g+l}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","currency",{regexp:/(\$)/,format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","exponential",{regexp:/(e\+|e-)/,format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexp:/(o)/,format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.numberToFormat(b,c,d),e+g}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","percentage",{regexp:/(%)/,format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.numberToFormat(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","time",{regexp:/(:)/,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)}})}(); \ No newline at end of file +(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="Edge",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};b=function(d){var f,g,i;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(d.match(e[g].regexps.unformat)){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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,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")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):p>g&&g>=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):q>g&&g>=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(r>g&&g>=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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(e.abbreviations[b]+"$"),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},loadLocale:function(a,b){f[a]=b},isNaN:function(a){return"number"==typeof a&&isNaN(a)},includes:function(a,b){return-1!==a.indexOf(b)},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*g)/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,d){if(!a)return h.currentLocale;if(a=a.toLowerCase(),a&&!d){if(!f[a])throw new Error("Unknown locale : "+a);h.currentLocale=a}return(d||!f[a])&&c.loadLocale(a,d),b},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(this[a+"s"][b])throw new TypeError(b+" "+a+" already registered.");this[a+"s"][b]=c},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},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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a,b={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"]};"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(console.log("unformating",new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")),g){for(e=0;e<=b.suffixes.length;e++){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e),console.log("jflsekjf");break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e),console.log("gergsegserse");break}}g*=f||1}return console.log(d,g,f),g}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","exponential",{regexps:{format:/(e\+|e-)/},format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexps:{format:/(o)/},format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.numberToFormat(b,c,d),e+g}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","percentage",{regexps:{format:/(%)/},format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.numberToFormat(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","time",{regexps:{format:/(:)/},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)}})}(); \ No newline at end of file diff --git a/numeral-with-locales.js b/numeral-with-locales.js index 0d56f0bb..32c3691e 100644 --- a/numeral-with-locales.js +++ b/numeral-with-locales.js @@ -43,7 +43,9 @@ } numeral = function(input) { - var value; + var value, + kind, + unformatFunction; if (numeral.isNumeral(input)) { value = input.value(); @@ -51,6 +53,24 @@ 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) { + if (input.match(formats[kind].regexps.unformat)) { + unformatFunction = formats[kind].unformat; + + break; + } + } + + unformatFunction = unformatFunction || numeral._.stringToNumber; + + value = unformatFunction(input); + } } else { value = Number(input)|| null; } @@ -68,8 +88,9 @@ // helper functions numeral._ = _ = { - formatNumber: function(value, format, roundingFunction) { - var locale = numeral.locales[numeral.options.currentLocale], + // formats numbers separators, decimals places, signs, abbreviations + numberToFormat: function(value, format, roundingFunction) { + var locale = locales[numeral.options.currentLocale], negP = false, signed = false, optDec = false, @@ -186,6 +207,54 @@ return (negP && neg ? '(' : '') + (!negP && neg ? '-' : '') + (!neg && signed ? '+' : '') + int + decimal + (abbr ? abbr : '') + (negP && neg ? ')' : ''); }, + // 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, + power, + 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(locale.abbreviations[abbreviation] + '$'); + + 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; + }, loadLocale: function (key, values) { locales[key] = values; }, @@ -393,7 +462,7 @@ output = options.nullFormat; } else { for (kind in formats) { - if (formats[kind].regexp && format.match(formats[kind].regexp)) { + if (format.match(formats[kind].regexps.format)) { formatFunction = formats[kind].format; break; @@ -541,7 +610,10 @@ } numeral.register('format', 'bytes', { - regexp: /([0\s]i?b)/, + regexps: { + format: /([0\s]i?b)/, + unformat: new RegExp('(' + decimal.suffixes.concat(binary.suffixes).join('|') + ')') + }, format: function(value, format, roundingFunction) { var output, bytes = numeral._.includes(format, 'ib') ? binary : decimal, @@ -571,6 +643,37 @@ output = numeral._.numberToFormat(value, format, roundingFunction); return output + suffix; + }, + unformat: function(string) { + var value = numeral._.stringToNumber(string), + power, + bytesMultiplier; + + console.log('unformating', new RegExp('(' + decimal.suffixes.concat(binary.suffixes).join('|') + ')')); + + if (value) { + for (power = 0; power <= decimal.suffixes.length; power++) { + if (numeral._.includes(string, decimal.suffixes[power])) { + bytesMultiplier = Math.pow(decimal.base, power); + + console.log('jflsekjf'); + + break; + } + + if (numeral._.includes(string, binary.suffixes[power])) { + bytesMultiplier = Math.pow(binary.base, power); + console.log('gergsegserse'); + + break; + } + } + + value *= (bytesMultiplier || 1); + } + console.log(string, value, bytesMultiplier); + + return value; } }); }()); @@ -593,7 +696,9 @@ } numeral.register('format', 'currency', { - regexp: /(\$)/, + regexps: { + format: /(\$)/ + }, format: function(value, format, roundingFunction) { var locale = numeral.locales[numeral.options.currentLocale], symbolIndex = format.indexOf('$'), @@ -657,7 +762,9 @@ } numeral.register('format', 'exponential', { - regexp: /(e\+|e-)/, + regexps: { + format: /(e\+|e-)/ + }, format: function(value, format, roundingFunction) { var output, exponential = typeof value === 'number' && !numeral._.isNaN(value) ? value.toExponential() : '0e+0', @@ -690,7 +797,9 @@ } numeral.register('format', 'ordinal', { - regexp: /(o)/, + regexps: { + format: /(o)/ + }, format: function(value, format, roundingFunction) { var locale = numeral.locales[numeral.options.currentLocale], output, @@ -726,7 +835,9 @@ } numeral.register('format', 'percentage', { - regexp: /(%)/, + regexps: { + format: /(%)/ + }, format: function(value, format, roundingFunction) { var space = numeral._.includes(format, ' %') ? ' ' : '', output; @@ -771,7 +882,9 @@ } numeral.register('format', 'time', { - regexp: /(:)/, + regexps: { + format: /(:)/ + }, format: function(value, format, roundingFunction) { var hours = Math.floor(value / 60 / 60), minutes = Math.floor((value - (hours * 60 * 60)) / 60), diff --git a/numeral.js b/numeral.js index a4086430..7f0ff641 100644 --- a/numeral.js +++ b/numeral.js @@ -43,7 +43,9 @@ } numeral = function(input) { - var value; + var value, + kind, + unformatFunction; if (numeral.isNumeral(input)) { value = input.value(); @@ -51,6 +53,24 @@ 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) { + if (input.match(formats[kind].regexps.unformat)) { + unformatFunction = formats[kind].unformat; + + break; + } + } + + unformatFunction = unformatFunction || numeral._.stringToNumber; + + value = unformatFunction(input); + } } else { value = Number(input)|| null; } @@ -68,8 +88,9 @@ // helper functions numeral._ = _ = { - formatNumber: function(value, format, roundingFunction) { - var locale = numeral.locales[numeral.options.currentLocale], + // formats numbers separators, decimals places, signs, abbreviations + numberToFormat: function(value, format, roundingFunction) { + var locale = locales[numeral.options.currentLocale], negP = false, signed = false, optDec = false, @@ -186,6 +207,54 @@ return (negP && neg ? '(' : '') + (!negP && neg ? '-' : '') + (!neg && signed ? '+' : '') + int + decimal + (abbr ? abbr : '') + (negP && neg ? ')' : ''); }, + // 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, + power, + 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(locale.abbreviations[abbreviation] + '$'); + + 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; + }, loadLocale: function (key, values) { locales[key] = values; }, @@ -393,7 +462,7 @@ output = options.nullFormat; } else { for (kind in formats) { - if (formats[kind].regexp && format.match(formats[kind].regexp)) { + if (format.match(formats[kind].regexps.format)) { formatFunction = formats[kind].format; break; @@ -541,7 +610,10 @@ } numeral.register('format', 'bytes', { - regexp: /([0\s]i?b)/, + regexps: { + format: /([0\s]i?b)/, + unformat: new RegExp('(' + decimal.suffixes.concat(binary.suffixes).join('|') + ')') + }, format: function(value, format, roundingFunction) { var output, bytes = numeral._.includes(format, 'ib') ? binary : decimal, @@ -571,6 +643,37 @@ output = numeral._.numberToFormat(value, format, roundingFunction); return output + suffix; + }, + unformat: function(string) { + var value = numeral._.stringToNumber(string), + power, + bytesMultiplier; + + console.log('unformating', new RegExp('(' + decimal.suffixes.concat(binary.suffixes).join('|') + ')')); + + if (value) { + for (power = 0; power <= decimal.suffixes.length; power++) { + if (numeral._.includes(string, decimal.suffixes[power])) { + bytesMultiplier = Math.pow(decimal.base, power); + + console.log('jflsekjf'); + + break; + } + + if (numeral._.includes(string, binary.suffixes[power])) { + bytesMultiplier = Math.pow(binary.base, power); + console.log('gergsegserse'); + + break; + } + } + + value *= (bytesMultiplier || 1); + } + console.log(string, value, bytesMultiplier); + + return value; } }); }()); @@ -593,7 +696,9 @@ } numeral.register('format', 'currency', { - regexp: /(\$)/, + regexps: { + format: /(\$)/ + }, format: function(value, format, roundingFunction) { var locale = numeral.locales[numeral.options.currentLocale], symbolIndex = format.indexOf('$'), @@ -657,7 +762,9 @@ } numeral.register('format', 'exponential', { - regexp: /(e\+|e-)/, + regexps: { + format: /(e\+|e-)/ + }, format: function(value, format, roundingFunction) { var output, exponential = typeof value === 'number' && !numeral._.isNaN(value) ? value.toExponential() : '0e+0', @@ -690,7 +797,9 @@ } numeral.register('format', 'ordinal', { - regexp: /(o)/, + regexps: { + format: /(o)/ + }, format: function(value, format, roundingFunction) { var locale = numeral.locales[numeral.options.currentLocale], output, @@ -726,7 +835,9 @@ } numeral.register('format', 'percentage', { - regexp: /(%)/, + regexps: { + format: /(%)/ + }, format: function(value, format, roundingFunction) { var space = numeral._.includes(format, ' %') ? ' ' : '', output; @@ -771,7 +882,9 @@ } numeral.register('format', 'time', { - regexp: /(:)/, + regexps: { + format: /(:)/ + }, format: function(value, format, roundingFunction) { var hours = Math.floor(value / 60 / 60), minutes = Math.floor((value - (hours * 60 * 60)) / 60), diff --git a/src/formats/bytes.js b/src/formats/bytes.js index 8f1592fe..c3096073 100644 --- a/src/formats/bytes.js +++ b/src/formats/bytes.js @@ -24,7 +24,10 @@ } numeral.register('format', 'bytes', { - regexp: /([0\s]i?b)/, + regexps: { + format: /([0\s]i?b)/, + unformat: new RegExp('(' + decimal.suffixes.concat(binary.suffixes).join('|') + ')') + }, format: function(value, format, roundingFunction) { var output, bytes = numeral._.includes(format, 'ib') ? binary : decimal, @@ -54,6 +57,31 @@ 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 index 406b1a4f..1825a8cd 100644 --- a/src/formats/currency.js +++ b/src/formats/currency.js @@ -16,7 +16,9 @@ } numeral.register('format', 'currency', { - regexp: /(\$)/, + regexps: { + format: /(\$)/ + }, format: function(value, format, roundingFunction) { var locale = numeral.locales[numeral.options.currentLocale], symbolIndex = format.indexOf('$'), diff --git a/src/formats/exponential.js b/src/formats/exponential.js index fee03c24..94420209 100644 --- a/src/formats/exponential.js +++ b/src/formats/exponential.js @@ -16,7 +16,9 @@ } numeral.register('format', 'exponential', { - regexp: /(e\+|e-)/, + regexps: { + format: /(e\+|e-)/ + }, format: function(value, format, roundingFunction) { var output, exponential = typeof value === 'number' && !numeral._.isNaN(value) ? value.toExponential() : '0e+0', diff --git a/src/formats/ordinal.js b/src/formats/ordinal.js index fe9da6ec..5167d68e 100644 --- a/src/formats/ordinal.js +++ b/src/formats/ordinal.js @@ -16,7 +16,9 @@ } numeral.register('format', 'ordinal', { - regexp: /(o)/, + regexps: { + format: /(o)/ + }, format: function(value, format, roundingFunction) { var locale = numeral.locales[numeral.options.currentLocale], output, diff --git a/src/formats/percentage.js b/src/formats/percentage.js index 5c9c2365..a202ae78 100644 --- a/src/formats/percentage.js +++ b/src/formats/percentage.js @@ -16,7 +16,9 @@ } numeral.register('format', 'percentage', { - regexp: /(%)/, + regexps: { + format: /(%)/ + }, format: function(value, format, roundingFunction) { var space = numeral._.includes(format, ' %') ? ' ' : '', output; diff --git a/src/formats/time.js b/src/formats/time.js index 5bcae269..0583a227 100644 --- a/src/formats/time.js +++ b/src/formats/time.js @@ -16,7 +16,9 @@ } numeral.register('format', 'time', { - regexp: /(:)/, + regexps: { + format: /(:)/ + }, format: function(value, format, roundingFunction) { var hours = Math.floor(value / 60 / 60), minutes = Math.floor((value - (hours * 60 * 60)) / 60), diff --git a/src/numeral.js b/src/numeral.js index 8920ca09..ee0fb292 100644 --- a/src/numeral.js +++ b/src/numeral.js @@ -43,7 +43,9 @@ } numeral = function(input) { - var value; + var value, + kind, + unformatFunction; if (numeral.isNumeral(input)) { value = input.value(); @@ -52,7 +54,23 @@ } else if (input === null || _.isNaN(input)) { value = null; } else if (typeof input === 'string') { - value = numeral._.stringToNumber(input); + 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) { + if (input.match(formats[kind].regexps.unformat)) { + unformatFunction = formats[kind].unformat; + + break; + } + } + + unformatFunction = unformatFunction || numeral._.stringToNumber; + + value = unformatFunction(input); + } } else { value = Number(input)|| null; } @@ -235,8 +253,6 @@ value *= Number(string); } - // loop through formats for furthur - return value; }, loadLocale: function (key, values) { @@ -446,7 +462,7 @@ output = options.nullFormat; } else { for (kind in formats) { - if (formats[kind].regexp && format.match(formats[kind].regexp)) { + if (format.match(formats[kind].regexps.format)) { formatFunction = formats[kind].format; break; diff --git a/tests/formats/bytes.js b/tests/formats/bytes.js index bf8c74be..d9e382cd 100644 --- a/tests/formats/bytes.js +++ b/tests/formats/bytes.js @@ -35,4 +35,29 @@ describe('Bytes', function() { 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/numeral.js b/tests/numeral.js index 09346e00..ba2bae37 100644 --- a/tests/numeral.js +++ b/tests/numeral.js @@ -29,7 +29,6 @@ describe('Numeral', function() { i; for (i = 0; i < tests.length; i++) { - console.log(tests[i][0]); expect(typeof numeral(tests[i][0]).value()).to.equal(tests[i][1]); } }); From 8be28bf84cba94451a814ea0a09e0c9eeddc2907 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sat, 3 Dec 2016 21:37:43 -0800 Subject: [PATCH 103/150] unformatting for all formats --- README.md | 4 +- min/numeral-with-locales.min.js | 2 +- min/numeral.min.js | 2 +- numeral-with-locales.js | 68 ++++++++++++++++++++++++++------- numeral.js | 68 ++++++++++++++++++++++++++------- src/formats/exponential.js | 18 ++++++++- src/formats/percentage.js | 6 ++- src/formats/time.js | 23 ++++++++++- src/numeral.js | 13 +++++-- tests/formats/currency.js | 19 ++++++++- tests/formats/exponential.js | 15 ++++++++ tests/formats/ordinal.js | 15 ++++++++ tests/formats/percentage.js | 15 ++++++++ tests/formats/time.js | 14 +++++++ 14 files changed, 241 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index afb482fe..1c8b9cbf 100644 --- a/README.md +++ b/README.md @@ -49,9 +49,9 @@ See [the english unit tests](https://github.com/adamwdraper/Numeral-js/blob/mast ### 2.0.0 -Breaking change: The `unformat` function has been removed `numeral().unformat(string)` and now happens on numeral init `numeral(string)` +Breaking change: 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: All formats are now separate files. The built numeral.js will contain them all, but this will also allow for custom builds that only include certain types of formats. +Breaking change: The `unformat` function has been removed `numeral().unformat(string)` and now happens on numeral init `numeral(string)` Breaking change: All `language` now renamed to `locale` and standardized to all lowercase filenames diff --git a/min/numeral-with-locales.min.js b/min/numeral-with-locales.min.js index 78b33ea7..3353c4d4 100644 --- a/min/numeral-with-locales.min.js +++ b/min/numeral-with-locales.min.js @@ -5,4 +5,4 @@ * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="Edge",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};b=function(d){var f,g,i;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(d.match(e[g].regexps.unformat)){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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,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")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):p>g&&g>=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):q>g&&g>=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(r>g&&g>=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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(e.abbreviations[b]+"$"),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},loadLocale:function(a,b){f[a]=b},isNaN:function(a){return"number"==typeof a&&isNaN(a)},includes:function(a,b){return-1!==a.indexOf(b)},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*g)/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,d){if(!a)return h.currentLocale;if(a=a.toLowerCase(),a&&!d){if(!f[a])throw new Error("Unknown locale : "+a);h.currentLocale=a}return(d||!f[a])&&c.loadLocale(a,d),b},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(this[a+"s"][b])throw new TypeError(b+" "+a+" already registered.");this[a+"s"][b]=c},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},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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a,b={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"]};"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(console.log("unformating",new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")),g){for(e=0;e<=b.suffixes.length;e++){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e),console.log("jflsekjf");break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e),console.log("gergsegserse");break}}g*=f||1}return console.log(d,g,f),g}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","exponential",{regexps:{format:/(e\+|e-)/},format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexps:{format:/(o)/},format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.numberToFormat(b,c,d),e+g}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","percentage",{regexps:{format:/(%)/},format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.numberToFormat(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","time",{regexps:{format:/(:)/},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)}})}(),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.locale&&this.numeral.locale("be-nl",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("bg",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("chs",a)}(),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.locale&&this.numeral.locale("cs",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mia",trillion:"b"},ordinal:function(a){return"."},currency:{symbol:"DKK"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("da-dk",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"CHF"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de-ch",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de",a)}(),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.locale&&this.numeral.locale("en-au",a)}(),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.locale&&this.numeral.locale("en-gb",a)}(),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:"R"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("en-za",a)}(),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.locale&&this.numeral.locale("es-es",a)}(),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.locale&&this.numeral.locale("es",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("et",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("fi",a)}(),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.locale&&this.numeral.locale("fr-ca",a)}(),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.locale&&this.numeral.locale("fr-ch",a)}(),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.locale&&this.numeral.locale("fr",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("hu",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("it",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("ja",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("lv",a)}(),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.locale&&this.numeral.locale("nl-nl",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&(this.numeral.locale("nb-no",a),this.numeral.locale("nn-no",a),this.numeral.locale("no",a),this.numeral.locale("nb",a),this.numeral.locale("nn",a))}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pl",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mil",million:"milhões",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"R$"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pt-br",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("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.locale&&this.numeral.locale("ru-ua",a)}(),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.locale&&this.numeral.locale("ru",a)}(),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.locale&&this.numeral.locale("sk",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("th",a)}(),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.locale&&this.numeral.locale("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.locale&&this.numeral.locale("uk-ua",a)}(); \ No newline at end of file +(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="Edge",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,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")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):p>g&&g>=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):q>g&&g>=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(r>g&&g>=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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("[0-9\\s]"+e.abbreviations[b]+"$"),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},loadLocale:function(a,b){f[a]=b},isNaN:function(a){return"number"==typeof a&&isNaN(a)},includes:function(a,b){return-1!==a.indexOf(b)},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*g)/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,d){if(!a)return h.currentLocale;if(a=a.toLowerCase(),a&&!d){if(!f[a])throw new Error("Unknown locale : "+a);h.currentLocale=a}return(d||!f[a])&&c.loadLocale(a,d),b},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(this[a+"s"][b])throw new TypeError(b+" "+a+" already registered.");this[a+"s"][b]=c},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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a,b={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"]};"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","exponential",{regexps:{format:/(e\+|e-)/,unformat:/(e\+|e-)/},format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]},unformat:function(b){function c(b,c,d,e){var f=a._.correctionFactor(b,c),g=b*f*(c*f)/(f*f);return g}var d=b.includes("e+")?b.split("e+"):b.split("e-"),e=Number(d[0]),f=Number(d[1]);return f=b.includes("e-")?f*=-1:f,a._.reduce([e,Math.pow(10,f)],c,1)}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexps:{format:/(o)/},format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.numberToFormat(b,c,d),e+g}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","percentage",{regexps:{format:/(%)/,unformat:/(%)/},format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.numberToFormat(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e},unformat:function(b){return.01*a._.stringToNumber(b)}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.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)}})}(),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.locale&&this.numeral.locale("be-nl",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("bg",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("chs",a)}(),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.locale&&this.numeral.locale("cs",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mia",trillion:"b"},ordinal:function(a){return"."},currency:{symbol:"DKK"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("da-dk",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"CHF"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de-ch",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de",a)}(),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.locale&&this.numeral.locale("en-au",a)}(),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.locale&&this.numeral.locale("en-gb",a)}(),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:"R"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("en-za",a)}(),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.locale&&this.numeral.locale("es-es",a)}(),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.locale&&this.numeral.locale("es",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("et",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("fi",a)}(),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.locale&&this.numeral.locale("fr-ca",a)}(),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.locale&&this.numeral.locale("fr-ch",a)}(),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.locale&&this.numeral.locale("fr",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("hu",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("it",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("ja",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("lv",a)}(),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.locale&&this.numeral.locale("nl-nl",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&(this.numeral.locale("nb-no",a),this.numeral.locale("nn-no",a),this.numeral.locale("no",a),this.numeral.locale("nb",a),this.numeral.locale("nn",a))}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pl",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mil",million:"milhões",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"R$"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pt-br",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("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.locale&&this.numeral.locale("ru-ua",a)}(),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.locale&&this.numeral.locale("ru",a)}(),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.locale&&this.numeral.locale("sk",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("th",a)}(),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.locale&&this.numeral.locale("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.locale&&this.numeral.locale("uk-ua",a)}(); \ No newline at end of file diff --git a/min/numeral.min.js b/min/numeral.min.js index d1a67f65..5f2f94f3 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="Edge",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};b=function(d){var f,g,i;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(d.match(e[g].regexps.unformat)){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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,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")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):p>g&&g>=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):q>g&&g>=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(r>g&&g>=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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(e.abbreviations[b]+"$"),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},loadLocale:function(a,b){f[a]=b},isNaN:function(a){return"number"==typeof a&&isNaN(a)},includes:function(a,b){return-1!==a.indexOf(b)},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*g)/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,d){if(!a)return h.currentLocale;if(a=a.toLowerCase(),a&&!d){if(!f[a])throw new Error("Unknown locale : "+a);h.currentLocale=a}return(d||!f[a])&&c.loadLocale(a,d),b},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(this[a+"s"][b])throw new TypeError(b+" "+a+" already registered.");this[a+"s"][b]=c},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},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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a,b={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"]};"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(console.log("unformating",new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")),g){for(e=0;e<=b.suffixes.length;e++){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e),console.log("jflsekjf");break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e),console.log("gergsegserse");break}}g*=f||1}return console.log(d,g,f),g}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","exponential",{regexps:{format:/(e\+|e-)/},format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexps:{format:/(o)/},format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.numberToFormat(b,c,d),e+g}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","percentage",{regexps:{format:/(%)/},format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.numberToFormat(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","time",{regexps:{format:/(:)/},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)}})}(); \ No newline at end of file +(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="Edge",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,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")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):p>g&&g>=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):q>g&&g>=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(r>g&&g>=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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("[0-9\\s]"+e.abbreviations[b]+"$"),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},loadLocale:function(a,b){f[a]=b},isNaN:function(a){return"number"==typeof a&&isNaN(a)},includes:function(a,b){return-1!==a.indexOf(b)},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*g)/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,d){if(!a)return h.currentLocale;if(a=a.toLowerCase(),a&&!d){if(!f[a])throw new Error("Unknown locale : "+a);h.currentLocale=a}return(d||!f[a])&&c.loadLocale(a,d),b},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(this[a+"s"][b])throw new TypeError(b+" "+a+" already registered.");this[a+"s"][b]=c},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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a,b={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"]};"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","exponential",{regexps:{format:/(e\+|e-)/,unformat:/(e\+|e-)/},format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]},unformat:function(b){function c(b,c,d,e){var f=a._.correctionFactor(b,c),g=b*f*(c*f)/(f*f);return g}var d=b.includes("e+")?b.split("e+"):b.split("e-"),e=Number(d[0]),f=Number(d[1]);return f=b.includes("e-")?f*=-1:f,a._.reduce([e,Math.pow(10,f)],c,1)}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexps:{format:/(o)/},format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.numberToFormat(b,c,d),e+g}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","percentage",{regexps:{format:/(%)/,unformat:/(%)/},format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.numberToFormat(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e},unformat:function(b){return.01*a._.stringToNumber(b)}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.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)}})}(); \ No newline at end of file diff --git a/numeral-with-locales.js b/numeral-with-locales.js index 32c3691e..a0d32c83 100644 --- a/numeral-with-locales.js +++ b/numeral-with-locales.js @@ -7,7 +7,6 @@ */ (function() { - /************************************ Variables ************************************/ @@ -45,7 +44,8 @@ numeral = function(input) { var value, kind, - unformatFunction; + unformatFunction, + regexp; if (numeral.isNumeral(input)) { value = input.value(); @@ -60,7 +60,9 @@ value = null; } else { for (kind in formats) { - if (input.match(formats[kind].regexps.unformat)) { + 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; @@ -235,7 +237,7 @@ } for (abbreviation in abbreviations) { - regexp = new RegExp(locale.abbreviations[abbreviation] + '$'); + regexp = new RegExp('[0-9\\s]' + locale.abbreviations[abbreviation] + '$'); if (stringOriginal.match(regexp)) { value *= Math.pow(10, abbreviations[abbreviation]); @@ -479,6 +481,9 @@ value: function() { return this._value; }, + input: function() { + return this._input; + }, set: function(value) { this._value = Number(value); @@ -649,21 +654,16 @@ power, bytesMultiplier; - console.log('unformating', new RegExp('(' + decimal.suffixes.concat(binary.suffixes).join('|') + ')')); - if (value) { - for (power = 0; power <= decimal.suffixes.length; power++) { + for (power = decimal.suffixes.length - 1; power >= 0; power--) { if (numeral._.includes(string, decimal.suffixes[power])) { bytesMultiplier = Math.pow(decimal.base, power); - console.log('jflsekjf'); - break; } if (numeral._.includes(string, binary.suffixes[power])) { bytesMultiplier = Math.pow(binary.base, power); - console.log('gergsegserse'); break; } @@ -671,7 +671,6 @@ value *= (bytesMultiplier || 1); } - console.log(string, value, bytesMultiplier); return value; } @@ -763,7 +762,8 @@ numeral.register('format', 'exponential', { regexps: { - format: /(e\+|e-)/ + format: /(e\+|e-)/, + unformat: /(e\+|e-)/ }, format: function(value, format, roundingFunction) { var output, @@ -775,6 +775,21 @@ output = numeral._.numberToFormat(Number(parts[0]), format, roundingFunction); return output + 'e' + parts[1]; + }, + unformat: function(string) { + var parts = string.includes('e+') ? string.split('e+') : string.split('e-'), + value = Number(parts[0]), + power = Number(parts[1]); + + power = string.includes('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); } }); }()); @@ -836,7 +851,8 @@ numeral.register('format', 'percentage', { regexps: { - format: /(%)/ + format: /(%)/, + unformat: /(%)/ }, format: function(value, format, roundingFunction) { var space = numeral._.includes(format, ' %') ? ' ' : '', @@ -860,6 +876,9 @@ } return output; + }, + unformat: function(string) { + return numeral._.stringToNumber(string) * 0.01; } }); }()); @@ -883,7 +902,8 @@ numeral.register('format', 'time', { regexps: { - format: /(:)/ + format: /(:)/, + unformat: /(:)/ }, format: function(value, format, roundingFunction) { var hours = Math.floor(value / 60 / 60), @@ -891,6 +911,26 @@ 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/numeral.js b/numeral.js index 7f0ff641..14545b0a 100644 --- a/numeral.js +++ b/numeral.js @@ -7,7 +7,6 @@ */ (function() { - /************************************ Variables ************************************/ @@ -45,7 +44,8 @@ numeral = function(input) { var value, kind, - unformatFunction; + unformatFunction, + regexp; if (numeral.isNumeral(input)) { value = input.value(); @@ -60,7 +60,9 @@ value = null; } else { for (kind in formats) { - if (input.match(formats[kind].regexps.unformat)) { + 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; @@ -235,7 +237,7 @@ } for (abbreviation in abbreviations) { - regexp = new RegExp(locale.abbreviations[abbreviation] + '$'); + regexp = new RegExp('[0-9\\s]' + locale.abbreviations[abbreviation] + '$'); if (stringOriginal.match(regexp)) { value *= Math.pow(10, abbreviations[abbreviation]); @@ -479,6 +481,9 @@ value: function() { return this._value; }, + input: function() { + return this._input; + }, set: function(value) { this._value = Number(value); @@ -649,21 +654,16 @@ power, bytesMultiplier; - console.log('unformating', new RegExp('(' + decimal.suffixes.concat(binary.suffixes).join('|') + ')')); - if (value) { - for (power = 0; power <= decimal.suffixes.length; power++) { + for (power = decimal.suffixes.length - 1; power >= 0; power--) { if (numeral._.includes(string, decimal.suffixes[power])) { bytesMultiplier = Math.pow(decimal.base, power); - console.log('jflsekjf'); - break; } if (numeral._.includes(string, binary.suffixes[power])) { bytesMultiplier = Math.pow(binary.base, power); - console.log('gergsegserse'); break; } @@ -671,7 +671,6 @@ value *= (bytesMultiplier || 1); } - console.log(string, value, bytesMultiplier); return value; } @@ -763,7 +762,8 @@ numeral.register('format', 'exponential', { regexps: { - format: /(e\+|e-)/ + format: /(e\+|e-)/, + unformat: /(e\+|e-)/ }, format: function(value, format, roundingFunction) { var output, @@ -775,6 +775,21 @@ output = numeral._.numberToFormat(Number(parts[0]), format, roundingFunction); return output + 'e' + parts[1]; + }, + unformat: function(string) { + var parts = string.includes('e+') ? string.split('e+') : string.split('e-'), + value = Number(parts[0]), + power = Number(parts[1]); + + power = string.includes('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); } }); }()); @@ -836,7 +851,8 @@ numeral.register('format', 'percentage', { regexps: { - format: /(%)/ + format: /(%)/, + unformat: /(%)/ }, format: function(value, format, roundingFunction) { var space = numeral._.includes(format, ' %') ? ' ' : '', @@ -860,6 +876,9 @@ } return output; + }, + unformat: function(string) { + return numeral._.stringToNumber(string) * 0.01; } }); }()); @@ -883,7 +902,8 @@ numeral.register('format', 'time', { regexps: { - format: /(:)/ + format: /(:)/, + unformat: /(:)/ }, format: function(value, format, roundingFunction) { var hours = Math.floor(value / 60 / 60), @@ -891,6 +911,26 @@ 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/formats/exponential.js b/src/formats/exponential.js index 94420209..809ce1ad 100644 --- a/src/formats/exponential.js +++ b/src/formats/exponential.js @@ -17,7 +17,8 @@ numeral.register('format', 'exponential', { regexps: { - format: /(e\+|e-)/ + format: /(e\+|e-)/, + unformat: /(e\+|e-)/ }, format: function(value, format, roundingFunction) { var output, @@ -29,6 +30,21 @@ output = numeral._.numberToFormat(Number(parts[0]), format, roundingFunction); return output + 'e' + parts[1]; + }, + unformat: function(string) { + var parts = string.includes('e+') ? string.split('e+') : string.split('e-'), + value = Number(parts[0]), + power = Number(parts[1]); + + power = string.includes('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/percentage.js b/src/formats/percentage.js index a202ae78..56a81863 100644 --- a/src/formats/percentage.js +++ b/src/formats/percentage.js @@ -17,7 +17,8 @@ numeral.register('format', 'percentage', { regexps: { - format: /(%)/ + format: /(%)/, + unformat: /(%)/ }, format: function(value, format, roundingFunction) { var space = numeral._.includes(format, ' %') ? ' ' : '', @@ -41,6 +42,9 @@ } return output; + }, + unformat: function(string) { + return numeral._.stringToNumber(string) * 0.01; } }); }()); diff --git a/src/formats/time.js b/src/formats/time.js index 0583a227..d11cd0f9 100644 --- a/src/formats/time.js +++ b/src/formats/time.js @@ -17,7 +17,8 @@ numeral.register('format', 'time', { regexps: { - format: /(:)/ + format: /(:)/, + unformat: /(:)/ }, format: function(value, format, roundingFunction) { var hours = Math.floor(value / 60 / 60), @@ -25,6 +26,26 @@ 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/numeral.js b/src/numeral.js index ee0fb292..2a43c575 100644 --- a/src/numeral.js +++ b/src/numeral.js @@ -7,7 +7,6 @@ */ (function() { - /************************************ Variables ************************************/ @@ -45,7 +44,8 @@ numeral = function(input) { var value, kind, - unformatFunction; + unformatFunction, + regexp; if (numeral.isNumeral(input)) { value = input.value(); @@ -60,7 +60,9 @@ value = null; } else { for (kind in formats) { - if (input.match(formats[kind].regexps.unformat)) { + 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; @@ -235,7 +237,7 @@ } for (abbreviation in abbreviations) { - regexp = new RegExp(locale.abbreviations[abbreviation] + '$'); + regexp = new RegExp('[0-9\\s]' + locale.abbreviations[abbreviation] + '$'); if (stringOriginal.match(regexp)) { value *= Math.pow(10, abbreviations[abbreviation]); @@ -479,6 +481,9 @@ value: function() { return this._value; }, + input: function() { + return this._input; + }, set: function(value) { this._value = Number(value); diff --git a/tests/formats/currency.js b/tests/formats/currency.js index eaf25fde..ddedd99d 100644 --- a/tests/formats/currency.js +++ b/tests/formats/currency.js @@ -23,7 +23,6 @@ describe('Currency', function() { [-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)'], @@ -32,7 +31,6 @@ describe('Currency', function() { [-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'], @@ -47,4 +45,21 @@ describe('Currency', function() { 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 index 4b3ad458..45bbf28f 100644 --- a/tests/formats/exponential.js +++ b/tests/formats/exponential.js @@ -27,6 +27,21 @@ describe('Exponential', function() { 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 index 3493f44b..2de46b85 100644 --- a/tests/formats/ordinal.js +++ b/tests/formats/ordinal.js @@ -32,4 +32,19 @@ describe('Ordinal', function() { 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 index 4671c1fc..fd3ed118 100644 --- a/tests/formats/percentage.js +++ b/tests/formats/percentage.js @@ -26,4 +26,19 @@ describe('Percentage', function() { expect(numeral(tests[i][0]).format(tests[i][1])).to.equal(tests[i][2]); } }); + + it('should unformat to percentages', 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]); + } + }); }); diff --git a/tests/formats/time.js b/tests/formats/time.js index 254e0df0..3342a9e8 100644 --- a/tests/formats/time.js +++ b/tests/formats/time.js @@ -25,4 +25,18 @@ describe('Time', function() { 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]); + } + }); }); From 0de94be157a5eac3ff2d9af119568e61c69a50f4 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sat, 3 Dec 2016 22:01:04 -0800 Subject: [PATCH 104/150] all locale tests passing!!!! --- Gruntfile.js | 10 ++-- src/numeral.js | 4 +- tests/locales/be-nl.js | 2 +- tests/locales/bg.js | 2 +- tests/locales/chs.js | 2 +- tests/locales/cs.js | 2 +- tests/locales/da-dk.js | 2 +- tests/locales/de-ch.js | 2 +- tests/locales/de.js | 2 +- tests/locales/en-au.js | 2 +- tests/locales/en-gb.js | 2 +- tests/locales/en-za.js | 2 +- tests/locales/en.js | 2 +- tests/locales/es-es.js | 2 +- tests/locales/es.js | 2 +- tests/locales/et.js | 2 +- tests/locales/fi.js | 2 +- tests/locales/fr-ca.js | 2 +- tests/locales/fr-ch.js | 2 +- tests/locales/fr.js | 2 +- tests/locales/hu.js | 2 +- tests/locales/it.js | 2 +- tests/locales/ja.js | 2 +- tests/locales/lv.js | 2 +- tests/locales/nl-nl.js | 2 +- tests/locales/no.js | 2 +- tests/locales/pl.js | 2 +- tests/locales/pt-br.js | 2 +- tests/locales/pt-pt.js | 2 +- tests/locales/ru-ua.js | 2 +- tests/locales/ru.js | 2 +- tests/locales/sk.js | 2 +- tests/locales/th.js | 2 +- tests/locales/tr.js | 2 +- tests/locales/uk-ua.js | 2 +- tests/numeral/unformat.js | 109 -------------------------------------- 36 files changed, 39 insertions(+), 150 deletions(-) delete mode 100644 tests/numeral/unformat.js diff --git a/Gruntfile.js b/Gruntfile.js index f1524257..9d4ab088 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -27,8 +27,8 @@ module.exports = function(grunt) { mochaTest : { all: [ 'tests/numeral.js', - 'tests/formats/*.js' - // 'tests/locales/*.js' + 'tests/formats/*.js', + 'tests/locales/*.js' ] }, karma: { @@ -36,10 +36,10 @@ module.exports = function(grunt) { files: [ 'src/numeral.js', 'src/formats/*.js', - // 'src/locales/*.js', + 'src/locales/*.js', 'tests/numeral.js', - 'tests/formats/*.js' - // 'tests/locales/*.js' + 'tests/formats/*.js', + 'tests/locales/*.js' ], frameworks: [ 'mocha', diff --git a/src/numeral.js b/src/numeral.js index 2a43c575..6dcc567e 100644 --- a/src/numeral.js +++ b/src/numeral.js @@ -220,7 +220,6 @@ trillion: 12 }, abbreviation, - power, value, i, regexp; @@ -237,11 +236,10 @@ } for (abbreviation in abbreviations) { - regexp = new RegExp('[0-9\\s]' + locale.abbreviations[abbreviation] + '$'); + regexp = new RegExp('[^a-zA-Z]' + locale.abbreviations[abbreviation] + '(?:\\)|(\\' + locale.currency.symbol + ')?(?:\\))?)?$'); if (stringOriginal.match(regexp)) { value *= Math.pow(10, abbreviations[abbreviation]); - break; } } diff --git a/tests/locales/be-nl.js b/tests/locales/be-nl.js index 8951ce95..bbea7c73 100644 --- a/tests/locales/be-nl.js +++ b/tests/locales/be-nl.js @@ -95,7 +95,7 @@ describe('Locale: be-nl', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); } }); }); diff --git a/tests/locales/bg.js b/tests/locales/bg.js index f161b320..6bdf7afb 100644 --- a/tests/locales/bg.js +++ b/tests/locales/bg.js @@ -89,7 +89,7 @@ describe('Locale: bg', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); } }); }); diff --git a/tests/locales/chs.js b/tests/locales/chs.js index 10be70c0..efe3ac92 100644 --- a/tests/locales/chs.js +++ b/tests/locales/chs.js @@ -89,7 +89,7 @@ describe('Locale: chs', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); } }); }); diff --git a/tests/locales/cs.js b/tests/locales/cs.js index 1e1e7996..e2d2717d 100644 --- a/tests/locales/cs.js +++ b/tests/locales/cs.js @@ -90,7 +90,7 @@ describe('Locale: cs', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + 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 index b684788d..7cc3a079 100644 --- a/tests/locales/da-dk.js +++ b/tests/locales/da-dk.js @@ -89,7 +89,7 @@ describe('Locale: da-dk', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + 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 index 3c870228..7ca693e4 100644 --- a/tests/locales/de-ch.js +++ b/tests/locales/de-ch.js @@ -89,7 +89,7 @@ describe('Locale: de-ch', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); } }); }); diff --git a/tests/locales/de.js b/tests/locales/de.js index 234aef3a..d066550b 100644 --- a/tests/locales/de.js +++ b/tests/locales/de.js @@ -89,7 +89,7 @@ describe('Locale: de', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + 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 index 3c74ec05..8e269d3d 100644 --- a/tests/locales/en-au.js +++ b/tests/locales/en-au.js @@ -89,7 +89,7 @@ describe('Locale: en-au', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + 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 index 33453b7c..2fb9ccfb 100644 --- a/tests/locales/en-gb.js +++ b/tests/locales/en-gb.js @@ -89,7 +89,7 @@ describe('Locale: en-gb', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + 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 index efae64f3..ae0292d5 100644 --- a/tests/locales/en-za.js +++ b/tests/locales/en-za.js @@ -89,7 +89,7 @@ describe('Locale: en-za', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); } }); }); diff --git a/tests/locales/en.js b/tests/locales/en.js index 500c85e8..0f51bb46 100644 --- a/tests/locales/en.js +++ b/tests/locales/en.js @@ -78,7 +78,7 @@ describe('Locale: en', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + 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 index f6fe25cd..15209166 100644 --- a/tests/locales/es-es.js +++ b/tests/locales/es-es.js @@ -89,7 +89,7 @@ describe('Locale: es-es', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); } }); }); diff --git a/tests/locales/es.js b/tests/locales/es.js index 782039bd..19aa8f13 100644 --- a/tests/locales/es.js +++ b/tests/locales/es.js @@ -89,7 +89,7 @@ describe('Locale: es', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); } }); }); diff --git a/tests/locales/et.js b/tests/locales/et.js index 19ec7321..9e379594 100644 --- a/tests/locales/et.js +++ b/tests/locales/et.js @@ -89,7 +89,7 @@ describe('Locale: et', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); } }); }); diff --git a/tests/locales/fi.js b/tests/locales/fi.js index 0b976829..58a784e1 100644 --- a/tests/locales/fi.js +++ b/tests/locales/fi.js @@ -89,7 +89,7 @@ describe('Locale: fi', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + 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 index d1677847..4b02c196 100644 --- a/tests/locales/fr-ca.js +++ b/tests/locales/fr-ca.js @@ -89,7 +89,7 @@ describe('Locale: fr-ca', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + 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 index 7bba1b44..3a17f270 100644 --- a/tests/locales/fr-ch.js +++ b/tests/locales/fr-ch.js @@ -89,7 +89,7 @@ describe('Locale: fr-ch', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); } }); }); diff --git a/tests/locales/fr.js b/tests/locales/fr.js index f3bfb584..bc9fc0f9 100644 --- a/tests/locales/fr.js +++ b/tests/locales/fr.js @@ -89,7 +89,7 @@ describe('Locale: fr', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); } }); }); diff --git a/tests/locales/hu.js b/tests/locales/hu.js index 6716d2de..30ef8394 100644 --- a/tests/locales/hu.js +++ b/tests/locales/hu.js @@ -89,7 +89,7 @@ describe('Locale: hu', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); } }); }); diff --git a/tests/locales/it.js b/tests/locales/it.js index 2f59461b..4fbdb54c 100644 --- a/tests/locales/it.js +++ b/tests/locales/it.js @@ -89,7 +89,7 @@ describe('Locale: it', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); } }); }); diff --git a/tests/locales/ja.js b/tests/locales/ja.js index af5f4ee3..7b978560 100644 --- a/tests/locales/ja.js +++ b/tests/locales/ja.js @@ -89,7 +89,7 @@ describe('Locale: ja', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); } }); }); diff --git a/tests/locales/lv.js b/tests/locales/lv.js index 425e1340..5c69e5c5 100644 --- a/tests/locales/lv.js +++ b/tests/locales/lv.js @@ -89,7 +89,7 @@ describe('Locale: lv', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + 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 index bdf4c354..9c286c68 100644 --- a/tests/locales/nl-nl.js +++ b/tests/locales/nl-nl.js @@ -97,7 +97,7 @@ describe('Locale: nl-nl', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); } }); }); diff --git a/tests/locales/no.js b/tests/locales/no.js index e0cbcc31..022f9d5c 100644 --- a/tests/locales/no.js +++ b/tests/locales/no.js @@ -89,7 +89,7 @@ describe('Locale: no', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); } }); }); diff --git a/tests/locales/pl.js b/tests/locales/pl.js index 7bc705b6..069339bc 100644 --- a/tests/locales/pl.js +++ b/tests/locales/pl.js @@ -90,7 +90,7 @@ describe('Locale: pl', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + 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 index 57e91a8a..37d8682f 100644 --- a/tests/locales/pt-br.js +++ b/tests/locales/pt-br.js @@ -89,7 +89,7 @@ describe('Locale: pt-br', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + 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 index f0dd31db..c76c0a7f 100644 --- a/tests/locales/pt-pt.js +++ b/tests/locales/pt-pt.js @@ -89,7 +89,7 @@ describe('Locale: pt-pt', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + 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 index db5765f7..b1a22f5e 100644 --- a/tests/locales/ru-ua.js +++ b/tests/locales/ru-ua.js @@ -90,7 +90,7 @@ describe('Locale: ru-ua', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); } }); }); diff --git a/tests/locales/ru.js b/tests/locales/ru.js index f5a1b3fe..5f0ef1cb 100644 --- a/tests/locales/ru.js +++ b/tests/locales/ru.js @@ -90,7 +90,7 @@ describe('Locale: ru', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); } }); }); diff --git a/tests/locales/sk.js b/tests/locales/sk.js index a93e3c63..54d5eaf1 100644 --- a/tests/locales/sk.js +++ b/tests/locales/sk.js @@ -89,7 +89,7 @@ describe('Locale: sk', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); } }); }); diff --git a/tests/locales/th.js b/tests/locales/th.js index 078e6432..cbc641eb 100644 --- a/tests/locales/th.js +++ b/tests/locales/th.js @@ -89,7 +89,7 @@ describe('Locale: th', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); } }); }); diff --git a/tests/locales/tr.js b/tests/locales/tr.js index fb5741a7..ee475d21 100644 --- a/tests/locales/tr.js +++ b/tests/locales/tr.js @@ -89,7 +89,7 @@ describe('Locale: tr', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + 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 index 935a5a01..727cab5a 100644 --- a/tests/locales/uk-ua.js +++ b/tests/locales/uk-ua.js @@ -90,7 +90,7 @@ describe('Locale: uk-ua', function() { ]; for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); + expect(numeral(tests[i][0]).value()).to.equal(tests[i][1]); } }); }); diff --git a/tests/numeral/unformat.js b/tests/numeral/unformat.js deleted file mode 100644 index 5d17cb3d..00000000 --- a/tests/numeral/unformat.js +++ /dev/null @@ -1,109 +0,0 @@ -// Node -if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../src/numeral'); - var expect = require('chai').expect; -} - -describe('Unformat', function() { - beforeEach(function() { - numeral.zeroFormat('N/A'); - - numeral.nullFormat('N/A'); - }); - - after(function() { - numeral.reset(); - }); - - describe('Numbers', function() { - it('should unformat a number', function() { - var tests = [ - ['10,000.123', 10000.123], - ['(0.12345)', -0.12345], - ['((--0.12345))', 0.12345], - ['N/A', 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++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); - } - }); - }); - - describe('Currency', function() { - it('should unformat currency', function() { - var tests = [ - ['($1.23m)', -1230000], - ['$ 10,000.00', 10000] - ]; - - for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); - } - }); - }); - - describe('Bytes', function() { - it('should unformat bytes', function() { - var tests = [ - ['100B', 100], - ['3.154 TiB', 3467859674006], - ['3.154 TB', 3467859674006] - ]; - - for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); - } - }); - }); - - describe('Percentages', function() { - it('should unformat percentages', function() { - var tests = [ - ['-76%', -0.76] - ]; - - for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); - } - }); - }); - - describe('Time', function() { - it('should unformat time', function() { - var tests = [ - ['2:23:57', 8637] - ]; - - for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); - } - }); - }); - - describe('Exponential', function() { - it('should unformat exponential notation', function() { - var tests = [ - ['0e+0',0], - ['1e+0',1], - ['7.7e+1',77], - ['7.7e-3',0.0077], - ['7.712e+2',771.2], - ['-1.0008e+9',-1000800000], - ['1.08e-5',0.0000108] - ]; - - for (var i = 0; i < tests.length; i++) { - expect(numeral().unformat(tests[i][0])).to.equal(tests[i][1]); - } - }); - }); -}); From ca3e18700ae36097a4a60f916e452a1454383110 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sat, 3 Dec 2016 22:33:04 -0800 Subject: [PATCH 105/150] all locales to use register call --- README.md | 8 ++-- src/formats/bytes.js | 11 +---- src/formats/currency.js | 11 +---- src/formats/exponential.js | 11 +---- src/formats/ordinal.js | 2 +- src/formats/percentage.js | 11 +---- src/formats/time.js | 11 +---- src/locales/be-nl.js | 18 +++----- src/locales/bg.js | 15 ++----- src/locales/chs.js | 19 +++------ src/locales/cs.js | 15 ++----- src/locales/da-dk.js | 19 +++------ src/locales/de-ch.js | 21 ++++------ src/locales/de.js | 19 +++------ src/locales/en-au.js | 17 +++----- src/locales/en-gb.js | 19 +++------ src/locales/en-za.js | 15 ++----- src/locales/es-es.js | 15 ++----- src/locales/es.js | 19 +++------ src/locales/et.js | 17 +++----- src/locales/fi.js | 17 +++----- src/locales/fr-ca.js | 15 ++----- src/locales/fr-ch.js | 17 +++----- src/locales/fr.js | 19 +++------ src/locales/hu.js | 17 +++----- src/locales/it.js | 19 +++------ src/locales/ja.js | 15 ++----- src/locales/lv.js | 14 ++----- src/locales/nl-nl.js | 19 +++------ src/locales/no.js | 19 ++------- src/locales/pl.js | 19 +++------ src/locales/pt-br.js | 19 +++------ src/locales/pt-pt.js | 17 +++----- src/locales/ru-ua.js | 19 +++------ src/locales/ru.js | 15 ++----- src/locales/sk.js | 15 ++----- src/locales/th.js | 17 +++----- src/locales/tr.js | 63 +++++++++++++--------------- src/locales/uk-ua.js | 19 +++------ src/numeral.js | 2 + tests/locales/be-nl.js | 2 - tests/locales/bg.js | 2 - tests/locales/chs.js | 2 - tests/locales/cs.js | 2 - tests/locales/da-dk.js | 2 - tests/locales/de-ch.js | 2 - tests/locales/de.js | 2 - tests/locales/en-au.js | 2 - tests/locales/en-gb.js | 2 - tests/locales/en-za.js | 2 - tests/locales/en.js | 85 -------------------------------------- tests/locales/es-es.js | 2 - tests/locales/es.js | 2 - tests/locales/et.js | 2 - tests/locales/fi.js | 2 - tests/locales/fr-ca.js | 2 - tests/locales/fr-ch.js | 2 - tests/locales/fr.js | 2 - tests/locales/hu.js | 2 - tests/locales/it.js | 2 - tests/locales/ja.js | 2 - tests/locales/lv.js | 2 - tests/locales/nl-nl.js | 2 - tests/locales/no.js | 2 - tests/locales/pl.js | 2 - tests/locales/pt-br.js | 2 - tests/locales/pt-pt.js | 2 - tests/locales/ru-ua.js | 2 - tests/locales/ru.js | 2 - tests/locales/sk.js | 2 - tests/locales/th.js | 2 - tests/locales/tr.js | 2 - tests/locales/uk-ua.js | 2 - 73 files changed, 201 insertions(+), 617 deletions(-) delete mode 100644 tests/locales/en.js diff --git a/README.md b/README.md index 1c8b9cbf..7ec8e63a 100644 --- a/README.md +++ b/README.md @@ -49,13 +49,15 @@ See [the english unit tests](https://github.com/adamwdraper/Numeral-js/blob/mast ### 2.0.0 -Breaking change: 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 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: The `unformat` function has been removed `numeral().unformat(string)` and now happens on numeral init `numeral(string)` +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: Bytes are now formatted as: `b` (base 1000) and `ib` (base 1024) +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 diff --git a/src/formats/bytes.js b/src/formats/bytes.js index c3096073..96fa2e87 100644 --- a/src/formats/bytes.js +++ b/src/formats/bytes.js @@ -4,7 +4,7 @@ * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var numeral, + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'), decimal = { base: 1000, suffixes: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] @@ -14,15 +14,6 @@ suffixes: ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'] }; - // get numeral from environment - if (typeof window !== 'undefined' && this.numeral) { - // Browser - numeral = this.numeral; - } else if (typeof module !== 'undefined' && module.exports) { - // Node - numeral = require('../numeral'); - } - numeral.register('format', 'bytes', { regexps: { format: /([0\s]i?b)/, diff --git a/src/formats/currency.js b/src/formats/currency.js index 1825a8cd..d3af3bae 100644 --- a/src/formats/currency.js +++ b/src/formats/currency.js @@ -4,16 +4,7 @@ * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var numeral; - - // get numeral from environment - if (typeof window !== 'undefined' && this.numeral) { - // Browser - numeral = this.numeral; - } else if (typeof module !== 'undefined' && module.exports) { - // Node - numeral = require('../numeral'); - } + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); numeral.register('format', 'currency', { regexps: { diff --git a/src/formats/exponential.js b/src/formats/exponential.js index 809ce1ad..29cf0598 100644 --- a/src/formats/exponential.js +++ b/src/formats/exponential.js @@ -4,16 +4,7 @@ * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var numeral; - - // get numeral from environment - if (typeof window !== 'undefined' && this.numeral) { - // Browser - numeral = this.numeral; - } else if (typeof module !== 'undefined' && module.exports) { - // Node - numeral = require('../numeral'); - } + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); numeral.register('format', 'exponential', { regexps: { diff --git a/src/formats/ordinal.js b/src/formats/ordinal.js index 5167d68e..ba338353 100644 --- a/src/formats/ordinal.js +++ b/src/formats/ordinal.js @@ -4,7 +4,7 @@ * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var numeral; + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); // get numeral from environment if (typeof window !== 'undefined' && this.numeral) { diff --git a/src/formats/percentage.js b/src/formats/percentage.js index 56a81863..362e5269 100644 --- a/src/formats/percentage.js +++ b/src/formats/percentage.js @@ -4,16 +4,7 @@ * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var numeral; - - // get numeral from environment - if (typeof window !== 'undefined' && this.numeral) { - // Browser - numeral = this.numeral; - } else if (typeof module !== 'undefined' && module.exports) { - // Node - numeral = require('../numeral'); - } + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); numeral.register('format', 'percentage', { regexps: { diff --git a/src/formats/time.js b/src/formats/time.js index d11cd0f9..2eb2945f 100644 --- a/src/formats/time.js +++ b/src/formats/time.js @@ -4,16 +4,7 @@ * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var numeral; - - // get numeral from environment - if (typeof window !== 'undefined' && this.numeral) { - // Browser - numeral = this.numeral; - } else if (typeof module !== 'undefined' && module.exports) { - // Node - numeral = require('../numeral'); - } + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); numeral.register('format', 'time', { regexps: { diff --git a/src/locales/be-nl.js b/src/locales/be-nl.js index b5b2ca91..775f9d0d 100644 --- a/src/locales/be-nl.js +++ b/src/locales/be-nl.js @@ -1,10 +1,12 @@ -/* +/* * numeral.js locale configuration * locale : belgium-dutch (be-nl) * author : Dieter Luypaert : https://github.com/moeriki */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'be-nl', { delimiters: { thousands: ' ', decimal : ',' @@ -17,19 +19,11 @@ }, 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 = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('be-nl', locale); - } + }); }()); diff --git a/src/locales/bg.js b/src/locales/bg.js index 1f8ee92b..49a1e96a 100644 --- a/src/locales/bg.js +++ b/src/locales/bg.js @@ -4,7 +4,9 @@ * author : Don Vince : https://github.com/donvince/ */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'bg', { delimiters: { thousands: ' ', decimal: ',' @@ -29,14 +31,5 @@ currency: { symbol: 'лв' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('bg', locale); - } + }); }()); diff --git a/src/locales/chs.js b/src/locales/chs.js index ad03a279..71ce6b5d 100644 --- a/src/locales/chs.js +++ b/src/locales/chs.js @@ -1,10 +1,12 @@ -/* +/* * numeral.js locale configuration - * locale : simplified chinese + * locale : simplified chinese (chs) * author : badplum : https://github.com/badplum */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'chs', { delimiters: { thousands: ',', decimal: '.' @@ -21,14 +23,5 @@ currency: { symbol: '¥' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('chs', locale); - } + }); }()); diff --git a/src/locales/cs.js b/src/locales/cs.js index 9856fda8..5c66b274 100644 --- a/src/locales/cs.js +++ b/src/locales/cs.js @@ -4,7 +4,9 @@ * author : Anatoli Papirovski : https://github.com/apapirovski */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'cs', { delimiters: { thousands: ' ', decimal: ',' @@ -21,14 +23,5 @@ currency: { symbol: 'Kč' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('cs', locale); - } + }); }()); diff --git a/src/locales/da-dk.js b/src/locales/da-dk.js index 0f365609..1f07ef3c 100644 --- a/src/locales/da-dk.js +++ b/src/locales/da-dk.js @@ -1,10 +1,12 @@ -/* +/* * numeral.js locale configuration * locale : danish denmark (dk) * author : Michael Storgaard : https://github.com/mstorgaard */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'da-dk', { delimiters: { thousands: '.', decimal: ',' @@ -21,14 +23,5 @@ currency: { symbol: 'DKK' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('da-dk', locale); - } -}()); \ No newline at end of file + }); +}()); diff --git a/src/locales/de-ch.js b/src/locales/de-ch.js index 8b92d27f..89cdda66 100644 --- a/src/locales/de-ch.js +++ b/src/locales/de-ch.js @@ -1,10 +1,12 @@ -/* +/* * 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 () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'de-ch', { delimiters: { thousands: ' ', decimal: ',' @@ -21,14 +23,5 @@ currency: { symbol: 'CHF' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('de-ch', locale); - } -}()); \ No newline at end of file + }); +}()); diff --git a/src/locales/de.js b/src/locales/de.js index 848ffb51..c13c6e5e 100644 --- a/src/locales/de.js +++ b/src/locales/de.js @@ -1,10 +1,12 @@ -/* +/* * numeral.js locale configuration * locale : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium * author : Marco Krage : https://github.com/sinky */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'de', { delimiters: { thousands: ' ', decimal: ',' @@ -21,14 +23,5 @@ currency: { symbol: '€' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('de', locale); - } -}()); \ No newline at end of file + }); +}()); diff --git a/src/locales/en-au.js b/src/locales/en-au.js index cbb1fd0a..589eb472 100644 --- a/src/locales/en-au.js +++ b/src/locales/en-au.js @@ -1,10 +1,12 @@ -/* +/* * numeral.js locale configuration * locale : English Australia * author : Don Vince : https://github.com/donvince/ */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'en-au', { delimiters: { thousands: ',', decimal: '.' @@ -25,14 +27,5 @@ currency: { symbol: '$' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('en-au', locale); - } + }); }()); diff --git a/src/locales/en-gb.js b/src/locales/en-gb.js index eed6b41d..9f240635 100644 --- a/src/locales/en-gb.js +++ b/src/locales/en-gb.js @@ -1,10 +1,12 @@ -/* +/* * numeral.js locale configuration * locale : english united kingdom (uk) * author : Dan Ristic : https://github.com/dristic */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'en-gb', { delimiters: { thousands: ',', decimal: '.' @@ -25,14 +27,5 @@ currency: { symbol: '£' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('en-gb', locale); - } -}()); \ No newline at end of file + }); +}()); diff --git a/src/locales/en-za.js b/src/locales/en-za.js index 95c0a5cb..f4bf9238 100644 --- a/src/locales/en-za.js +++ b/src/locales/en-za.js @@ -4,7 +4,9 @@ * author : Etienne Boshoff : etienne@zailab.com */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'en-za', { delimiters: { thousands: ' ', decimal: ',' @@ -25,14 +27,5 @@ currency: { symbol: 'R' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('en-za', locale); - } + }); }()); diff --git a/src/locales/es-es.js b/src/locales/es-es.js index 143ac3cc..2d5cc2b8 100644 --- a/src/locales/es-es.js +++ b/src/locales/es-es.js @@ -4,7 +4,9 @@ * author : Hernan Garcia : https://github.com/hgarcia */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'es-es', { delimiters: { thousands: '.', decimal: ',' @@ -26,14 +28,5 @@ currency: { symbol: '€' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('es-es', locale); - } + }); }()); diff --git a/src/locales/es.js b/src/locales/es.js index 5059a310..fe69e41d 100644 --- a/src/locales/es.js +++ b/src/locales/es.js @@ -1,10 +1,12 @@ -/* +/* * numeral.js locale configuration * locale : spanish * author : Hernan Garcia : https://github.com/hgarcia */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'es', { delimiters: { thousands: '.', decimal: ',' @@ -19,21 +21,12 @@ var b = number % 10; return (b === 1 || b === 3) ? 'er' : (b === 2) ? 'do' : - (b === 7 || b === 0) ? 'mo' : + (b === 7 || b === 0) ? 'mo' : (b === 8) ? 'vo' : (b === 9) ? 'no' : 'to'; }, currency: { symbol: '$' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('es', locale); - } + }); }()); diff --git a/src/locales/et.js b/src/locales/et.js index 2cd953ea..aa79ff3c 100644 --- a/src/locales/et.js +++ b/src/locales/et.js @@ -1,4 +1,4 @@ -/* +/* * numeral.js locale configuration * locale : Estonian * author : Illimar Tambek : https://github.com/ragulka @@ -7,7 +7,9 @@ * from numbers with a space */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'et', { delimiters: { thousands: ' ', decimal: ',' @@ -24,14 +26,5 @@ currency: { symbol: '€' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('et', locale); - } + }); }()); diff --git a/src/locales/fi.js b/src/locales/fi.js index 482e79db..f6f0ddf6 100644 --- a/src/locales/fi.js +++ b/src/locales/fi.js @@ -1,10 +1,12 @@ -/* +/* * numeral.js locale configuration * locale : Finnish * author : Sami Saada : https://github.com/samitheberber */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'fi', { delimiters: { thousands: ' ', decimal: ',' @@ -21,14 +23,5 @@ currency: { symbol: '€' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('fi', locale); - } + }); }()); diff --git a/src/locales/fr-ca.js b/src/locales/fr-ca.js index 4a86e442..603ea8d4 100644 --- a/src/locales/fr-ca.js +++ b/src/locales/fr-ca.js @@ -4,7 +4,9 @@ * author : Léo Renaud-Allaire : https://github.com/renaudleo */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'fr-ca', { delimiters: { thousands: ' ', decimal: ',' @@ -21,14 +23,5 @@ currency: { symbol: '$' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('fr-ca', locale); - } + }); }()); diff --git a/src/locales/fr-ch.js b/src/locales/fr-ch.js index 71060a8b..faaf411a 100644 --- a/src/locales/fr-ch.js +++ b/src/locales/fr-ch.js @@ -1,10 +1,12 @@ -/* +/* * numeral.js locale configuration * locale : french (fr-ch) * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'fr-ch', { delimiters: { thousands: '\'', decimal: '.' @@ -21,14 +23,5 @@ currency: { symbol: 'CHF' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('fr-ch', locale); - } + }); }()); diff --git a/src/locales/fr.js b/src/locales/fr.js index 84225e9e..5ec90241 100644 --- a/src/locales/fr.js +++ b/src/locales/fr.js @@ -1,10 +1,12 @@ -/* +/* * numeral.js locale configuration * locale : french (fr) * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'fr', { delimiters: { thousands: ' ', decimal: ',' @@ -21,14 +23,5 @@ currency: { symbol: '€' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('fr', locale); - } -}()); \ No newline at end of file + }); +}()); diff --git a/src/locales/hu.js b/src/locales/hu.js index f14fedce..f9316004 100644 --- a/src/locales/hu.js +++ b/src/locales/hu.js @@ -4,7 +4,9 @@ * author : Peter Bakondy : https://github.com/pbakondy */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'hu', { delimiters: { thousands: ' ', decimal: ',' @@ -21,14 +23,5 @@ currency: { symbol: ' Ft' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('hu', locale); - } -}()); \ No newline at end of file + }); +}()); diff --git a/src/locales/it.js b/src/locales/it.js index 1d6e14e0..be176733 100644 --- a/src/locales/it.js +++ b/src/locales/it.js @@ -1,10 +1,12 @@ -/* +/* * numeral.js locale configuration * locale : italian Italy (it) * author : Giacomo Trombi : http://cinquepunti.it */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'it', { delimiters: { thousands: '.', decimal: ',' @@ -21,14 +23,5 @@ currency: { symbol: '€' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('it', locale); - } -}()); \ No newline at end of file + }); +}()); diff --git a/src/locales/ja.js b/src/locales/ja.js index 12445f78..c48c8a25 100644 --- a/src/locales/ja.js +++ b/src/locales/ja.js @@ -4,7 +4,9 @@ * author : teppeis : https://github.com/teppeis */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'ja', { delimiters: { thousands: ',', decimal: '.' @@ -21,14 +23,5 @@ currency: { symbol: '¥' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('ja', locale); - } + }); }()); diff --git a/src/locales/lv.js b/src/locales/lv.js index 2eca3b09..9addba81 100644 --- a/src/locales/lv.js +++ b/src/locales/lv.js @@ -4,7 +4,9 @@ * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'lv', { delimiters: { thousands: ' ', decimal: ',' @@ -21,13 +23,5 @@ currency: { symbol: '€' } - }; - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('lv', locale); - } + }); }()); diff --git a/src/locales/nl-nl.js b/src/locales/nl-nl.js index 96fca57e..fe4295de 100644 --- a/src/locales/nl-nl.js +++ b/src/locales/nl-nl.js @@ -1,10 +1,12 @@ -/* +/* * numeral.js locale configuration * locale : netherlands-dutch (nl-nl) * author : Dave Clayton : https://github.com/davedx */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'nl-nl', { delimiters: { thousands: '.', decimal : ',' @@ -22,14 +24,5 @@ currency: { symbol: '€ ' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('nl-nl', locale); - } -}()); \ No newline at end of file + }); +}()); diff --git a/src/locales/no.js b/src/locales/no.js index 70922d43..b9d764c8 100644 --- a/src/locales/no.js +++ b/src/locales/no.js @@ -4,7 +4,9 @@ * author : Ove Andersen : https://github.com/azzlack */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'no', { delimiters: { thousands: ' ', decimal: ',' @@ -21,18 +23,5 @@ currency: { symbol: 'kr' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('nb-no', locale); - this.numeral.locale('nn-no', locale); - this.numeral.locale('no', locale); - this.numeral.locale('nb', locale); - this.numeral.locale('nn', locale); - } + }); }()); diff --git a/src/locales/pl.js b/src/locales/pl.js index 665b0260..eac9c243 100644 --- a/src/locales/pl.js +++ b/src/locales/pl.js @@ -1,10 +1,12 @@ -/* +/* * numeral.js locale configuration * locale : polish (pl) * author : Dominik Bulaj : https://github.com/dominikbulaj */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'pl', { delimiters: { thousands: ' ', decimal: ',' @@ -21,14 +23,5 @@ currency: { symbol: 'PLN' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('pl', locale); - } -}()); \ No newline at end of file + }); +}()); diff --git a/src/locales/pt-br.js b/src/locales/pt-br.js index 390ac09e..6d7e22d1 100644 --- a/src/locales/pt-br.js +++ b/src/locales/pt-br.js @@ -1,10 +1,12 @@ -/* +/* * numeral.js locale configuration * locale : portuguese brazil (pt-br) * author : Ramiro Varandas Jr : https://github.com/ramirovjr */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'pt-br', { delimiters: { thousands: '.', decimal: ',' @@ -21,14 +23,5 @@ currency: { symbol: 'R$' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('pt-br', locale); - } -}()); \ No newline at end of file + }); +}()); diff --git a/src/locales/pt-pt.js b/src/locales/pt-pt.js index 3eba2813..cc9aaba3 100644 --- a/src/locales/pt-pt.js +++ b/src/locales/pt-pt.js @@ -1,10 +1,12 @@ -/* +/* * numeral.js locale configuration * locale : portuguese (pt-pt) * author : Diogo Resende : https://github.com/dresende */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'pt-pt', { delimiters: { thousands: ' ', decimal: ',' @@ -21,14 +23,5 @@ currency: { symbol: '€' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('pt-pt', locale); - } + }); }()); diff --git a/src/locales/ru-ua.js b/src/locales/ru-ua.js index 93d4f386..4809eb48 100644 --- a/src/locales/ru-ua.js +++ b/src/locales/ru-ua.js @@ -2,7 +2,9 @@ // locale : Russian for the Ukraine (ru-ua) // author : Anatoli Papirovski : https://github.com/apapirovski (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'ru-ua', { delimiters: { thousands: ' ', decimal: ',' @@ -14,22 +16,13 @@ trillion: 't' }, ordinal: function () { - // not ideal, but since in Russian it can taken on + // not ideal, but since in Russian 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 = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('ru-ua', locale); - } + }); }()); diff --git a/src/locales/ru.js b/src/locales/ru.js index afc9ee5c..85cfa0df 100644 --- a/src/locales/ru.js +++ b/src/locales/ru.js @@ -4,7 +4,9 @@ * author : Anatoli Papirovski : https://github.com/apapirovski */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'ru', { delimiters: { thousands: ' ', decimal: ',' @@ -24,14 +26,5 @@ currency: { symbol: 'руб.' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('ru', locale); - } + }); }()); diff --git a/src/locales/sk.js b/src/locales/sk.js index f0f0d3ba..2f3a7bdc 100644 --- a/src/locales/sk.js +++ b/src/locales/sk.js @@ -4,7 +4,9 @@ * author : Ahmed Al Hafoudh : http://www.freevision.sk */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'sk', { delimiters: { thousands: ' ', decimal: ',' @@ -21,14 +23,5 @@ currency: { symbol: '€' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('sk', locale); - } + }); }()); diff --git a/src/locales/th.js b/src/locales/th.js index 423cae15..30f01f6e 100644 --- a/src/locales/th.js +++ b/src/locales/th.js @@ -1,10 +1,12 @@ -/* +/* * numeral.js locale configuration * locale : thai (th) * author : Sathit Jittanupat : https://github.com/jojosati */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'th', { delimiters: { thousands: ',', decimal: '.' @@ -21,14 +23,5 @@ currency: { symbol: '฿' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('th', locale); - } + }); }()); diff --git a/src/locales/tr.js b/src/locales/tr.js index 4e06f196..1ed4fe13 100644 --- a/src/locales/tr.js +++ b/src/locales/tr.js @@ -1,10 +1,11 @@ -/* +/* * 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 () { - var suffixes = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'), + suffixes = { 1: '\'inci', 5: '\'inci', 8: '\'inci', @@ -28,40 +29,32 @@ 60: '\'ıncı', 90: '\'ıncı' - }, - locale = { - 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' + 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ı'; } - }; - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('tr', locale); - } + 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 index d1e8d042..50d99e84 100644 --- a/src/locales/uk-ua.js +++ b/src/locales/uk-ua.js @@ -2,7 +2,9 @@ // locale : Ukrainian for the Ukraine (uk-ua) // author : Michael Piefel : https://github.com/piefel (with help from Tetyana Kuzmenko) (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'uk-ua', { delimiters: { thousands: ' ', decimal: ',' @@ -14,22 +16,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 = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('uk-ua', locale); - } + }); }()); diff --git a/src/numeral.js b/src/numeral.js index 6dcc567e..75375358 100644 --- a/src/numeral.js +++ b/src/numeral.js @@ -428,6 +428,8 @@ }; numeral.register = function(type, name, format) { + name = name.toLowerCase(); + if (this[type + 's'][name]) { throw new TypeError(name + ' ' + type + ' already registered.'); } diff --git a/tests/locales/be-nl.js b/tests/locales/be-nl.js index bbea7c73..06aa7c99 100644 --- a/tests/locales/be-nl.js +++ b/tests/locales/be-nl.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: be-nl', function() { before(function() { - numeral.locale('be-nl', locale); - numeral.locale('be-nl'); }); diff --git a/tests/locales/bg.js b/tests/locales/bg.js index 6bdf7afb..7c1cbbb6 100644 --- a/tests/locales/bg.js +++ b/tests/locales/bg.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: bg', function() { before(function() { - numeral.locale('bg', locale); - numeral.locale('bg'); }); diff --git a/tests/locales/chs.js b/tests/locales/chs.js index efe3ac92..8f183c97 100644 --- a/tests/locales/chs.js +++ b/tests/locales/chs.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: chs', function() { before(function() { - numeral.locale('chs', locale); - numeral.locale('chs'); }); diff --git a/tests/locales/cs.js b/tests/locales/cs.js index e2d2717d..a9f26793 100644 --- a/tests/locales/cs.js +++ b/tests/locales/cs.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: cs', function() { before(function() { - numeral.locale('cs', locale); - numeral.locale('cs'); }); diff --git a/tests/locales/da-dk.js b/tests/locales/da-dk.js index 7cc3a079..98d7810f 100644 --- a/tests/locales/da-dk.js +++ b/tests/locales/da-dk.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: da-dk', function() { before(function() { - numeral.locale('da-dk', locale); - numeral.locale('da-dk'); }); diff --git a/tests/locales/de-ch.js b/tests/locales/de-ch.js index 7ca693e4..ffed80e0 100644 --- a/tests/locales/de-ch.js +++ b/tests/locales/de-ch.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: de-ch', function() { before(function() { - numeral.locale('de-ch', locale); - numeral.locale('de-ch'); }); diff --git a/tests/locales/de.js b/tests/locales/de.js index d066550b..542bad11 100644 --- a/tests/locales/de.js +++ b/tests/locales/de.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: de', function() { before(function() { - numeral.locale('de', locale); - numeral.locale('de'); }); diff --git a/tests/locales/en-au.js b/tests/locales/en-au.js index 8e269d3d..68c0220d 100644 --- a/tests/locales/en-au.js +++ b/tests/locales/en-au.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: en-au', function() { before(function() { - numeral.locale('en-au', locale); - numeral.locale('en-au'); }); diff --git a/tests/locales/en-gb.js b/tests/locales/en-gb.js index 2fb9ccfb..db4846fa 100644 --- a/tests/locales/en-gb.js +++ b/tests/locales/en-gb.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: en-gb', function() { before(function() { - numeral.locale('en-gb', locale); - numeral.locale('en-gb'); }); diff --git a/tests/locales/en-za.js b/tests/locales/en-za.js index ae0292d5..659ee265 100644 --- a/tests/locales/en-za.js +++ b/tests/locales/en-za.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: en-za', function() { before(function() { - numeral.locale('en-za', locale); - numeral.locale('en-za'); }); diff --git a/tests/locales/en.js b/tests/locales/en.js deleted file mode 100644 index 0f51bb46..00000000 --- a/tests/locales/en.js +++ /dev/null @@ -1,85 +0,0 @@ -// Node -if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../src/numeral'); - var expect = require('chai').expect; -} - -describe('Locale: en', function() { - - 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/es-es.js b/tests/locales/es-es.js index 15209166..2a621d2e 100644 --- a/tests/locales/es-es.js +++ b/tests/locales/es-es.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: es-es', function() { before(function() { - numeral.locale('es-es', locale); - numeral.locale('es-es'); }); diff --git a/tests/locales/es.js b/tests/locales/es.js index 19aa8f13..9eebd10b 100644 --- a/tests/locales/es.js +++ b/tests/locales/es.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: es', function() { before(function() { - numeral.locale('es', locale); - numeral.locale('es'); }); diff --git a/tests/locales/et.js b/tests/locales/et.js index 9e379594..4536be8b 100644 --- a/tests/locales/et.js +++ b/tests/locales/et.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: et', function() { before(function() { - numeral.locale('et', locale); - numeral.locale('et'); }); diff --git a/tests/locales/fi.js b/tests/locales/fi.js index 58a784e1..a1e045dd 100644 --- a/tests/locales/fi.js +++ b/tests/locales/fi.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: fi', function() { before(function() { - numeral.locale('fi', locale); - numeral.locale('fi'); }); diff --git a/tests/locales/fr-ca.js b/tests/locales/fr-ca.js index 4b02c196..a76c8362 100644 --- a/tests/locales/fr-ca.js +++ b/tests/locales/fr-ca.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: fr-ca', function() { before(function() { - numeral.locale('fr-ca', locale); - numeral.locale('fr-ca'); }); diff --git a/tests/locales/fr-ch.js b/tests/locales/fr-ch.js index 3a17f270..49efe3d9 100644 --- a/tests/locales/fr-ch.js +++ b/tests/locales/fr-ch.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: fr-ch', function() { before(function() { - numeral.locale('fr-ch', locale); - numeral.locale('fr-ch'); }); diff --git a/tests/locales/fr.js b/tests/locales/fr.js index bc9fc0f9..682c8939 100644 --- a/tests/locales/fr.js +++ b/tests/locales/fr.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: fr', function() { before(function() { - numeral.locale('fr', locale); - numeral.locale('fr'); }); diff --git a/tests/locales/hu.js b/tests/locales/hu.js index 30ef8394..0f536495 100644 --- a/tests/locales/hu.js +++ b/tests/locales/hu.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: hu', function() { before(function() { - numeral.locale('hu', locale); - numeral.locale('hu'); }); diff --git a/tests/locales/it.js b/tests/locales/it.js index 4fbdb54c..71ac3e77 100644 --- a/tests/locales/it.js +++ b/tests/locales/it.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: it', function() { before(function() { - numeral.locale('it', locale); - numeral.locale('it'); }); diff --git a/tests/locales/ja.js b/tests/locales/ja.js index 7b978560..fc42b386 100644 --- a/tests/locales/ja.js +++ b/tests/locales/ja.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: ja', function() { before(function() { - numeral.locale('ja', locale); - numeral.locale('ja'); }); diff --git a/tests/locales/lv.js b/tests/locales/lv.js index 5c69e5c5..f2fc608d 100644 --- a/tests/locales/lv.js +++ b/tests/locales/lv.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: lv', function() { before(function() { - numeral.locale('lv', locale); - numeral.locale('lv'); }); diff --git a/tests/locales/nl-nl.js b/tests/locales/nl-nl.js index 9c286c68..41d85fd7 100644 --- a/tests/locales/nl-nl.js +++ b/tests/locales/nl-nl.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: nl-nl', function() { before(function() { - numeral.locale('nl-nl', locale); - numeral.locale('nl-nl'); }); diff --git a/tests/locales/no.js b/tests/locales/no.js index 022f9d5c..46686a71 100644 --- a/tests/locales/no.js +++ b/tests/locales/no.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: no', function() { before(function() { - numeral.locale('no', locale); - numeral.locale('no'); }); diff --git a/tests/locales/pl.js b/tests/locales/pl.js index 069339bc..a72e34d8 100644 --- a/tests/locales/pl.js +++ b/tests/locales/pl.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: pl', function() { before(function() { - numeral.locale('pl', locale); - numeral.locale('pl'); }); diff --git a/tests/locales/pt-br.js b/tests/locales/pt-br.js index 37d8682f..f5197640 100644 --- a/tests/locales/pt-br.js +++ b/tests/locales/pt-br.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: pt-br', function() { before(function() { - numeral.locale('pt-br', locale); - numeral.locale('pt-br'); }); diff --git a/tests/locales/pt-pt.js b/tests/locales/pt-pt.js index c76c0a7f..330e6626 100644 --- a/tests/locales/pt-pt.js +++ b/tests/locales/pt-pt.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: pt-pt', function() { before(function() { - numeral.locale('pt-pt', locale); - numeral.locale('pt-pt'); }); diff --git a/tests/locales/ru-ua.js b/tests/locales/ru-ua.js index b1a22f5e..f6b3c833 100644 --- a/tests/locales/ru-ua.js +++ b/tests/locales/ru-ua.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: ru-ua', function() { before(function() { - numeral.locale('ru-ua', locale); - numeral.locale('ru-ua'); }); diff --git a/tests/locales/ru.js b/tests/locales/ru.js index 5f0ef1cb..cddf901e 100644 --- a/tests/locales/ru.js +++ b/tests/locales/ru.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: ru', function() { before(function() { - numeral.locale('ru', locale); - numeral.locale('ru'); }); diff --git a/tests/locales/sk.js b/tests/locales/sk.js index 54d5eaf1..c7f20edc 100644 --- a/tests/locales/sk.js +++ b/tests/locales/sk.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: sk', function() { before(function() { - numeral.locale('sk', locale); - numeral.locale('sk'); }); diff --git a/tests/locales/th.js b/tests/locales/th.js index cbc641eb..4f6c79ce 100644 --- a/tests/locales/th.js +++ b/tests/locales/th.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: th', function() { before(function() { - numeral.locale('th', locale); - numeral.locale('th'); }); diff --git a/tests/locales/tr.js b/tests/locales/tr.js index ee475d21..6b63a955 100644 --- a/tests/locales/tr.js +++ b/tests/locales/tr.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: tr', function() { before(function() { - numeral.locale('tr', locale); - numeral.locale('tr'); }); diff --git a/tests/locales/uk-ua.js b/tests/locales/uk-ua.js index 727cab5a..5a82a5a7 100644 --- a/tests/locales/uk-ua.js +++ b/tests/locales/uk-ua.js @@ -8,8 +8,6 @@ if (typeof module !== 'undefined' && module.exports) { describe('Locale: uk-ua', function() { before(function() { - numeral.locale('uk-ua', locale); - numeral.locale('uk-ua'); }); From 26efbab65facc530d942f2db7987433b2e905451 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sat, 3 Dec 2016 22:41:04 -0800 Subject: [PATCH 106/150] remove loading locale from locale function --- README.md | 2 ++ src/numeral.js | 22 +++------------------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 7ec8e63a..259bbb20 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,8 @@ Breaking change / Feature: All formats and locales are now loaded using `numeral 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) diff --git a/src/numeral.js b/src/numeral.js index 75375358..16b7224a 100644 --- a/src/numeral.js +++ b/src/numeral.js @@ -255,9 +255,6 @@ return value; }, - loadLocale: function (key, values) { - locales[key] = values; - }, isNaN: function(value) { return typeof value === 'number' && isNaN(value); }, @@ -366,28 +363,15 @@ // avaliable formats numeral.locales = locales; - // This function will load locales and then set the global locale. If + // 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, values) { + numeral.locale = function(key) { if (!key) { return options.currentLocale; } - // standardize to lowercase - key = key.toLowerCase(); - - if (key && !values) { - if (!locales[key]) { - throw new Error('Unknown locale : ' + key); - } - - options.currentLocale = key; - } - - if (values || !locales[key]) { - _.loadLocale(key, values); - } + options.currentLocale = key.toLowerCase(); return numeral; }; From 319b06261c45177f516df6c88ad78a26ae216c2d Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sat, 3 Dec 2016 22:46:00 -0800 Subject: [PATCH 107/150] build --- locales.js | 592 +++++++++------------------- min/locales.min.js | 2 +- min/locales/be-nl.min.js | 2 +- min/locales/bg.min.js | 2 +- min/locales/chs.min.js | 2 +- min/locales/cs.min.js | 2 +- min/locales/da-dk.min.js | 2 +- min/locales/de-ch.min.js | 2 +- min/locales/de.min.js | 2 +- min/locales/en-au.min.js | 2 +- min/locales/en-gb.min.js | 2 +- min/locales/en-za.min.js | 2 +- min/locales/es-ES.min.js | 1 - min/locales/es-es.min.js | 1 + min/locales/es.min.js | 2 +- min/locales/et.min.js | 2 +- min/locales/fi.min.js | 2 +- min/locales/fr-CA.min.js | 1 - min/locales/fr-ca.min.js | 1 + min/locales/fr-ch.min.js | 2 +- min/locales/fr.min.js | 2 +- min/locales/hu.min.js | 2 +- min/locales/it.min.js | 2 +- min/locales/ja.min.js | 2 +- min/locales/lv.min.js | 2 +- min/locales/nl-nl.min.js | 2 +- min/locales/no.min.js | 2 +- min/locales/pl.min.js | 2 +- min/locales/pt-br.min.js | 2 +- min/locales/pt-pt.min.js | 2 +- min/locales/ru-UA.min.js | 1 - min/locales/ru-ua.min.js | 1 + min/locales/ru.min.js | 2 +- min/locales/sk.min.js | 2 +- min/locales/th.min.js | 2 +- min/locales/tr.min.js | 2 +- min/locales/uk-UA.min.js | 1 - min/locales/uk-ua.min.js | 1 + min/numeral-with-locales.min.js | 2 +- min/numeral.min.js | 2 +- numeral-with-locales.js | 677 ++++++++++---------------------- numeral.js | 85 +--- tests/numeral/misc.js | 59 --- 43 files changed, 435 insertions(+), 1048 deletions(-) delete mode 100644 min/locales/es-ES.min.js create mode 100644 min/locales/es-es.min.js delete mode 100644 min/locales/fr-CA.min.js create mode 100644 min/locales/fr-ca.min.js delete mode 100644 min/locales/ru-UA.min.js create mode 100644 min/locales/ru-ua.min.js delete mode 100644 min/locales/uk-UA.min.js create mode 100644 min/locales/uk-ua.min.js delete mode 100644 tests/numeral/misc.js diff --git a/locales.js b/locales.js index dfea3008..76eb3a27 100644 --- a/locales.js +++ b/locales.js @@ -1,10 +1,12 @@ -/* +/* * numeral.js locale configuration * locale : belgium-dutch (be-nl) * author : Dieter Luypaert : https://github.com/moeriki */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'be-nl', { delimiters: { thousands: ' ', decimal : ',' @@ -17,21 +19,13 @@ }, 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 = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('be-nl', locale); - } + }); }()); /* @@ -40,7 +34,9 @@ * author : Don Vince : https://github.com/donvince/ */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'bg', { delimiters: { thousands: ' ', decimal: ',' @@ -65,25 +61,18 @@ currency: { symbol: 'лв' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('bg', locale); - } + }); }()); -/* +/* * numeral.js locale configuration - * locale : simplified chinese + * locale : simplified chinese (chs) * author : badplum : https://github.com/badplum */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'chs', { delimiters: { thousands: ',', decimal: '.' @@ -100,16 +89,7 @@ currency: { symbol: '¥' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('chs', locale); - } + }); }()); /* @@ -118,7 +98,9 @@ * author : Anatoli Papirovski : https://github.com/apapirovski */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'cs', { delimiters: { thousands: ' ', decimal: ',' @@ -135,25 +117,18 @@ currency: { symbol: 'Kč' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('cs', locale); - } + }); }()); -/* +/* * numeral.js locale configuration * locale : danish denmark (dk) * author : Michael Storgaard : https://github.com/mstorgaard */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'da-dk', { delimiters: { thousands: '.', decimal: ',' @@ -170,24 +145,18 @@ currency: { symbol: 'DKK' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('da-dk', locale); - } + }); }()); -/* + +/* * 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 () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'de-ch', { delimiters: { thousands: ' ', decimal: ',' @@ -204,24 +173,18 @@ currency: { symbol: 'CHF' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('de-ch', locale); - } + }); }()); -/* + +/* * numeral.js locale configuration * locale : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium * author : Marco Krage : https://github.com/sinky */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'de', { delimiters: { thousands: ' ', decimal: ',' @@ -238,24 +201,18 @@ currency: { symbol: '€' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('de', locale); - } + }); }()); -/* + +/* * numeral.js locale configuration * locale : English Australia * author : Don Vince : https://github.com/donvince/ */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'en-au', { delimiters: { thousands: ',', decimal: '.' @@ -276,25 +233,18 @@ currency: { symbol: '$' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('en-au', locale); - } + }); }()); -/* +/* * numeral.js locale configuration * locale : english united kingdom (uk) * author : Dan Ristic : https://github.com/dristic */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'en-gb', { delimiters: { thousands: ',', decimal: '.' @@ -315,24 +265,18 @@ currency: { symbol: '£' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('en-gb', locale); - } + }); }()); + /* * numeral.js locale configuration * locale : english south africa (uk) * author : Etienne Boshoff : etienne@zailab.com */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'en-za', { delimiters: { thousands: ' ', decimal: ',' @@ -353,16 +297,7 @@ currency: { symbol: 'R' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('en-za', locale); - } + }); }()); /* @@ -371,7 +306,9 @@ * author : Hernan Garcia : https://github.com/hgarcia */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'es-es', { delimiters: { thousands: '.', decimal: ',' @@ -393,25 +330,18 @@ currency: { symbol: '€' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('es-es', locale); - } + }); }()); -/* +/* * numeral.js locale configuration * locale : spanish * author : Hernan Garcia : https://github.com/hgarcia */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'es', { delimiters: { thousands: '.', decimal: ',' @@ -426,26 +356,17 @@ var b = number % 10; return (b === 1 || b === 3) ? 'er' : (b === 2) ? 'do' : - (b === 7 || b === 0) ? 'mo' : + (b === 7 || b === 0) ? 'mo' : (b === 8) ? 'vo' : (b === 9) ? 'no' : 'to'; }, currency: { symbol: '$' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('es', locale); - } + }); }()); -/* +/* * numeral.js locale configuration * locale : Estonian * author : Illimar Tambek : https://github.com/ragulka @@ -454,7 +375,9 @@ * from numbers with a space */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'et', { delimiters: { thousands: ' ', decimal: ',' @@ -471,25 +394,18 @@ currency: { symbol: '€' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('et', locale); - } + }); }()); -/* +/* * numeral.js locale configuration * locale : Finnish * author : Sami Saada : https://github.com/samitheberber */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'fi', { delimiters: { thousands: ' ', decimal: ',' @@ -506,16 +422,7 @@ currency: { symbol: '€' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('fi', locale); - } + }); }()); /* @@ -524,7 +431,9 @@ * author : Léo Renaud-Allaire : https://github.com/renaudleo */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'fr-ca', { delimiters: { thousands: ' ', decimal: ',' @@ -541,25 +450,18 @@ currency: { symbol: '$' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('fr-ca', locale); - } + }); }()); -/* +/* * numeral.js locale configuration * locale : french (fr-ch) * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'fr-ch', { delimiters: { thousands: '\'', decimal: '.' @@ -576,25 +478,18 @@ currency: { symbol: 'CHF' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('fr-ch', locale); - } + }); }()); -/* +/* * numeral.js locale configuration * locale : french (fr) * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'fr', { delimiters: { thousands: ' ', decimal: ',' @@ -611,24 +506,18 @@ currency: { symbol: '€' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('fr', locale); - } + }); }()); + /* * numeral.js locale configuration * locale : Hungarian (hu) * author : Peter Bakondy : https://github.com/pbakondy */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'hu', { delimiters: { thousands: ' ', decimal: ',' @@ -645,24 +534,18 @@ currency: { symbol: ' Ft' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('hu', locale); - } + }); }()); -/* + +/* * numeral.js locale configuration * locale : italian Italy (it) * author : Giacomo Trombi : http://cinquepunti.it */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'it', { delimiters: { thousands: '.', decimal: ',' @@ -679,24 +562,18 @@ currency: { symbol: '€' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('it', locale); - } + }); }()); + /* * numeral.js locale configuration * locale : japanese * author : teppeis : https://github.com/teppeis */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'ja', { delimiters: { thousands: ',', decimal: '.' @@ -713,16 +590,7 @@ currency: { symbol: '¥' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('ja', locale); - } + }); }()); /* @@ -731,7 +599,9 @@ * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'lv', { delimiters: { thousands: ' ', decimal: ',' @@ -748,24 +618,18 @@ currency: { symbol: '€' } - }; - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('lv', locale); - } + }); }()); -/* +/* * numeral.js locale configuration * locale : netherlands-dutch (nl-nl) * author : Dave Clayton : https://github.com/davedx */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'nl-nl', { delimiters: { thousands: '.', decimal : ',' @@ -783,24 +647,18 @@ currency: { symbol: '€ ' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('nl-nl', locale); - } + }); }()); + /* * numeral.js locale configuration * locale : norwegian (bokmål) * author : Ove Andersen : https://github.com/azzlack */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'no', { delimiters: { thousands: ' ', decimal: ',' @@ -817,29 +675,18 @@ currency: { symbol: 'kr' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('nb-no', locale); - this.numeral.locale('nn-no', locale); - this.numeral.locale('no', locale); - this.numeral.locale('nb', locale); - this.numeral.locale('nn', locale); - } + }); }()); -/* +/* * numeral.js locale configuration * locale : polish (pl) * author : Dominik Bulaj : https://github.com/dominikbulaj */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'pl', { delimiters: { thousands: ' ', decimal: ',' @@ -856,24 +703,18 @@ currency: { symbol: 'PLN' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('pl', locale); - } + }); }()); -/* + +/* * numeral.js locale configuration * locale : portuguese brazil (pt-br) * author : Ramiro Varandas Jr : https://github.com/ramirovjr */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'pt-br', { delimiters: { thousands: '.', decimal: ',' @@ -890,24 +731,18 @@ currency: { symbol: 'R$' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('pt-br', locale); - } + }); }()); -/* + +/* * numeral.js locale configuration * locale : portuguese (pt-pt) * author : Diogo Resende : https://github.com/dresende */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'pt-pt', { delimiters: { thousands: ' ', decimal: ',' @@ -924,23 +759,16 @@ currency: { symbol: '€' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('pt-pt', locale); - } + }); }()); // numeral.js locale configuration // locale : Russian for the Ukraine (ru-ua) // author : Anatoli Papirovski : https://github.com/apapirovski (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'ru-ua', { delimiters: { thousands: ' ', decimal: ',' @@ -952,24 +780,15 @@ trillion: 't' }, ordinal: function () { - // not ideal, but since in Russian it can taken on + // not ideal, but since in Russian 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 = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('ru-ua', locale); - } + }); }()); /* @@ -978,7 +797,9 @@ * author : Anatoli Papirovski : https://github.com/apapirovski */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'ru', { delimiters: { thousands: ' ', decimal: ',' @@ -998,16 +819,7 @@ currency: { symbol: 'руб.' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('ru', locale); - } + }); }()); /* @@ -1016,7 +828,9 @@ * author : Ahmed Al Hafoudh : http://www.freevision.sk */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'sk', { delimiters: { thousands: ' ', decimal: ',' @@ -1033,25 +847,18 @@ currency: { symbol: '€' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('sk', locale); - } + }); }()); -/* +/* * numeral.js locale configuration * locale : thai (th) * author : Sathit Jittanupat : https://github.com/jojosati */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'th', { delimiters: { thousands: ',', decimal: '.' @@ -1068,25 +875,17 @@ currency: { symbol: '฿' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('th', locale); - } + }); }()); -/* +/* * 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 () { - var suffixes = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'), + suffixes = { 1: '\'inci', 5: '\'inci', 8: '\'inci', @@ -1110,49 +909,43 @@ 60: '\'ıncı', 90: '\'ıncı' + }; + + numeral.register('locale', 'tr', { + delimiters: { + thousands: '.', + decimal: ',' }, - locale = { - 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' + abbreviations: { + thousand: 'bin', + million: 'milyon', + billion: 'milyar', + trillion: 'trilyon' + }, + ordinal: function (number) { + if (number === 0) { // special case for zero + return '\'ıncı'; } - }; - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('tr', locale); - } + var a = number % 10, + b = number % 100 - a, + c = number >= 100 ? 100 : null; + + return suffixes[a] || suffixes[b] || suffixes[c]; + }, + currency: { + symbol: '\u20BA' + } + }); }()); // 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 locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'uk-ua', { delimiters: { thousands: ' ', decimal: ',' @@ -1164,22 +957,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 = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('uk-ua', locale); - } + }); }()); diff --git a/min/locales.min.js b/min/locales.min.js index aa8e858f..b197fb7c 100644 --- a/min/locales.min.js +++ b/min/locales.min.js @@ -1 +1 @@ -!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.locale&&this.numeral.locale("be-nl",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("bg",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("chs",a)}(),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.locale&&this.numeral.locale("cs",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mia",trillion:"b"},ordinal:function(a){return"."},currency:{symbol:"DKK"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("da-dk",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"CHF"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de-ch",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de",a)}(),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.locale&&this.numeral.locale("en-au",a)}(),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.locale&&this.numeral.locale("en-gb",a)}(),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:"R"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("en-za",a)}(),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.locale&&this.numeral.locale("es-es",a)}(),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.locale&&this.numeral.locale("es",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("et",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("fi",a)}(),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.locale&&this.numeral.locale("fr-ca",a)}(),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.locale&&this.numeral.locale("fr-ch",a)}(),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.locale&&this.numeral.locale("fr",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("hu",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("it",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("ja",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("lv",a)}(),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.locale&&this.numeral.locale("nl-nl",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&(this.numeral.locale("nb-no",a),this.numeral.locale("nn-no",a),this.numeral.locale("no",a),this.numeral.locale("nb",a),this.numeral.locale("nn",a))}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pl",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mil",million:"milhões",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"R$"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pt-br",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("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.locale&&this.numeral.locale("ru-ua",a)}(),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.locale&&this.numeral.locale("ru",a)}(),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.locale&&this.numeral.locale("sk",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("th",a)}(),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.locale&&this.numeral.locale("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.locale&&this.numeral.locale("uk-ua",a)}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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&&1>=b||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","bg",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","chs",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","cs",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"Kč"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","de",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","et",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","fi",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","hu",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","it",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ja",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","lv",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","no",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","pl",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","pt-pt",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ru-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"₴"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ru",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн.",billion:"млрд.",trillion:"трлн."},ordinal:function(){return"."},currency:{symbol:"руб."}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","sk",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","th",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral"),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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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/be-nl.min.js b/min/locales/be-nl.min.js index 87291407..9aa339b3 100644 --- a/min/locales/be-nl.min.js +++ b/min/locales/be-nl.min.js @@ -1 +1 @@ -!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.locale&&this.numeral.locale("be-nl",a)}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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&&1>=b||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 index c46f1c6e..3cdf496b 100644 --- a/min/locales/bg.min.js +++ b/min/locales/bg.min.js @@ -1 +1 @@ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("bg",a)}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 index d529790e..77852335 100644 --- a/min/locales/chs.min.js +++ b/min/locales/chs.min.js @@ -1 +1 @@ -!function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("chs",a)}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 index 8021da66..c082260d 100644 --- a/min/locales/cs.min.js +++ b/min/locales/cs.min.js @@ -1 +1 @@ -!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.locale&&this.numeral.locale("cs",a)}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 index 6b7f5ab0..31755f7e 100644 --- a/min/locales/da-dk.min.js +++ b/min/locales/da-dk.min.js @@ -1 +1 @@ -!function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mia",trillion:"b"},ordinal:function(a){return"."},currency:{symbol:"DKK"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("da-dk",a)}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 index 0dfcb5ff..b65063a3 100644 --- a/min/locales/de-ch.min.js +++ b/min/locales/de-ch.min.js @@ -1 +1 @@ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"CHF"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de-ch",a)}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 index 7cae51bb..df96ef76 100644 --- a/min/locales/de.min.js +++ b/min/locales/de.min.js @@ -1 +1 @@ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de",a)}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 index 8ae0d458..8980711a 100644 --- a/min/locales/en-au.min.js +++ b/min/locales/en-au.min.js @@ -1 +1 @@ -!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.locale&&this.numeral.locale("en-au",a)}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 index 3f3acffc..17cc5774 100644 --- a/min/locales/en-gb.min.js +++ b/min/locales/en-gb.min.js @@ -1 +1 @@ -!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.locale&&this.numeral.locale("en-gb",a)}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 index 2f3f771c..c47301c1 100644 --- a/min/locales/en-za.min.js +++ b/min/locales/en-za.min.js @@ -1 +1 @@ -!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:"R"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("en-za",a)}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 deleted file mode 100644 index f47c2c4d..00000000 --- a/min/locales/es-ES.min.js +++ /dev/null @@ -1 +0,0 @@ -!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.locale&&this.numeral.locale("es-es",a)}(); \ 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..df96be94 --- /dev/null +++ b/min/locales/es-es.min.js @@ -0,0 +1 @@ +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 index e6a21a83..d061edc3 100644 --- a/min/locales/es.min.js +++ b/min/locales/es.min.js @@ -1 +1 @@ -!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.locale&&this.numeral.locale("es",a)}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 index 94fdcc9c..d9afa261 100644 --- a/min/locales/et.min.js +++ b/min/locales/et.min.js @@ -1 +1 @@ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("et",a)}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 index db07a409..b6baa24a 100644 --- a/min/locales/fi.min.js +++ b/min/locales/fi.min.js @@ -1 +1 @@ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("fi",a)}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 deleted file mode 100644 index f997402f..00000000 --- a/min/locales/fr-CA.min.js +++ /dev/null @@ -1 +0,0 @@ -!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.locale&&this.numeral.locale("fr-ca",a)}(); \ 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..70675254 --- /dev/null +++ b/min/locales/fr-ca.min.js @@ -0,0 +1 @@ +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 index 17076eee..e16245d7 100644 --- a/min/locales/fr-ch.min.js +++ b/min/locales/fr-ch.min.js @@ -1 +1 @@ -!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.locale&&this.numeral.locale("fr-ch",a)}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 index 0a427c1b..a2fbeb5b 100644 --- a/min/locales/fr.min.js +++ b/min/locales/fr.min.js @@ -1 +1 @@ -!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.locale&&this.numeral.locale("fr",a)}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 index 42fc9eba..fde493c5 100644 --- a/min/locales/hu.min.js +++ b/min/locales/hu.min.js @@ -1 +1 @@ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("hu",a)}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 index c8e57856..a1d0c19e 100644 --- a/min/locales/it.min.js +++ b/min/locales/it.min.js @@ -1 +1 @@ -!function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("it",a)}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 index 02878485..4f4f56ce 100644 --- a/min/locales/ja.min.js +++ b/min/locales/ja.min.js @@ -1 +1 @@ -!function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("ja",a)}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 index 0d28a73a..9a1f999c 100644 --- a/min/locales/lv.min.js +++ b/min/locales/lv.min.js @@ -1 +1 @@ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("lv",a)}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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-nl.min.js b/min/locales/nl-nl.min.js index cd1e7a7b..f701051a 100644 --- a/min/locales/nl-nl.min.js +++ b/min/locales/nl-nl.min.js @@ -1 +1 @@ -!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.locale&&this.numeral.locale("nl-nl",a)}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 index f6ed94e4..24c99ac0 100644 --- a/min/locales/no.min.js +++ b/min/locales/no.min.js @@ -1 +1 @@ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&(this.numeral.locale("nb-no",a),this.numeral.locale("nn-no",a),this.numeral.locale("no",a),this.numeral.locale("nb",a),this.numeral.locale("nn",a))}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 index 72c4addc..47348fca 100644 --- a/min/locales/pl.min.js +++ b/min/locales/pl.min.js @@ -1 +1 @@ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pl",a)}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 index b13dd7ea..ed2e152f 100644 --- a/min/locales/pt-br.min.js +++ b/min/locales/pt-br.min.js @@ -1 +1 @@ -!function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mil",million:"milhões",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"R$"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pt-br",a)}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 index 4d17163c..8104095b 100644 --- a/min/locales/pt-pt.min.js +++ b/min/locales/pt-pt.min.js @@ -1 +1 @@ -!function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pt-pt",a)}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 deleted file mode 100644 index daf31256..00000000 --- a/min/locales/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.locale&&this.numeral.locale("ru-ua",a)}(); \ 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..7da88866 --- /dev/null +++ b/min/locales/ru-ua.min.js @@ -0,0 +1 @@ +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 index 8659f04d..3679546f 100644 --- a/min/locales/ru.min.js +++ b/min/locales/ru.min.js @@ -1 +1 @@ -!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.locale&&this.numeral.locale("ru",a)}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 index 8e4dfc4d..adfcc5df 100644 --- a/min/locales/sk.min.js +++ b/min/locales/sk.min.js @@ -1 +1 @@ -!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.locale&&this.numeral.locale("sk",a)}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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/th.min.js b/min/locales/th.min.js index ebe80585..8a0508ae 100644 --- a/min/locales/th.min.js +++ b/min/locales/th.min.js @@ -1 +1 @@ -!function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("th",a)}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 index 9a668806..7dfc5167 100644 --- a/min/locales/tr.min.js +++ b/min/locales/tr.min.js @@ -1 +1 @@ -!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.locale&&this.numeral.locale("tr",b)}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral"),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 deleted file mode 100644 index 25f0b784..00000000 --- a/min/locales/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.locale&&this.numeral.locale("uk-ua",a)}(); \ 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..d0a1b346 --- /dev/null +++ b/min/locales/uk-ua.min.js @@ -0,0 +1 @@ +!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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/numeral-with-locales.min.js b/min/numeral-with-locales.min.js index 3353c4d4..ae6254e1 100644 --- a/min/numeral-with-locales.min.js +++ b/min/numeral-with-locales.min.js @@ -5,4 +5,4 @@ * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="Edge",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,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")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):p>g&&g>=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):q>g&&g>=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(r>g&&g>=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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("[0-9\\s]"+e.abbreviations[b]+"$"),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},loadLocale:function(a,b){f[a]=b},isNaN:function(a){return"number"==typeof a&&isNaN(a)},includes:function(a,b){return-1!==a.indexOf(b)},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*g)/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,d){if(!a)return h.currentLocale;if(a=a.toLowerCase(),a&&!d){if(!f[a])throw new Error("Unknown locale : "+a);h.currentLocale=a}return(d||!f[a])&&c.loadLocale(a,d),b},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(this[a+"s"][b])throw new TypeError(b+" "+a+" already registered.");this[a+"s"][b]=c},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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a,b={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"]};"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","exponential",{regexps:{format:/(e\+|e-)/,unformat:/(e\+|e-)/},format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]},unformat:function(b){function c(b,c,d,e){var f=a._.correctionFactor(b,c),g=b*f*(c*f)/(f*f);return g}var d=b.includes("e+")?b.split("e+"):b.split("e-"),e=Number(d[0]),f=Number(d[1]);return f=b.includes("e-")?f*=-1:f,a._.reduce([e,Math.pow(10,f)],c,1)}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexps:{format:/(o)/},format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.numberToFormat(b,c,d),e+g}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","percentage",{regexps:{format:/(%)/,unformat:/(%)/},format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.numberToFormat(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e},unformat:function(b){return.01*a._.stringToNumber(b)}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.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)}})}(),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.locale&&this.numeral.locale("be-nl",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("bg",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("chs",a)}(),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.locale&&this.numeral.locale("cs",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mia",trillion:"b"},ordinal:function(a){return"."},currency:{symbol:"DKK"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("da-dk",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"CHF"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de-ch",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("de",a)}(),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.locale&&this.numeral.locale("en-au",a)}(),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.locale&&this.numeral.locale("en-gb",a)}(),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:"R"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("en-za",a)}(),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.locale&&this.numeral.locale("es-es",a)}(),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.locale&&this.numeral.locale("es",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("et",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("fi",a)}(),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.locale&&this.numeral.locale("fr-ca",a)}(),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.locale&&this.numeral.locale("fr-ch",a)}(),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.locale&&this.numeral.locale("fr",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("hu",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("it",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("ja",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("lv",a)}(),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.locale&&this.numeral.locale("nl-nl",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&(this.numeral.locale("nb-no",a),this.numeral.locale("nn-no",a),this.numeral.locale("no",a),this.numeral.locale("nb",a),this.numeral.locale("nn",a))}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pl",a)}(),function(){var a={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mil",million:"milhões",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"R$"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("pt-br",a)}(),function(){var a={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("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.locale&&this.numeral.locale("ru-ua",a)}(),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.locale&&this.numeral.locale("ru",a)}(),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.locale&&this.numeral.locale("sk",a)}(),function(){var a={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&this.numeral&&this.numeral.locale&&this.numeral.locale("th",a)}(),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.locale&&this.numeral.locale("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.locale&&this.numeral.locale("uk-ua",a)}(); \ No newline at end of file +(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="Edge",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,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")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):p>g&&g>=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):q>g&&g>=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(r>g&&g>=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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)},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*g)/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(),b):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.");this[a+"s"][b]=c},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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral"),b={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","exponential",{regexps:{format:/(e\+|e-)/,unformat:/(e\+|e-)/},format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]},unformat:function(b){function c(b,c,d,e){var f=a._.correctionFactor(b,c),g=b*f*(c*f)/(f*f);return g}var d=b.includes("e+")?b.split("e+"):b.split("e-"),e=Number(d[0]),f=Number(d[1]);return f=b.includes("e-")?f*=-1:f,a._.reduce([e,Math.pow(10,f)],c,1)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexps:{format:/(o)/},format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.numberToFormat(b,c,d),e+g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","percentage",{regexps:{format:/(%)/,unformat:/(%)/},format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.numberToFormat(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e},unformat:function(b){return.01*a._.stringToNumber(b)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.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)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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&&1>=b||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","bg",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","chs",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","cs",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"Kč"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","de",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","et",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","fi",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","hu",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","it",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ja",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","lv",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","no",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","pl",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","pt-pt",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ru-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"₴"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ru",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн.",billion:"млрд.",trillion:"трлн."},ordinal:function(){return"."},currency:{symbol:"руб."}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","sk",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","th",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral"),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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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/numeral.min.js b/min/numeral.min.js index 5f2f94f3..7dff6343 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="Edge",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,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")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):p>g&&g>=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):q>g&&g>=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(r>g&&g>=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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("[0-9\\s]"+e.abbreviations[b]+"$"),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},loadLocale:function(a,b){f[a]=b},isNaN:function(a){return"number"==typeof a&&isNaN(a)},includes:function(a,b){return-1!==a.indexOf(b)},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*g)/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,d){if(!a)return h.currentLocale;if(a=a.toLowerCase(),a&&!d){if(!f[a])throw new Error("Unknown locale : "+a);h.currentLocale=a}return(d||!f[a])&&c.loadLocale(a,d),b},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(this[a+"s"][b])throw new TypeError(b+" "+a+" already registered.");this[a+"s"][b]=c},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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a,b={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"]};"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","exponential",{regexps:{format:/(e\+|e-)/,unformat:/(e\+|e-)/},format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]},unformat:function(b){function c(b,c,d,e){var f=a._.correctionFactor(b,c),g=b*f*(c*f)/(f*f);return g}var d=b.includes("e+")?b.split("e+"):b.split("e-"),e=Number(d[0]),f=Number(d[1]);return f=b.includes("e-")?f*=-1:f,a._.reduce([e,Math.pow(10,f)],c,1)}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexps:{format:/(o)/},format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.numberToFormat(b,c,d),e+g}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","percentage",{regexps:{format:/(%)/,unformat:/(%)/},format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.numberToFormat(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e},unformat:function(b){return.01*a._.stringToNumber(b)}})}(),function(){var a;"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.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)}})}(); \ No newline at end of file +(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="Edge",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,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")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):p>g&&g>=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):q>g&&g>=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(r>g&&g>=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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)},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*g)/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(),b):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.");this[a+"s"][b]=c},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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral"),b={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","exponential",{regexps:{format:/(e\+|e-)/,unformat:/(e\+|e-)/},format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]},unformat:function(b){function c(b,c,d,e){var f=a._.correctionFactor(b,c),g=b*f*(c*f)/(f*f);return g}var d=b.includes("e+")?b.split("e+"):b.split("e-"),e=Number(d[0]),f=Number(d[1]);return f=b.includes("e-")?f*=-1:f,a._.reduce([e,Math.pow(10,f)],c,1)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexps:{format:/(o)/},format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.numberToFormat(b,c,d),e+g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","percentage",{regexps:{format:/(%)/,unformat:/(%)/},format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.numberToFormat(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e},unformat:function(b){return.01*a._.stringToNumber(b)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.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)}})}(); \ No newline at end of file diff --git a/numeral-with-locales.js b/numeral-with-locales.js index a0d32c83..e4671c94 100644 --- a/numeral-with-locales.js +++ b/numeral-with-locales.js @@ -220,7 +220,6 @@ trillion: 12 }, abbreviation, - power, value, i, regexp; @@ -237,11 +236,10 @@ } for (abbreviation in abbreviations) { - regexp = new RegExp('[0-9\\s]' + locale.abbreviations[abbreviation] + '$'); + regexp = new RegExp('[^a-zA-Z]' + locale.abbreviations[abbreviation] + '(?:\\)|(\\' + locale.currency.symbol + ')?(?:\\))?)?$'); if (stringOriginal.match(regexp)) { value *= Math.pow(10, abbreviations[abbreviation]); - break; } } @@ -257,9 +255,6 @@ return value; }, - loadLocale: function (key, values) { - locales[key] = values; - }, isNaN: function(value) { return typeof value === 'number' && isNaN(value); }, @@ -368,28 +363,15 @@ // avaliable formats numeral.locales = locales; - // This function will load locales and then set the global locale. If + // 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, values) { + numeral.locale = function(key) { if (!key) { return options.currentLocale; } - // standardize to lowercase - key = key.toLowerCase(); - - if (key && !values) { - if (!locales[key]) { - throw new Error('Unknown locale : ' + key); - } - - options.currentLocale = key; - } - - if (values || !locales[key]) { - _.loadLocale(key, values); - } + options.currentLocale = key.toLowerCase(); return numeral; }; @@ -430,6 +412,8 @@ }; numeral.register = function(type, name, format) { + name = name.toLowerCase(); + if (this[type + 's'][name]) { throw new TypeError(name + ' ' + type + ' already registered.'); } @@ -595,7 +579,7 @@ * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var numeral, + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'), decimal = { base: 1000, suffixes: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] @@ -605,15 +589,6 @@ suffixes: ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'] }; - // get numeral from environment - if (typeof window !== 'undefined' && this.numeral) { - // Browser - numeral = this.numeral; - } else if (typeof module !== 'undefined' && module.exports) { - // Node - numeral = require('../numeral'); - } - numeral.register('format', 'bytes', { regexps: { format: /([0\s]i?b)/, @@ -683,16 +658,7 @@ * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var numeral; - - // get numeral from environment - if (typeof window !== 'undefined' && this.numeral) { - // Browser - numeral = this.numeral; - } else if (typeof module !== 'undefined' && module.exports) { - // Node - numeral = require('../numeral'); - } + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); numeral.register('format', 'currency', { regexps: { @@ -749,16 +715,7 @@ * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var numeral; - - // get numeral from environment - if (typeof window !== 'undefined' && this.numeral) { - // Browser - numeral = this.numeral; - } else if (typeof module !== 'undefined' && module.exports) { - // Node - numeral = require('../numeral'); - } + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); numeral.register('format', 'exponential', { regexps: { @@ -800,7 +757,7 @@ * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var numeral; + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); // get numeral from environment if (typeof window !== 'undefined' && this.numeral) { @@ -838,16 +795,7 @@ * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var numeral; - - // get numeral from environment - if (typeof window !== 'undefined' && this.numeral) { - // Browser - numeral = this.numeral; - } else if (typeof module !== 'undefined' && module.exports) { - // Node - numeral = require('../numeral'); - } + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); numeral.register('format', 'percentage', { regexps: { @@ -889,16 +837,7 @@ * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var numeral; - - // get numeral from environment - if (typeof window !== 'undefined' && this.numeral) { - // Browser - numeral = this.numeral; - } else if (typeof module !== 'undefined' && module.exports) { - // Node - numeral = require('../numeral'); - } + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); numeral.register('format', 'time', { regexps: { @@ -935,13 +874,15 @@ }); }()); -/* +/* * numeral.js locale configuration * locale : belgium-dutch (be-nl) * author : Dieter Luypaert : https://github.com/moeriki */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'be-nl', { delimiters: { thousands: ' ', decimal : ',' @@ -954,21 +895,13 @@ }, 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 = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('be-nl', locale); - } + }); }()); /* @@ -977,7 +910,9 @@ * author : Don Vince : https://github.com/donvince/ */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'bg', { delimiters: { thousands: ' ', decimal: ',' @@ -1002,25 +937,18 @@ currency: { symbol: 'лв' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('bg', locale); - } + }); }()); -/* +/* * numeral.js locale configuration - * locale : simplified chinese + * locale : simplified chinese (chs) * author : badplum : https://github.com/badplum */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'chs', { delimiters: { thousands: ',', decimal: '.' @@ -1037,16 +965,7 @@ currency: { symbol: '¥' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('chs', locale); - } + }); }()); /* @@ -1055,7 +974,9 @@ * author : Anatoli Papirovski : https://github.com/apapirovski */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'cs', { delimiters: { thousands: ' ', decimal: ',' @@ -1072,25 +993,18 @@ currency: { symbol: 'Kč' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('cs', locale); - } + }); }()); -/* +/* * numeral.js locale configuration * locale : danish denmark (dk) * author : Michael Storgaard : https://github.com/mstorgaard */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'da-dk', { delimiters: { thousands: '.', decimal: ',' @@ -1107,24 +1021,18 @@ currency: { symbol: 'DKK' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('da-dk', locale); - } + }); }()); -/* + +/* * 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 () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'de-ch', { delimiters: { thousands: ' ', decimal: ',' @@ -1141,24 +1049,18 @@ currency: { symbol: 'CHF' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('de-ch', locale); - } + }); }()); -/* + +/* * numeral.js locale configuration * locale : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium * author : Marco Krage : https://github.com/sinky */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'de', { delimiters: { thousands: ' ', decimal: ',' @@ -1175,24 +1077,18 @@ currency: { symbol: '€' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('de', locale); - } + }); }()); -/* + +/* * numeral.js locale configuration * locale : English Australia * author : Don Vince : https://github.com/donvince/ */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'en-au', { delimiters: { thousands: ',', decimal: '.' @@ -1213,25 +1109,18 @@ currency: { symbol: '$' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('en-au', locale); - } + }); }()); -/* +/* * numeral.js locale configuration * locale : english united kingdom (uk) * author : Dan Ristic : https://github.com/dristic */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'en-gb', { delimiters: { thousands: ',', decimal: '.' @@ -1252,24 +1141,18 @@ currency: { symbol: '£' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('en-gb', locale); - } + }); }()); + /* * numeral.js locale configuration * locale : english south africa (uk) * author : Etienne Boshoff : etienne@zailab.com */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'en-za', { delimiters: { thousands: ' ', decimal: ',' @@ -1290,16 +1173,7 @@ currency: { symbol: 'R' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('en-za', locale); - } + }); }()); /* @@ -1308,7 +1182,9 @@ * author : Hernan Garcia : https://github.com/hgarcia */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'es-es', { delimiters: { thousands: '.', decimal: ',' @@ -1330,25 +1206,18 @@ currency: { symbol: '€' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('es-es', locale); - } + }); }()); -/* +/* * numeral.js locale configuration * locale : spanish * author : Hernan Garcia : https://github.com/hgarcia */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'es', { delimiters: { thousands: '.', decimal: ',' @@ -1363,26 +1232,17 @@ var b = number % 10; return (b === 1 || b === 3) ? 'er' : (b === 2) ? 'do' : - (b === 7 || b === 0) ? 'mo' : + (b === 7 || b === 0) ? 'mo' : (b === 8) ? 'vo' : (b === 9) ? 'no' : 'to'; }, currency: { symbol: '$' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('es', locale); - } + }); }()); -/* +/* * numeral.js locale configuration * locale : Estonian * author : Illimar Tambek : https://github.com/ragulka @@ -1391,7 +1251,9 @@ * from numbers with a space */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'et', { delimiters: { thousands: ' ', decimal: ',' @@ -1408,25 +1270,18 @@ currency: { symbol: '€' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('et', locale); - } + }); }()); -/* +/* * numeral.js locale configuration * locale : Finnish * author : Sami Saada : https://github.com/samitheberber */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'fi', { delimiters: { thousands: ' ', decimal: ',' @@ -1443,16 +1298,7 @@ currency: { symbol: '€' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('fi', locale); - } + }); }()); /* @@ -1461,7 +1307,9 @@ * author : Léo Renaud-Allaire : https://github.com/renaudleo */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'fr-ca', { delimiters: { thousands: ' ', decimal: ',' @@ -1478,25 +1326,18 @@ currency: { symbol: '$' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('fr-ca', locale); - } + }); }()); -/* +/* * numeral.js locale configuration * locale : french (fr-ch) * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'fr-ch', { delimiters: { thousands: '\'', decimal: '.' @@ -1513,25 +1354,18 @@ currency: { symbol: 'CHF' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('fr-ch', locale); - } + }); }()); -/* +/* * numeral.js locale configuration * locale : french (fr) * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'fr', { delimiters: { thousands: ' ', decimal: ',' @@ -1548,24 +1382,18 @@ currency: { symbol: '€' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('fr', locale); - } + }); }()); + /* * numeral.js locale configuration * locale : Hungarian (hu) * author : Peter Bakondy : https://github.com/pbakondy */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'hu', { delimiters: { thousands: ' ', decimal: ',' @@ -1582,24 +1410,18 @@ currency: { symbol: ' Ft' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('hu', locale); - } + }); }()); -/* + +/* * numeral.js locale configuration * locale : italian Italy (it) * author : Giacomo Trombi : http://cinquepunti.it */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'it', { delimiters: { thousands: '.', decimal: ',' @@ -1616,24 +1438,18 @@ currency: { symbol: '€' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('it', locale); - } + }); }()); + /* * numeral.js locale configuration * locale : japanese * author : teppeis : https://github.com/teppeis */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'ja', { delimiters: { thousands: ',', decimal: '.' @@ -1650,16 +1466,7 @@ currency: { symbol: '¥' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('ja', locale); - } + }); }()); /* @@ -1668,7 +1475,9 @@ * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'lv', { delimiters: { thousands: ' ', decimal: ',' @@ -1685,24 +1494,18 @@ currency: { symbol: '€' } - }; - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('lv', locale); - } + }); }()); -/* +/* * numeral.js locale configuration * locale : netherlands-dutch (nl-nl) * author : Dave Clayton : https://github.com/davedx */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'nl-nl', { delimiters: { thousands: '.', decimal : ',' @@ -1720,24 +1523,18 @@ currency: { symbol: '€ ' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('nl-nl', locale); - } + }); }()); + /* * numeral.js locale configuration * locale : norwegian (bokmål) * author : Ove Andersen : https://github.com/azzlack */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'no', { delimiters: { thousands: ' ', decimal: ',' @@ -1754,29 +1551,18 @@ currency: { symbol: 'kr' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('nb-no', locale); - this.numeral.locale('nn-no', locale); - this.numeral.locale('no', locale); - this.numeral.locale('nb', locale); - this.numeral.locale('nn', locale); - } + }); }()); -/* +/* * numeral.js locale configuration * locale : polish (pl) * author : Dominik Bulaj : https://github.com/dominikbulaj */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'pl', { delimiters: { thousands: ' ', decimal: ',' @@ -1793,24 +1579,18 @@ currency: { symbol: 'PLN' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('pl', locale); - } + }); }()); -/* + +/* * numeral.js locale configuration * locale : portuguese brazil (pt-br) * author : Ramiro Varandas Jr : https://github.com/ramirovjr */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'pt-br', { delimiters: { thousands: '.', decimal: ',' @@ -1827,24 +1607,18 @@ currency: { symbol: 'R$' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('pt-br', locale); - } + }); }()); -/* + +/* * numeral.js locale configuration * locale : portuguese (pt-pt) * author : Diogo Resende : https://github.com/dresende */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'pt-pt', { delimiters: { thousands: ' ', decimal: ',' @@ -1861,23 +1635,16 @@ currency: { symbol: '€' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('pt-pt', locale); - } + }); }()); // numeral.js locale configuration // locale : Russian for the Ukraine (ru-ua) // author : Anatoli Papirovski : https://github.com/apapirovski (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'ru-ua', { delimiters: { thousands: ' ', decimal: ',' @@ -1889,24 +1656,15 @@ trillion: 't' }, ordinal: function () { - // not ideal, but since in Russian it can taken on + // not ideal, but since in Russian 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 = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('ru-ua', locale); - } + }); }()); /* @@ -1915,7 +1673,9 @@ * author : Anatoli Papirovski : https://github.com/apapirovski */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'ru', { delimiters: { thousands: ' ', decimal: ',' @@ -1935,16 +1695,7 @@ currency: { symbol: 'руб.' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('ru', locale); - } + }); }()); /* @@ -1953,7 +1704,9 @@ * author : Ahmed Al Hafoudh : http://www.freevision.sk */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'sk', { delimiters: { thousands: ' ', decimal: ',' @@ -1970,25 +1723,18 @@ currency: { symbol: '€' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('sk', locale); - } + }); }()); -/* +/* * numeral.js locale configuration * locale : thai (th) * author : Sathit Jittanupat : https://github.com/jojosati */ (function () { - var locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'th', { delimiters: { thousands: ',', decimal: '.' @@ -2005,25 +1751,17 @@ currency: { symbol: '฿' } - }; - - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('th', locale); - } + }); }()); -/* +/* * 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 () { - var suffixes = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'), + suffixes = { 1: '\'inci', 5: '\'inci', 8: '\'inci', @@ -2047,49 +1785,43 @@ 60: '\'ıncı', 90: '\'ıncı' - }, - locale = { - 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' + 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ı'; } - }; - // Node - if (typeof module !== 'undefined' && module.exports) { - module.exports = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('tr', locale); - } + var a = number % 10, + b = number % 100 - a, + c = number >= 100 ? 100 : null; + + return suffixes[a] || suffixes[b] || suffixes[c]; + }, + currency: { + symbol: '\u20BA' + } + }); }()); // 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 locale = { + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + + numeral.register('locale', 'uk-ua', { delimiters: { thousands: ' ', decimal: ',' @@ -2101,22 +1833,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 = locale; - } - // Browser - if (typeof window !== 'undefined' && this.numeral && this.numeral.locale) { - this.numeral.locale('uk-ua', locale); - } + }); }()); diff --git a/numeral.js b/numeral.js index 14545b0a..87192a91 100644 --- a/numeral.js +++ b/numeral.js @@ -220,7 +220,6 @@ trillion: 12 }, abbreviation, - power, value, i, regexp; @@ -237,11 +236,10 @@ } for (abbreviation in abbreviations) { - regexp = new RegExp('[0-9\\s]' + locale.abbreviations[abbreviation] + '$'); + regexp = new RegExp('[^a-zA-Z]' + locale.abbreviations[abbreviation] + '(?:\\)|(\\' + locale.currency.symbol + ')?(?:\\))?)?$'); if (stringOriginal.match(regexp)) { value *= Math.pow(10, abbreviations[abbreviation]); - break; } } @@ -257,9 +255,6 @@ return value; }, - loadLocale: function (key, values) { - locales[key] = values; - }, isNaN: function(value) { return typeof value === 'number' && isNaN(value); }, @@ -368,28 +363,15 @@ // avaliable formats numeral.locales = locales; - // This function will load locales and then set the global locale. If + // 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, values) { + numeral.locale = function(key) { if (!key) { return options.currentLocale; } - // standardize to lowercase - key = key.toLowerCase(); - - if (key && !values) { - if (!locales[key]) { - throw new Error('Unknown locale : ' + key); - } - - options.currentLocale = key; - } - - if (values || !locales[key]) { - _.loadLocale(key, values); - } + options.currentLocale = key.toLowerCase(); return numeral; }; @@ -430,6 +412,8 @@ }; numeral.register = function(type, name, format) { + name = name.toLowerCase(); + if (this[type + 's'][name]) { throw new TypeError(name + ' ' + type + ' already registered.'); } @@ -595,7 +579,7 @@ * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var numeral, + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'), decimal = { base: 1000, suffixes: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] @@ -605,15 +589,6 @@ suffixes: ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'] }; - // get numeral from environment - if (typeof window !== 'undefined' && this.numeral) { - // Browser - numeral = this.numeral; - } else if (typeof module !== 'undefined' && module.exports) { - // Node - numeral = require('../numeral'); - } - numeral.register('format', 'bytes', { regexps: { format: /([0\s]i?b)/, @@ -683,16 +658,7 @@ * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var numeral; - - // get numeral from environment - if (typeof window !== 'undefined' && this.numeral) { - // Browser - numeral = this.numeral; - } else if (typeof module !== 'undefined' && module.exports) { - // Node - numeral = require('../numeral'); - } + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); numeral.register('format', 'currency', { regexps: { @@ -749,16 +715,7 @@ * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var numeral; - - // get numeral from environment - if (typeof window !== 'undefined' && this.numeral) { - // Browser - numeral = this.numeral; - } else if (typeof module !== 'undefined' && module.exports) { - // Node - numeral = require('../numeral'); - } + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); numeral.register('format', 'exponential', { regexps: { @@ -800,7 +757,7 @@ * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var numeral; + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); // get numeral from environment if (typeof window !== 'undefined' && this.numeral) { @@ -838,16 +795,7 @@ * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var numeral; - - // get numeral from environment - if (typeof window !== 'undefined' && this.numeral) { - // Browser - numeral = this.numeral; - } else if (typeof module !== 'undefined' && module.exports) { - // Node - numeral = require('../numeral'); - } + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); numeral.register('format', 'percentage', { regexps: { @@ -889,16 +837,7 @@ * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var numeral; - - // get numeral from environment - if (typeof window !== 'undefined' && this.numeral) { - // Browser - numeral = this.numeral; - } else if (typeof module !== 'undefined' && module.exports) { - // Node - numeral = require('../numeral'); - } + var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); numeral.register('format', 'time', { regexps: { diff --git a/tests/numeral/misc.js b/tests/numeral/misc.js deleted file mode 100644 index 5bc4d622..00000000 --- a/tests/numeral/misc.js +++ /dev/null @@ -1,59 +0,0 @@ -// Node -if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../src/numeral'); - var expect = require('chai').expect; -} - -describe('Misc', function() { - after(function() { - numeral.reset(); - }); - - describe('Locale Data', function() { - it('should use custom locale data', function() { - var cOld = '$', - cNew = '!', - formatTestVal = function() { - return numeral('100').format('$0,0'); - }, - oldCurrencyVal = cOld + '100', - newCurrencyVal = cNew + '100'; - - expect(numeral.localeData().currency.symbol).to.equal(cOld); - expect(numeral.localeData('en').currency.symbol).to.equal(cOld); - - numeral.localeData().currency.symbol = cNew; - expect(numeral.localeData().currency.symbol).to.equal(cNew); - expect(formatTestVal()).to.equal(newCurrencyVal); - - numeral.localeData().currency.symbol = cOld; - expect(numeral.localeData().currency.symbol).to.equal('$'); - expect(formatTestVal()).to.equal(oldCurrencyVal); - - numeral.localeData('en').currency.symbol = cNew; - expect(numeral.localeData().currency.symbol).to.equal(cNew); - expect(formatTestVal()).to.equal(newCurrencyVal); - - numeral.localeData('en').currency.symbol = cOld; - expect(numeral.localeData().currency.symbol).to.equal(cOld); - expect(formatTestVal()).to.equal(oldCurrencyVal); - }); - - it('should key properly on custom locale data', function () { - var customformat = { - format: '0,0.00 $', - currency: { - symbol: '^' - } - }; - - numeral.locale('en-XX', customformat); - - expect(numeral.localeData('en-XX').format).to.equal('0,0.00 $'); - expect(numeral.localeData('en-XX').currency.symbol).to.equal('^'); - - expect(numeral.localeData('en-xx').format).to.equal('0,0.00 $'); - expect(numeral.localeData('en-xx').currency.symbol).to.equal('^'); - }); - }); -}); From c3f21bec04f1f79a93b527e91ab63db548d4649a Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sat, 3 Dec 2016 22:51:03 -0800 Subject: [PATCH 108/150] fix tests for ie --- min/numeral-with-locales.min.js | 2 +- min/numeral.min.js | 2 +- numeral-with-locales.js | 4 ++-- numeral.js | 4 ++-- src/formats/exponential.js | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/min/numeral-with-locales.min.js b/min/numeral-with-locales.min.js index ae6254e1..74856849 100644 --- a/min/numeral-with-locales.min.js +++ b/min/numeral-with-locales.min.js @@ -5,4 +5,4 @@ * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="Edge",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,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")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):p>g&&g>=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):q>g&&g>=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(r>g&&g>=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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)},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*g)/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(),b):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.");this[a+"s"][b]=c},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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral"),b={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","exponential",{regexps:{format:/(e\+|e-)/,unformat:/(e\+|e-)/},format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]},unformat:function(b){function c(b,c,d,e){var f=a._.correctionFactor(b,c),g=b*f*(c*f)/(f*f);return g}var d=b.includes("e+")?b.split("e+"):b.split("e-"),e=Number(d[0]),f=Number(d[1]);return f=b.includes("e-")?f*=-1:f,a._.reduce([e,Math.pow(10,f)],c,1)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexps:{format:/(o)/},format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.numberToFormat(b,c,d),e+g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","percentage",{regexps:{format:/(%)/,unformat:/(%)/},format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.numberToFormat(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e},unformat:function(b){return.01*a._.stringToNumber(b)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.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)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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&&1>=b||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","bg",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","chs",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","cs",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"Kč"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","de",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","et",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","fi",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","hu",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","it",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ja",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","lv",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","no",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","pl",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","pt-pt",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ru-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"₴"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ru",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн.",billion:"млрд.",trillion:"трлн."},ordinal:function(){return"."},currency:{symbol:"руб."}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","sk",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","th",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral"),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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","uk-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тис.",million:"млн",billion:"млрд",trillion:"блн"},ordinal:function(){return""},currency:{symbol:"₴"}})}(); \ No newline at end of file +(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="Edge",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,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")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):p>g&&g>=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):q>g&&g>=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(r>g&&g>=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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)},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*g)/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(),b):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.");this[a+"s"][b]=c},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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral"),b={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","exponential",{regexps:{format:/(e\+|e-)/,unformat:/(e\+|e-)/},format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]},unformat:function(b){function c(b,c,d,e){var f=a._.correctionFactor(b,c),g=b*f*(c*f)/(f*f);return g}var d=a._.includes(b,"e+")?b.split("e+"):b.split("e-"),e=Number(d[0]),f=Number(d[1]);return f=a._.includes(b,"e-")?f*=-1:f,a._.reduce([e,Math.pow(10,f)],c,1)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexps:{format:/(o)/},format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.numberToFormat(b,c,d),e+g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","percentage",{regexps:{format:/(%)/,unformat:/(%)/},format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.numberToFormat(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e},unformat:function(b){return.01*a._.stringToNumber(b)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.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)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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&&1>=b||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","bg",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","chs",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","cs",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"Kč"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","de",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","et",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","fi",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","hu",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","it",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ja",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","lv",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","no",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","pl",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","pt-pt",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ru-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"₴"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ru",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн.",billion:"млрд.",trillion:"трлн."},ordinal:function(){return"."},currency:{symbol:"руб."}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","sk",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","th",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral"),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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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/numeral.min.js b/min/numeral.min.js index 7dff6343..fa7c5108 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="Edge",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,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")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):p>g&&g>=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):q>g&&g>=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(r>g&&g>=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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)},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*g)/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(),b):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.");this[a+"s"][b]=c},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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral"),b={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","exponential",{regexps:{format:/(e\+|e-)/,unformat:/(e\+|e-)/},format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]},unformat:function(b){function c(b,c,d,e){var f=a._.correctionFactor(b,c),g=b*f*(c*f)/(f*f);return g}var d=b.includes("e+")?b.split("e+"):b.split("e-"),e=Number(d[0]),f=Number(d[1]);return f=b.includes("e-")?f*=-1:f,a._.reduce([e,Math.pow(10,f)],c,1)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexps:{format:/(o)/},format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.numberToFormat(b,c,d),e+g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","percentage",{regexps:{format:/(%)/,unformat:/(%)/},format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.numberToFormat(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e},unformat:function(b){return.01*a._.stringToNumber(b)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.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)}})}(); \ No newline at end of file +(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="Edge",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,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")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):p>g&&g>=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):q>g&&g>=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(r>g&&g>=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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)},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*g)/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(),b):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.");this[a+"s"][b]=c},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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral"),b={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","exponential",{regexps:{format:/(e\+|e-)/,unformat:/(e\+|e-)/},format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]},unformat:function(b){function c(b,c,d,e){var f=a._.correctionFactor(b,c),g=b*f*(c*f)/(f*f);return g}var d=a._.includes(b,"e+")?b.split("e+"):b.split("e-"),e=Number(d[0]),f=Number(d[1]);return f=a._.includes(b,"e-")?f*=-1:f,a._.reduce([e,Math.pow(10,f)],c,1)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexps:{format:/(o)/},format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.numberToFormat(b,c,d),e+g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","percentage",{regexps:{format:/(%)/,unformat:/(%)/},format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.numberToFormat(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e},unformat:function(b){return.01*a._.stringToNumber(b)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.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)}})}(); \ No newline at end of file diff --git a/numeral-with-locales.js b/numeral-with-locales.js index e4671c94..f9ab6ec1 100644 --- a/numeral-with-locales.js +++ b/numeral-with-locales.js @@ -734,11 +734,11 @@ return output + 'e' + parts[1]; }, unformat: function(string) { - var parts = string.includes('e+') ? string.split('e+') : string.split('e-'), + var parts = numeral._.includes(string, 'e+') ? string.split('e+') : string.split('e-'), value = Number(parts[0]), power = Number(parts[1]); - power = string.includes('e-') ? power *= -1 : power; + power = numeral._.includes(string, 'e-') ? power *= -1 : power; function cback(accum, curr, currI, O) { var corrFactor = numeral._.correctionFactor(accum, curr), diff --git a/numeral.js b/numeral.js index 87192a91..0b5a27a7 100644 --- a/numeral.js +++ b/numeral.js @@ -734,11 +734,11 @@ return output + 'e' + parts[1]; }, unformat: function(string) { - var parts = string.includes('e+') ? string.split('e+') : string.split('e-'), + var parts = numeral._.includes(string, 'e+') ? string.split('e+') : string.split('e-'), value = Number(parts[0]), power = Number(parts[1]); - power = string.includes('e-') ? power *= -1 : power; + power = numeral._.includes(string, 'e-') ? power *= -1 : power; function cback(accum, curr, currI, O) { var corrFactor = numeral._.correctionFactor(accum, curr), diff --git a/src/formats/exponential.js b/src/formats/exponential.js index 29cf0598..39ed8298 100644 --- a/src/formats/exponential.js +++ b/src/formats/exponential.js @@ -23,11 +23,11 @@ return output + 'e' + parts[1]; }, unformat: function(string) { - var parts = string.includes('e+') ? string.split('e+') : string.split('e-'), + var parts = numeral._.includes(string, 'e+') ? string.split('e+') : string.split('e-'), value = Number(parts[0]), power = Number(parts[1]); - power = string.includes('e-') ? power *= -1 : power; + power = numeral._.includes(string, 'e-') ? power *= -1 : power; function cback(accum, curr, currI, O) { var corrFactor = numeral._.correctionFactor(accum, curr), From 4ae647409e68a42d69e722abae65f5011402cbbb Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sat, 3 Dec 2016 23:06:00 -0800 Subject: [PATCH 109/150] add validate to new src --- min/numeral-with-locales.min.js | 2 +- min/numeral.min.js | 2 +- numeral-with-locales.js | 90 ++++ numeral.js | 90 ++++ src/numeral-old.js | 876 -------------------------------- src/numeral.js | 90 ++++ tests/numeral.js | 72 +++ tests/numeral/validate.js | 80 --- 8 files changed, 344 insertions(+), 958 deletions(-) delete mode 100644 src/numeral-old.js delete mode 100644 tests/numeral/validate.js diff --git a/min/numeral-with-locales.min.js b/min/numeral-with-locales.min.js index 74856849..f67274cc 100644 --- a/min/numeral-with-locales.min.js +++ b/min/numeral-with-locales.min.js @@ -5,4 +5,4 @@ * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="Edge",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,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")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):p>g&&g>=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):q>g&&g>=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(r>g&&g>=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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)},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*g)/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(),b):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.");this[a+"s"][b]=c},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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral"),b={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","exponential",{regexps:{format:/(e\+|e-)/,unformat:/(e\+|e-)/},format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]},unformat:function(b){function c(b,c,d,e){var f=a._.correctionFactor(b,c),g=b*f*(c*f)/(f*f);return g}var d=a._.includes(b,"e+")?b.split("e+"):b.split("e-"),e=Number(d[0]),f=Number(d[1]);return f=a._.includes(b,"e-")?f*=-1:f,a._.reduce([e,Math.pow(10,f)],c,1)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexps:{format:/(o)/},format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.numberToFormat(b,c,d),e+g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","percentage",{regexps:{format:/(%)/,unformat:/(%)/},format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.numberToFormat(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e},unformat:function(b){return.01*a._.stringToNumber(b)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.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)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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&&1>=b||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","bg",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","chs",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","cs",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"Kč"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","de",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","et",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","fi",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","hu",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","it",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ja",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","lv",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","no",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","pl",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","pt-pt",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ru-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"₴"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ru",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн.",billion:"млрд.",trillion:"трлн."},ordinal:function(){return"."},currency:{symbol:"руб."}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","sk",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","th",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral"),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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","uk-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тис.",million:"млн",billion:"млрд",trillion:"блн"},ordinal:function(){return""},currency:{symbol:"₴"}})}(); \ No newline at end of file +(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="Edge",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,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")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):p>g&&g>=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):q>g&&g>=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(r>g&&g>=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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)},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*g)/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(),b):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.");this[a+"s"][b]=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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral"),b={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","exponential",{regexps:{format:/(e\+|e-)/,unformat:/(e\+|e-)/},format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]},unformat:function(b){function c(b,c,d,e){var f=a._.correctionFactor(b,c),g=b*f*(c*f)/(f*f);return g}var d=a._.includes(b,"e+")?b.split("e+"):b.split("e-"),e=Number(d[0]),f=Number(d[1]);return f=a._.includes(b,"e-")?f*=-1:f,a._.reduce([e,Math.pow(10,f)],c,1)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexps:{format:/(o)/},format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.numberToFormat(b,c,d),e+g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","percentage",{regexps:{format:/(%)/,unformat:/(%)/},format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.numberToFormat(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e},unformat:function(b){return.01*a._.stringToNumber(b)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.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)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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&&1>=b||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","bg",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","chs",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","cs",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"Kč"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","de",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","et",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","fi",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","hu",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","it",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ja",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","lv",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","no",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","pl",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","pt-pt",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ru-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"₴"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ru",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн.",billion:"млрд.",trillion:"трлн."},ordinal:function(){return"."},currency:{symbol:"руб."}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","sk",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","th",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral"),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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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/numeral.min.js b/min/numeral.min.js index fa7c5108..65d7a734 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="Edge",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,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")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):p>g&&g>=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):q>g&&g>=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(r>g&&g>=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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)},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*g)/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(),b):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.");this[a+"s"][b]=c},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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral"),b={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","exponential",{regexps:{format:/(e\+|e-)/,unformat:/(e\+|e-)/},format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]},unformat:function(b){function c(b,c,d,e){var f=a._.correctionFactor(b,c),g=b*f*(c*f)/(f*f);return g}var d=a._.includes(b,"e+")?b.split("e+"):b.split("e-"),e=Number(d[0]),f=Number(d[1]);return f=a._.includes(b,"e-")?f*=-1:f,a._.reduce([e,Math.pow(10,f)],c,1)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexps:{format:/(o)/},format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.numberToFormat(b,c,d),e+g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","percentage",{regexps:{format:/(%)/,unformat:/(%)/},format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.numberToFormat(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e},unformat:function(b){return.01*a._.stringToNumber(b)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.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)}})}(); \ No newline at end of file +(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="Edge",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,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")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):p>g&&g>=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):q>g&&g>=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(r>g&&g>=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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)},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*g)/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(),b):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.");this[a+"s"][b]=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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral"),b={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","exponential",{regexps:{format:/(e\+|e-)/,unformat:/(e\+|e-)/},format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]},unformat:function(b){function c(b,c,d,e){var f=a._.correctionFactor(b,c),g=b*f*(c*f)/(f*f);return g}var d=a._.includes(b,"e+")?b.split("e+"):b.split("e-"),e=Number(d[0]),f=Number(d[1]);return f=a._.includes(b,"e-")?f*=-1:f,a._.reduce([e,Math.pow(10,f)],c,1)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexps:{format:/(o)/},format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.numberToFormat(b,c,d),e+g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","percentage",{regexps:{format:/(%)/,unformat:/(%)/},format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.numberToFormat(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e},unformat:function(b){return.01*a._.stringToNumber(b)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.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)}})}(); \ No newline at end of file diff --git a/numeral-with-locales.js b/numeral-with-locales.js index f9ab6ec1..a841bf5e 100644 --- a/numeral-with-locales.js +++ b/numeral-with-locales.js @@ -422,6 +422,96 @@ }; + 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 diff --git a/numeral.js b/numeral.js index 0b5a27a7..df35061d 100644 --- a/numeral.js +++ b/numeral.js @@ -422,6 +422,96 @@ }; + 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 diff --git a/src/numeral-old.js b/src/numeral-old.js deleted file mode 100644 index 00cc7086..00000000 --- a/src/numeral-old.js +++ /dev/null @@ -1,876 +0,0 @@ -/*! @preserve - * numeral.js - * version : Edge - * author : Adam Draper - * license : MIT - * http://adamwdraper.github.com/Numeral-js/ - */ - -(function() { - - /************************************ - Variables - ************************************/ - - var numeral, - VERSION = 'Edge', - // internal storage for locale config files - locales = {}, - defaults = { - currentLocale: 'en', - zeroFormat: null, - nullFormat: null, - defaultFormat: '0,0' - }, - options = { - currentLocale: defaults.currentLocale, - zeroFormat: defaults.zeroFormat, - nullFormat: defaults.nullFormat, - defaultFormat: defaults.defaultFormat - }, - config = { - bytes: { - 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'] - } - } - }; - - - /************************************ - 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, 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); - - //roundingFunction = (roundingFunction !== undefined ? roundingFunction : Math.round); - // Multiply up by precision, round accurately, then divide and use native toFixed(): - output = (roundingFunction(value * power) / power).toFixed(boundedPrecision); - - if (optionals > maxDecimals - boundedPrecision) { - optionalsRegExp = new RegExp('\\.?0{1,' + (optionals - (maxDecimals - boundedPrecision)) + '}$'); - output = output.replace(optionalsRegExp, ''); - } - - return output; - } - - /************************************ - Formatting - ************************************/ - - // determine what type of formatting we need to do - function formatNumeral(n, format, roundingFunction) { - var value = n._value, - kind, - output, - formatFunction; - - if (value === 0 && options.zeroFormat !== null) { - output = options.zeroFormat; - } else if (value === null && options.nullFormat !== null) { - output = options.nullFormat; - } else { - kind = format.match(/(\$|%|:|[ai]?b|o|e\+|e-)/); - - switch (kind ? kind[0] : '') { - case '$': - formatFunction = formatCurrency; - break; - case '%': - formatFunction = formatPercentage; - break; - case ':': - formatFunction = formatTime; - break; - case 'b': - case 'ib': - formatFunction = formatBytes; - break; - case 'o': - formatFunction = formatOrdinal; - break; - case 'e+': - case 'e-': - formatFunction = formatExponential; - break; - default: - formatFunction = formatNumber; - } - - output = formatFunction(value, format, roundingFunction); - } - - return output; - } - - function formatCurrency(value, format, roundingFunction) { - var symbolIndex = format.indexOf('$'), - openParenIndex = format.indexOf('('), - minusSignIndex = format.indexOf('-'), - space = format.includes(' $') || format.includes('$ ') ? ' ' : '', - spliceIndex, - output; - - // strip format of spaces and $ - format = format.replace(/\s?\$\s?/, ''); - - // format the number - output = formatNumber(value, format, roundingFunction); - - // position the symbol - if (symbolIndex <= 1) { - if (output.includes('(') || output.includes('-')) { - output = output.split(''); - - spliceIndex = symbolIndex < openParenIndex || symbolIndex < minusSignIndex ? 0 : 1; - - output.splice(spliceIndex, 0, locales[options.currentLocale].currency.symbol + space); - - output = output.join(''); - } else { - output = locales[options.currentLocale].currency.symbol + space + output; - } - } else { - if (output.includes(')')) { - output = output.split(''); - - output.splice(-1, 0, space + locales[options.currentLocale].currency.symbol); - - output = output.join(''); - } else { - output = output + space + locales[options.currentLocale].currency.symbol; - } - } - - return output; - } - - function formatPercentage(value, format, roundingFunction) { - var space = format.includes(' %') ? ' ' : '', - output; - - value = value * 100; - - // check for space before % - format = format.replace(/\s?\%/, ''); - - output = formatNumber(value, format, roundingFunction); - - if (output.includes(')')) { - output = output.split(''); - - output.splice(-1, 0, space + '%'); - - output = output.join(''); - } else { - output = output + space + '%'; - } - - return output; - } - - function formatBytes(value, format, roundingFunction) { - var output, - bytes = format.includes('ib') ? config.bytes.binary : config.bytes.decimal, - suffix = format.includes(' b') || format.includes(' 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 = formatNumber(value, format, roundingFunction); - - return output + suffix; - } - - function formatOrdinal(value, format, roundingFunction) { - var output, - ordinal = format.includes(' o') ? ' ' : ''; - - // check for space before - format = format.replace(/\s?o/, ''); - - ordinal += locales[options.currentLocale].ordinal(value); - - output = formatNumber(value, format, roundingFunction); - - return output + ordinal; - } - - function formatExponential(value, format, roundingFunction) { - var output, - exponential = typeof value === 'number' && !Number.isNaN(value) ? value.toExponential() : '0e+0', - parts = exponential.split('e'); - - format = format.replace(/e[\+|\-]{1}0/, ''); - - output = formatNumber(Number(parts[0]), format, roundingFunction); - - return output + 'e' + parts[1]; - } - - function formatTime(value) { - 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); - } - - function formatNumber(value, format, roundingFunction) { - var negP = false, - signed = false, - optDec = false, - abbr = '', - trillion = 1000000000000, - billion = 1000000000, - million = 1000000, - thousand = 1000, - abbrForce, // force abbreviation - abs, - min, - max, - power, - int, - precision, - thousands, - decimal = '', - neg = false; - - // 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 (format.includes('(')) { - negP = true; - format = format.slice(1, -1); - } else if (format.includes('+')) { - signed = true; - format = format.replace(/\+/g, ''); - } - - // see if abbreviation is wanted - if (format.includes('a')) { - abbrForce = format.match(/a(k|m|b|t)?/); - - abbrForce = abbrForce ? abbrForce[1] : false; - - // check for space before abbreviation - if (format.includes(' a')) { - abbr = ' '; - } - - format = format.replace(new RegExp(abbr + 'a[kmbt]?'), ''); - - if (abs >= trillion && !abbrForce || abbrForce === 't') { - // trillion - abbr += locales[options.currentLocale].abbreviations.trillion; - value = value / trillion; - } else if (abs < trillion && abs >= billion && !abbrForce || abbrForce === 'b') { - // billion - abbr += locales[options.currentLocale].abbreviations.billion; - value = value / billion; - } else if (abs < billion && abs >= million && !abbrForce || abbrForce === 'm') { - // million - abbr += locales[options.currentLocale].abbreviations.million; - value = value / million; - } else if (abs < million && abs >= thousand && !abbrForce || abbrForce === 'k') { - // thousand - abbr += locales[options.currentLocale].abbreviations.thousand; - value = value / thousand; - } - } - - - if (format.includes('[.]')) { - optDec = true; - format = format.replace('[.]', '.'); - } - - int = value.toString().split('.')[0]; - precision = format.split('.')[1]; - thousands = format.indexOf(','); - - if (precision) { - if (precision.includes('[')) { - precision = precision.replace(']', ''); - precision = precision.split('['); - decimal = toFixed(value, (precision[0].length + precision[1].length), roundingFunction, precision[1].length); - } else { - decimal = toFixed(value, precision.length, roundingFunction); - } - - int = decimal.split('.')[0]; - - if (decimal.includes('.')) { - decimal = locales[options.currentLocale].delimiters.decimal + decimal.split('.')[1]; - } else { - decimal = ''; - } - - if (optDec && Number(decimal.slice(1)) === 0) { - decimal = ''; - } - } else { - int = toFixed(value, null, roundingFunction); - } - - // format number - if (int.includes('-')) { - int = int.slice(1); - neg = true; - } - - if (thousands > -1) { - int = int.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + locales[options.currentLocale].delimiters.thousands); - } - - if (format.indexOf('.') === 0) { - int = ''; - } - - return (negP && neg ? '(' : '') + (!negP && neg ? '-' : '') + (!neg && signed ? '+' : '') + int + decimal + (abbr ? abbr : '') + (negP && neg ? ')' : ''); - } - - - /************************************ - Unformatting - ************************************/ - - // revert to number - function unformatNumeral(n, string) { - var stringOriginal = string, - thousandRegExp, - millionRegExp, - billionRegExp, - trillionRegExp, - bytesMultiplier = false, - power, - value; - - if (string.includes(':')) { - value = unformatTime(string); - } else if (string.includes('e+') || string.includes('e-')) { - value = unformatExponential(string); - } else { - if (string === options.zeroFormat || string === options.nullFormat) { - value = 0; - } else { - if (locales[options.currentLocale].delimiters.decimal !== '.') { - string = string.replace(/\./g, '').replace(locales[options.currentLocale].delimiters.decimal, '.'); - } - - // see if abbreviations are there so that we can multiply to the correct number - thousandRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.thousand + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); - millionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.million + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); - billionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.billion + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); - trillionRegExp = new RegExp('[^a-zA-Z]' + locales[options.currentLocale].abbreviations.trillion + '(?:\\)|(\\' + locales[options.currentLocale].currency.symbol + ')?(?:\\))?)?$'); - - // see if bytes are there so that we can multiply to the correct number - for (power = 1; power <= config.bytes.decimal.suffixes.length; power++) { - bytesMultiplier = ((string.includes(config.bytes.decimal.suffixes[power])) || (string.includes(config.bytes.binary.suffixes[power])))? Math.pow(1024, power) : false; - - if (bytesMultiplier) { - break; - } - } - - // do some math to create our number - value = bytesMultiplier ? bytesMultiplier : 1; - value *= stringOriginal.match(thousandRegExp) ? Math.pow(10, 3) : 1; - value *= stringOriginal.match(millionRegExp) ? Math.pow(10, 6) : 1; - value *= stringOriginal.match(billionRegExp) ? Math.pow(10, 9) : 1; - value *= stringOriginal.match(trillionRegExp) ? Math.pow(10, 12) : 1; - // check for percentage - value *= string.includes('%') ? 0.01 : 1; - // check for negative number - value *= (string.split('-').length + Math.min(string.split('(').length - 1, string.split(')').length - 1)) % 2 ? 1 : -1; - // remove non numbers - value *= Number(string.replace(/[^0-9\.]+/g, '')); - // round if we are talking about bytes - value = bytesMultiplier ? Math.ceil(value) : value; - } - } - - n._value = value; - - return n._value; - } - - 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); - } - - function unformatExponential(string) { - var parts = string.includes('e+') ? string.split('e+') : string.split('e-'), - value = Number(parts[0]), - power = Number(parts[1]); - - power = string.includes('e-') ? power *= -1 : power; - - function cback(accum, curr, currI, O) { - var corrFactor = correctionFactor(accum, curr), - num = (accum * corrFactor) * (curr * corrFactor) / (corrFactor * corrFactor); - return num; - } - - return [value, Math.pow(10, power)].reduce(cback, 1); - } - - /************************************ - Top Level Functions - ************************************/ - - numeral = function(input) { - if (numeral.isNumeral(input)) { - input = input.value(); - } else if (input === 0 || typeof input === 'undefined') { - input = 0; - } else if (input === null || Number.isNaN(input)) { - input = null; - } else if (!Number(input)) { - input = numeral.fn.unformat(input); - } else { - input = Number(input); - } - - return new Numeral(input); - }; - - // version number - numeral.version = VERSION; - - // compare numeral object - numeral.isNumeral = function(obj) { - return obj instanceof Numeral; - }; - - - // This function will load locales and then set the global locale. If - // no arguments are passed in, it will simply return the current global - // locale key. - numeral.locale = function(key, values) { - if (!key) { - return options.currentLocale; - } - - // standardize to lowercase - key = key.toLowerCase(); - - if (key && !values) { - if (!locales[key]) { - throw new Error('Unknown locale : ' + key); - } - - options.currentLocale = key; - } - - if (values || !locales[key]) { - loadLocale(key, values); - } - - return numeral; - }; - - // 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.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: '$' - } - }); - - 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.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; - }; - - /************************************ - Helpers - ************************************/ - - function loadLocale(key, values) { - locales[key] = values; - } - - // isNaN polyfill - Number.isNaN = Number.isNaN || function(value) { - return typeof value === 'number' && isNaN(value); - }; - - // String includes polyfill - String.prototype.includes = String.prototype.includes || function(search, start) { - return this.indexOf(search, start) !== -1; - }; - - // Production steps of ECMA-262, Edition 5, 15.4.4.21 - // Reference: http://es5.github.io/#x15.4.4.21 - if (!Array.prototype.reduce) { - Array.prototype.reduce = function(callback /*, initialValue*/) { - 'use strict'; - 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(this), len = t.length >>> 0, k = 0, value; - - if (arguments.length === 2) { - value = arguments[1]; - } 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. - */ - function multiplier(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. - */ - function correctionFactor() { - var args = Array.prototype.slice.call(arguments); - - return args.reduce(function(accum, next) { - var mn = multiplier(next); - return accum > mn ? accum : mn; - }, 1); - } - - - /************************************ - Numeral Prototype - ************************************/ - - - numeral.fn = Numeral.prototype = { - clone: function() { - return numeral(this); - }, - format: function (inputString, roundingFunction) { - return formatNumeral(this, - inputString ? inputString : options.defaultFormat, - roundingFunction !== undefined ? roundingFunction : Math.round - ); - }, - unformat: function (inputString) { - if (Object.prototype.toString.call(inputString) === '[object Number]') { - return inputString; - } - - return unformatNumeral(this, inputString ? inputString : options.defaultFormat); - }, - value: function() { - return this._value; - }, - valueOf: function() { - return this._value; - }, - 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 = [this._value, value].reduce(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 = [value].reduce(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 = [this._value, value].reduce(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 = [this._value, value].reduce(cback); - - return this; - }, - difference: function(value) { - return Math.abs(numeral(this._value).subtract(value).value()); - } - }; - - /************************************ - Exposing Numeral - ************************************/ - - // CommonJS module is defined - if (typeof module !== 'undefined' && module.exports) { - module.exports = numeral; - } - - /*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; - } - - /*global define:false */ - if (typeof define === 'function' && define.amd) { - define([], function() { - return numeral; - }); - } -}).call(this); diff --git a/src/numeral.js b/src/numeral.js index 16b7224a..b6798070 100644 --- a/src/numeral.js +++ b/src/numeral.js @@ -422,6 +422,96 @@ }; + 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 diff --git a/tests/numeral.js b/tests/numeral.js index ba2bae37..29aaa72b 100644 --- a/tests/numeral.js +++ b/tests/numeral.js @@ -225,6 +225,78 @@ describe('Numeral', function() { }); }); + 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() { diff --git a/tests/numeral/validate.js b/tests/numeral/validate.js deleted file mode 100644 index d72c71cb..00000000 --- a/tests/numeral/validate.js +++ /dev/null @@ -1,80 +0,0 @@ -// Node -if (typeof module !== 'undefined' && module.exports) { - var numeral = require('../../src/numeral'); - var expect = require('chai').expect; -} - -describe('Validate', function() { - var locale = 'en'; - - after(function() { - numeral.reset(); - }); - - 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]); - } - }); - }); -}); From 98baa312052afcc9417cab5cd2b345adb6d1d653 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Mon, 5 Dec 2016 22:03:27 -0800 Subject: [PATCH 110/150] upgrade version to 2.0.0 --- LICENSE | 4 ++-- README.md | 2 ++ bower.json | 2 +- component.json | 2 +- package.json | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/LICENSE b/LICENSE index f9810c58..e373f897 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2014 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 259bbb20..1a9db88d 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,8 @@ See [the english unit tests](https://github.com/adamwdraper/Numeral-js/blob/mast ### 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, {})` diff --git a/bower.json b/bower.json index 15b0498c..72ba72bf 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "numeral", "repo": "adamwdraper/Numeral-js", - "version": "1.5.6", + "version": "2.0.0", "description": "Format and manipulate numbers.", "keywords": [ "numeral", diff --git a/component.json b/component.json index 15b0498c..72ba72bf 100644 --- a/component.json +++ b/component.json @@ -1,7 +1,7 @@ { "name": "numeral", "repo": "adamwdraper/Numeral-js", - "version": "1.5.6", + "version": "2.0.0", "description": "Format and manipulate numbers.", "keywords": [ "numeral", diff --git a/package.json b/package.json index 079c21a1..0ada61f8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "numeral", - "version": "1.5.6", + "version": "2.0.0", "description": "Format and manipulate numbers.", "homepage": "http://numeraljs.com/", "author": { From 428a633bea9f6033429def6f9e60c8a3b0293370 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Mon, 5 Dec 2016 22:12:55 -0800 Subject: [PATCH 111/150] upgrade numeral version --- min/numeral-with-locales.min.js | 4 ++-- min/numeral.min.js | 4 ++-- numeral-with-locales.js | 4 ++-- numeral.js | 4 ++-- src/numeral.js | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/min/numeral-with-locales.min.js b/min/numeral-with-locales.min.js index f67274cc..6a138570 100644 --- a/min/numeral-with-locales.min.js +++ b/min/numeral-with-locales.min.js @@ -1,8 +1,8 @@ /*! @preserve * numeral.js - * version : Edge + * version : 2.0.0 * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="Edge",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,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")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):p>g&&g>=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):q>g&&g>=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(r>g&&g>=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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)},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*g)/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(),b):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.");this[a+"s"][b]=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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral"),b={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","exponential",{regexps:{format:/(e\+|e-)/,unformat:/(e\+|e-)/},format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]},unformat:function(b){function c(b,c,d,e){var f=a._.correctionFactor(b,c),g=b*f*(c*f)/(f*f);return g}var d=a._.includes(b,"e+")?b.split("e+"):b.split("e-"),e=Number(d[0]),f=Number(d[1]);return f=a._.includes(b,"e-")?f*=-1:f,a._.reduce([e,Math.pow(10,f)],c,1)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexps:{format:/(o)/},format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.numberToFormat(b,c,d),e+g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","percentage",{regexps:{format:/(%)/,unformat:/(%)/},format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.numberToFormat(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e},unformat:function(b){return.01*a._.stringToNumber(b)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.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)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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&&1>=b||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","bg",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","chs",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","cs",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"Kč"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","de",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","et",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","fi",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","hu",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","it",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ja",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","lv",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","no",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","pl",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","pt-pt",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ru-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"₴"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ru",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн.",billion:"млрд.",trillion:"трлн."},ordinal:function(){return"."},currency:{symbol:"руб."}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","sk",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","th",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral"),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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","uk-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тис.",million:"млн",billion:"млрд",trillion:"блн"},ordinal:function(){return""},currency:{symbol:"₴"}})}(); \ No newline at end of file +(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="2.0.0",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,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")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):p>g&&g>=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):q>g&&g>=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(r>g&&g>=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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)},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*g)/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(),b):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.");this[a+"s"][b]=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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral"),b={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","exponential",{regexps:{format:/(e\+|e-)/,unformat:/(e\+|e-)/},format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]},unformat:function(b){function c(b,c,d,e){var f=a._.correctionFactor(b,c),g=b*f*(c*f)/(f*f);return g}var d=a._.includes(b,"e+")?b.split("e+"):b.split("e-"),e=Number(d[0]),f=Number(d[1]);return f=a._.includes(b,"e-")?f*=-1:f,a._.reduce([e,Math.pow(10,f)],c,1)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexps:{format:/(o)/},format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.numberToFormat(b,c,d),e+g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","percentage",{regexps:{format:/(%)/,unformat:/(%)/},format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.numberToFormat(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e},unformat:function(b){return.01*a._.stringToNumber(b)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.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)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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&&1>=b||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","bg",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","chs",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","cs",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"Kč"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","de",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","et",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","fi",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","hu",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","it",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ja",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","lv",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","no",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","pl",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","pt-pt",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ru-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"₴"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ru",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн.",billion:"млрд.",trillion:"трлн."},ordinal:function(){return"."},currency:{symbol:"руб."}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","sk",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","th",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral"),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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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/numeral.min.js b/min/numeral.min.js index 65d7a734..1265a2bc 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -1,8 +1,8 @@ /*! @preserve * numeral.js - * version : Edge + * version : 2.0.0 * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="Edge",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,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")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):p>g&&g>=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):q>g&&g>=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(r>g&&g>=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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)},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*g)/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(),b):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.");this[a+"s"][b]=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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral"),b={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","exponential",{regexps:{format:/(e\+|e-)/,unformat:/(e\+|e-)/},format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]},unformat:function(b){function c(b,c,d,e){var f=a._.correctionFactor(b,c),g=b*f*(c*f)/(f*f);return g}var d=a._.includes(b,"e+")?b.split("e+"):b.split("e-"),e=Number(d[0]),f=Number(d[1]);return f=a._.includes(b,"e-")?f*=-1:f,a._.reduce([e,Math.pow(10,f)],c,1)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexps:{format:/(o)/},format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.numberToFormat(b,c,d),e+g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","percentage",{regexps:{format:/(%)/,unformat:/(%)/},format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.numberToFormat(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e},unformat:function(b){return.01*a._.stringToNumber(b)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.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)}})}(); \ No newline at end of file +(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="2.0.0",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,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")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):p>g&&g>=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):q>g&&g>=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(r>g&&g>=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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)},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*g)/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(),b):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.");this[a+"s"][b]=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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral"),b={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","exponential",{regexps:{format:/(e\+|e-)/,unformat:/(e\+|e-)/},format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]},unformat:function(b){function c(b,c,d,e){var f=a._.correctionFactor(b,c),g=b*f*(c*f)/(f*f);return g}var d=a._.includes(b,"e+")?b.split("e+"):b.split("e-"),e=Number(d[0]),f=Number(d[1]);return f=a._.includes(b,"e-")?f*=-1:f,a._.reduce([e,Math.pow(10,f)],c,1)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexps:{format:/(o)/},format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.numberToFormat(b,c,d),e+g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","percentage",{regexps:{format:/(%)/,unformat:/(%)/},format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.numberToFormat(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e},unformat:function(b){return.01*a._.stringToNumber(b)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.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)}})}(); \ No newline at end of file diff --git a/numeral-with-locales.js b/numeral-with-locales.js index a841bf5e..cba57a25 100644 --- a/numeral-with-locales.js +++ b/numeral-with-locales.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js - * version : Edge + * version : 2.0.0 * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ @@ -13,7 +13,7 @@ var numeral, _, - VERSION = 'Edge', + VERSION = '2.0.0', formats = {}, locales = {}, defaults = { diff --git a/numeral.js b/numeral.js index df35061d..c637dd23 100644 --- a/numeral.js +++ b/numeral.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js - * version : Edge + * version : 2.0.0 * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ @@ -13,7 +13,7 @@ var numeral, _, - VERSION = 'Edge', + VERSION = '2.0.0', formats = {}, locales = {}, defaults = { diff --git a/src/numeral.js b/src/numeral.js index b6798070..c0a052aa 100644 --- a/src/numeral.js +++ b/src/numeral.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js - * version : Edge + * version : 2.0.0 * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ @@ -13,7 +13,7 @@ var numeral, _, - VERSION = 'Edge', + VERSION = '2.0.0', formats = {}, locales = {}, defaults = { From e10af6b019706fe2ecdc4eba3a68a1909f8dc3b0 Mon Sep 17 00:00:00 2001 From: Spain Date: Wed, 7 Dec 2016 12:03:27 -0500 Subject: [PATCH 112/150] Fix bug with webpack/browserify/rollup (fixes #403) - Check for both `window` and `window.numeral` before using `window.numeral` (rather than `require('numeral')` Closes #402 Closes #403 --- locales.js | 64 +++++++++++++-------------- min/locales.min.js | 2 +- min/locales/be-nl.min.js | 2 +- min/locales/bg.min.js | 2 +- min/locales/chs.min.js | 2 +- min/locales/cs.min.js | 2 +- min/locales/da-dk.min.js | 2 +- min/locales/de-ch.min.js | 2 +- min/locales/de.min.js | 2 +- min/locales/en-au.min.js | 2 +- min/locales/en-gb.min.js | 2 +- min/locales/en-za.min.js | 2 +- min/locales/es-es.min.js | 2 +- min/locales/es.min.js | 2 +- min/locales/et.min.js | 2 +- min/locales/fi.min.js | 2 +- min/locales/fr-ca.min.js | 2 +- min/locales/fr-ch.min.js | 2 +- min/locales/fr.min.js | 2 +- min/locales/hu.min.js | 2 +- min/locales/it.min.js | 2 +- min/locales/ja.min.js | 2 +- min/locales/lv.min.js | 2 +- min/locales/nl-nl.min.js | 2 +- min/locales/no.min.js | 2 +- min/locales/pl.min.js | 2 +- min/locales/pt-br.min.js | 2 +- min/locales/pt-pt.min.js | 2 +- min/locales/ru-ua.min.js | 2 +- min/locales/ru.min.js | 2 +- min/locales/sk.min.js | 2 +- min/locales/th.min.js | 2 +- min/locales/tr.min.js | 2 +- min/locales/uk-ua.min.js | 2 +- min/numeral-with-locales.min.js | 2 +- min/numeral.min.js | 2 +- numeral-with-locales.js | 76 ++++++++++++++++----------------- numeral.js | 12 +++--- src/formats/bytes.js | 2 +- src/formats/currency.js | 2 +- src/formats/exponential.js | 2 +- src/formats/ordinal.js | 2 +- src/formats/percentage.js | 2 +- src/formats/time.js | 2 +- src/locales/be-nl.js | 2 +- src/locales/bg.js | 2 +- src/locales/chs.js | 2 +- src/locales/cs.js | 2 +- src/locales/da-dk.js | 2 +- src/locales/de-ch.js | 2 +- src/locales/de.js | 2 +- src/locales/en-au.js | 2 +- src/locales/en-gb.js | 2 +- src/locales/en-za.js | 2 +- src/locales/es-es.js | 2 +- src/locales/es.js | 2 +- src/locales/et.js | 2 +- src/locales/fi.js | 2 +- src/locales/fr-ca.js | 2 +- src/locales/fr-ch.js | 2 +- src/locales/fr.js | 2 +- src/locales/hu.js | 2 +- src/locales/it.js | 2 +- src/locales/ja.js | 2 +- src/locales/lv.js | 2 +- src/locales/nl-nl.js | 2 +- src/locales/no.js | 2 +- src/locales/pl.js | 2 +- src/locales/pt-br.js | 2 +- src/locales/pt-pt.js | 2 +- src/locales/ru-ua.js | 2 +- src/locales/ru.js | 2 +- src/locales/sk.js | 2 +- src/locales/th.js | 2 +- src/locales/tr.js | 2 +- src/locales/uk-ua.js | 2 +- 76 files changed, 149 insertions(+), 149 deletions(-) diff --git a/locales.js b/locales.js index 76eb3a27..de7bdec5 100644 --- a/locales.js +++ b/locales.js @@ -4,7 +4,7 @@ * author : Dieter Luypaert : https://github.com/moeriki */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'be-nl', { delimiters: { @@ -34,7 +34,7 @@ * author : Don Vince : https://github.com/donvince/ */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'bg', { delimiters: { @@ -70,7 +70,7 @@ * author : badplum : https://github.com/badplum */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'chs', { delimiters: { @@ -98,7 +98,7 @@ * author : Anatoli Papirovski : https://github.com/apapirovski */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'cs', { delimiters: { @@ -126,7 +126,7 @@ * author : Michael Storgaard : https://github.com/mstorgaard */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'da-dk', { delimiters: { @@ -154,7 +154,7 @@ * author : Michael Piefel : https://github.com/piefel (based on work from Marco Krage : https://github.com/sinky) */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'de-ch', { delimiters: { @@ -182,7 +182,7 @@ * author : Marco Krage : https://github.com/sinky */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'de', { delimiters: { @@ -210,7 +210,7 @@ * author : Don Vince : https://github.com/donvince/ */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'en-au', { delimiters: { @@ -242,7 +242,7 @@ * author : Dan Ristic : https://github.com/dristic */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'en-gb', { delimiters: { @@ -274,7 +274,7 @@ * author : Etienne Boshoff : etienne@zailab.com */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'en-za', { delimiters: { @@ -306,7 +306,7 @@ * author : Hernan Garcia : https://github.com/hgarcia */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'es-es', { delimiters: { @@ -339,7 +339,7 @@ * author : Hernan Garcia : https://github.com/hgarcia */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'es', { delimiters: { @@ -375,7 +375,7 @@ * from numbers with a space */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'et', { delimiters: { @@ -403,7 +403,7 @@ * author : Sami Saada : https://github.com/samitheberber */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'fi', { delimiters: { @@ -431,7 +431,7 @@ * author : Léo Renaud-Allaire : https://github.com/renaudleo */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'fr-ca', { delimiters: { @@ -459,7 +459,7 @@ * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'fr-ch', { delimiters: { @@ -487,7 +487,7 @@ * author : Adam Draper : https://github.com/adamwdraper */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'fr', { delimiters: { @@ -515,7 +515,7 @@ * author : Peter Bakondy : https://github.com/pbakondy */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'hu', { delimiters: { @@ -543,7 +543,7 @@ * author : Giacomo Trombi : http://cinquepunti.it */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'it', { delimiters: { @@ -571,7 +571,7 @@ * author : teppeis : https://github.com/teppeis */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'ja', { delimiters: { @@ -599,7 +599,7 @@ * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'lv', { delimiters: { @@ -627,7 +627,7 @@ * author : Dave Clayton : https://github.com/davedx */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'nl-nl', { delimiters: { @@ -656,7 +656,7 @@ * author : Ove Andersen : https://github.com/azzlack */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'no', { delimiters: { @@ -684,7 +684,7 @@ * author : Dominik Bulaj : https://github.com/dominikbulaj */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'pl', { delimiters: { @@ -712,7 +712,7 @@ * author : Ramiro Varandas Jr : https://github.com/ramirovjr */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'pt-br', { delimiters: { @@ -740,7 +740,7 @@ * author : Diogo Resende : https://github.com/dresende */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'pt-pt', { delimiters: { @@ -766,7 +766,7 @@ // locale : Russian for the Ukraine (ru-ua) // author : Anatoli Papirovski : https://github.com/apapirovski (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'ru-ua', { delimiters: { @@ -797,7 +797,7 @@ * author : Anatoli Papirovski : https://github.com/apapirovski */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'ru', { delimiters: { @@ -828,7 +828,7 @@ * author : Ahmed Al Hafoudh : http://www.freevision.sk */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'sk', { delimiters: { @@ -856,7 +856,7 @@ * author : Sathit Jittanupat : https://github.com/jojosati */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'th', { delimiters: { @@ -884,7 +884,7 @@ * author : Ecmel Ercan : https://github.com/ecmel, Erhan Gundogan : https://github.com/erhangundogan, Burak Yiğit Kaya: https://github.com/BYK */ (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'), + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'), suffixes = { 1: '\'inci', 5: '\'inci', @@ -943,7 +943,7 @@ // locale : Ukrainian for the Ukraine (uk-ua) // author : Michael Piefel : https://github.com/piefel (with help from Tetyana Kuzmenko) (function () { - var numeral = typeof window !== 'undefined' ? this.numeral : require('../numeral'); + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); numeral.register('locale', 'uk-ua', { delimiters: { diff --git a/min/locales.min.js b/min/locales.min.js index b197fb7c..f23b278a 100644 --- a/min/locales.min.js +++ b/min/locales.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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&&1>=b||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","bg",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","chs",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","cs",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"Kč"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","de",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","et",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","fi",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","hu",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","it",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ja",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","lv",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","no",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","pl",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","pt-pt",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ru-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"₴"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ru",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн.",billion:"млрд.",trillion:"трлн."},ordinal:function(){return"."},currency:{symbol:"руб."}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","sk",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","th",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral"),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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","uk-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тис.",million:"млн",billion:"млрд",trillion:"блн"},ordinal:function(){return""},currency:{symbol:"₴"}})}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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:"€ "}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","bg",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","chs",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","cs",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"Kč"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","de",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","et",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","fi",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","hu",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","it",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ja",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","lv",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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&&b<=1||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","no",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","pl",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","pt-pt",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ru-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"₴"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ru",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн.",billion:"млрд.",trillion:"трлн."},ordinal:function(){return"."},currency:{symbol:"руб."}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","sk",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","th",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral"),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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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/be-nl.min.js b/min/locales/be-nl.min.js index 9aa339b3..febbf6f8 100644 --- a/min/locales/be-nl.min.js +++ b/min/locales/be-nl.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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&&1>=b||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 index 3cdf496b..47070f0d 100644 --- a/min/locales/bg.min.js +++ b/min/locales/bg.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","bg",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}})}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 index 77852335..71483dc6 100644 --- a/min/locales/chs.min.js +++ b/min/locales/chs.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","chs",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 index c082260d..2cc68bcb 100644 --- a/min/locales/cs.min.js +++ b/min/locales/cs.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 index 31755f7e..cffb43e9 100644 --- a/min/locales/da-dk.min.js +++ b/min/locales/da-dk.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 index b65063a3..7be400f7 100644 --- a/min/locales/de-ch.min.js +++ b/min/locales/de-ch.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 index df96ef76..006ca730 100644 --- a/min/locales/de.min.js +++ b/min/locales/de.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 index 8980711a..caa38e2e 100644 --- a/min/locales/en-au.min.js +++ b/min/locales/en-au.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 index 17cc5774..c937f656 100644 --- a/min/locales/en-gb.min.js +++ b/min/locales/en-gb.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 index c47301c1..7d64f495 100644 --- a/min/locales/en-za.min.js +++ b/min/locales/en-za.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 index df96be94..56bd4d40 100644 --- a/min/locales/es-es.min.js +++ b/min/locales/es-es.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 index d061edc3..00b2005c 100644 --- a/min/locales/es.min.js +++ b/min/locales/es.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 index d9afa261..59da7f3d 100644 --- a/min/locales/et.min.js +++ b/min/locales/et.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 index b6baa24a..613cf43c 100644 --- a/min/locales/fi.min.js +++ b/min/locales/fi.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 index 70675254..93187abd 100644 --- a/min/locales/fr-ca.min.js +++ b/min/locales/fr-ca.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 index e16245d7..84b26b32 100644 --- a/min/locales/fr-ch.min.js +++ b/min/locales/fr-ch.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 index a2fbeb5b..de3ef306 100644 --- a/min/locales/fr.min.js +++ b/min/locales/fr.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 index fde493c5..eefcd79a 100644 --- a/min/locales/hu.min.js +++ b/min/locales/hu.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 index a1d0c19e..610374d2 100644 --- a/min/locales/it.min.js +++ b/min/locales/it.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 index 4f4f56ce..09921910 100644 --- a/min/locales/ja.min.js +++ b/min/locales/ja.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ja",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 index 9a1f999c..94d75371 100644 --- a/min/locales/lv.min.js +++ b/min/locales/lv.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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-nl.min.js b/min/locales/nl-nl.min.js index f701051a..981dc4eb 100644 --- a/min/locales/nl-nl.min.js +++ b/min/locales/nl-nl.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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&&b<=1||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 index 24c99ac0..885f6b6e 100644 --- a/min/locales/no.min.js +++ b/min/locales/no.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 index 47348fca..d674b360 100644 --- a/min/locales/pl.min.js +++ b/min/locales/pl.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 index ed2e152f..114de591 100644 --- a/min/locales/pt-br.min.js +++ b/min/locales/pt-br.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 index 8104095b..250e741a 100644 --- a/min/locales/pt-pt.min.js +++ b/min/locales/pt-pt.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 index 7da88866..fe920362 100644 --- a/min/locales/ru-ua.min.js +++ b/min/locales/ru-ua.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 index 3679546f..0348802d 100644 --- a/min/locales/ru.min.js +++ b/min/locales/ru.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ru",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн.",billion:"млрд.",trillion:"трлн."},ordinal:function(){return"."},currency:{symbol:"руб."}})}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 index adfcc5df..8cd3eb87 100644 --- a/min/locales/sk.min.js +++ b/min/locales/sk.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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 +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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/th.min.js b/min/locales/th.min.js index 8a0508ae..c4595483 100644 --- a/min/locales/th.min.js +++ b/min/locales/th.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","th",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}})}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 index 7dfc5167..2872d938 100644 --- a/min/locales/tr.min.js +++ b/min/locales/tr.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral"),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 +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral"),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 index d0a1b346..0a6f7e20 100644 --- a/min/locales/uk-ua.min.js +++ b/min/locales/uk-ua.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","uk-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тис.",million:"млн",billion:"млрд",trillion:"блн"},ordinal:function(){return""},currency:{symbol:"₴"}})}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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/numeral-with-locales.min.js b/min/numeral-with-locales.min.js index 6a138570..9a80e29a 100644 --- a/min/numeral-with-locales.min.js +++ b/min/numeral-with-locales.min.js @@ -5,4 +5,4 @@ * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="2.0.0",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,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")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):p>g&&g>=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):q>g&&g>=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(r>g&&g>=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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)},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*g)/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(),b):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.");this[a+"s"][b]=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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral"),b={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","exponential",{regexps:{format:/(e\+|e-)/,unformat:/(e\+|e-)/},format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]},unformat:function(b){function c(b,c,d,e){var f=a._.correctionFactor(b,c),g=b*f*(c*f)/(f*f);return g}var d=a._.includes(b,"e+")?b.split("e+"):b.split("e-"),e=Number(d[0]),f=Number(d[1]);return f=a._.includes(b,"e-")?f*=-1:f,a._.reduce([e,Math.pow(10,f)],c,1)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexps:{format:/(o)/},format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.numberToFormat(b,c,d),e+g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","percentage",{regexps:{format:/(%)/,unformat:/(%)/},format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.numberToFormat(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e},unformat:function(b){return.01*a._.stringToNumber(b)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.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)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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&&1>=b||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","bg",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","chs",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","cs",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"Kč"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","de",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","et",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","fi",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","hu",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","it",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ja",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","lv",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","no",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","pl",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","pt-pt",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ru-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"₴"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","ru",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн.",billion:"млрд.",trillion:"трлн."},ordinal:function(){return"."},currency:{symbol:"руб."}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","sk",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","th",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral"),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(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("locale","uk-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тис.",million:"млн",billion:"млрд",trillion:"блн"},ordinal:function(){return""},currency:{symbol:"₴"}})}(); \ No newline at end of file +(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="2.0.0",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,c=c.replace(/\+/g,"")),b._.includes(c,"a")&&(e=c.match(/a(k|m|b|t)?/),e=!!e&&e[1],b._.includes(c," a")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):g=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):g=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(g=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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 a.indexOf(b)!==-1},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(;f=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;fd?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*g)/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(),b):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.");this[a+"s"][b]=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(a){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))&&(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))&&(i=new RegExp(e+"{2}"),!a.match(/[^\d.,]/g)&&(g=a.split(d),!(g.length>2)&&(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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral"),b={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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&&d0&&(d/=i);break}return g=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),h<=1?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=h=20?"ste":"de"},currency:{symbol:"€ "}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","bg",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","chs",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","cs",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"Kč"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","de",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","et",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","fi",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","hu",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","it",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ja",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","lv",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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&&b<=1||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","no",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","pl",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","pt-pt",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ru-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"₴"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ru",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн.",billion:"млрд.",trillion:"трлн."},ordinal:function(){return"."},currency:{symbol:"руб."}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","sk",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","th",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral"),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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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/numeral.min.js b/min/numeral.min.js index 1265a2bc..2072b1ff 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="2.0.0",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,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")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):p>g&&g>=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):q>g&&g>=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(r>g&&g>=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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)},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*g)/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(),b):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.");this[a+"s"][b]=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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral"),b={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),1>=h?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:a._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","exponential",{regexps:{format:/(e\+|e-)/,unformat:/(e\+|e-)/},format:function(b,c,d){var e,f="number"!=typeof b||a._.isNaN(b)?"0e+0":b.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=a._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]},unformat:function(b){function c(b,c,d,e){var f=a._.correctionFactor(b,c),g=b*f*(c*f)/(f*f);return g}var d=a._.includes(b,"e+")?b.split("e+"):b.split("e-"),e=Number(d[0]),f=Number(d[1]);return f=a._.includes(b,"e-")?f*=-1:f,a._.reduce([e,Math.pow(10,f)],c,1)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");"undefined"!=typeof window&&this.numeral?a=this.numeral:"undefined"!=typeof module&&module.exports&&(a=require("../numeral")),a.register("format","ordinal",{regexps:{format:/(o)/},format:function(b,c,d){var e,f=a.locales[a.options.currentLocale],g=a._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(b),e=a._.numberToFormat(b,c,d),e+g}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.register("format","percentage",{regexps:{format:/(%)/,unformat:/(%)/},format:function(b,c,d){var e,f=a._.includes(c," %")?" ":"";return b=100*b,c=c.replace(/\s?\%/,""),e=a._.numberToFormat(b,c,d),a._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e},unformat:function(b){return.01*a._.stringToNumber(b)}})}(),function(){var a="undefined"!=typeof window?this.numeral:require("../numeral");a.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)}})}(); \ No newline at end of file +(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="2.0.0",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,c=c.replace(/\+/g,"")),b._.includes(c,"a")&&(e=c.match(/a(k|m|b|t)?/),e=!!e&&e[1],b._.includes(c," a")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):g=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):g=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(g=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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 a.indexOf(b)!==-1},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(;f=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;fd?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*g)/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(),b):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.");this[a+"s"][b]=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(a){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))&&(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))&&(i=new RegExp(e+"{2}"),!a.match(/[^\d.,]/g)&&(g=a.split(d),!(g.length>2)&&(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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral"),b={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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&&d0&&(d/=i);break}return g=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),h<=1?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=h Date: Wed, 7 Dec 2016 10:50:26 -0800 Subject: [PATCH 113/150] update version number and add change to readme --- README.md | 4 ++++ bower.json | 2 +- component.json | 2 +- min/numeral-with-locales.min.js | 4 ++-- min/numeral.min.js | 4 ++-- numeral-with-locales.js | 4 ++-- numeral.js | 4 ++-- package.json | 2 +- src/numeral.js | 4 ++-- 9 files changed, 17 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 1a9db88d..8346f5b6 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,10 @@ See [the english unit tests](https://github.com/adamwdraper/Numeral-js/blob/mast # Changelog +### 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. diff --git a/bower.json b/bower.json index 72ba72bf..a52875be 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "numeral", "repo": "adamwdraper/Numeral-js", - "version": "2.0.0", + "version": "2.0.1", "description": "Format and manipulate numbers.", "keywords": [ "numeral", diff --git a/component.json b/component.json index 72ba72bf..a52875be 100644 --- a/component.json +++ b/component.json @@ -1,7 +1,7 @@ { "name": "numeral", "repo": "adamwdraper/Numeral-js", - "version": "2.0.0", + "version": "2.0.1", "description": "Format and manipulate numbers.", "keywords": [ "numeral", diff --git a/min/numeral-with-locales.min.js b/min/numeral-with-locales.min.js index 9a80e29a..549d3286 100644 --- a/min/numeral-with-locales.min.js +++ b/min/numeral-with-locales.min.js @@ -1,8 +1,8 @@ /*! @preserve * numeral.js - * version : 2.0.0 + * version : 2.0.1 * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="2.0.0",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,c=c.replace(/\+/g,"")),b._.includes(c,"a")&&(e=c.match(/a(k|m|b|t)?/),e=!!e&&e[1],b._.includes(c," a")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):g=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):g=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(g=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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 a.indexOf(b)!==-1},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(;f=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;fd?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*g)/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(),b):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.");this[a+"s"][b]=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(a){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))&&(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))&&(i=new RegExp(e+"{2}"),!a.match(/[^\d.,]/g)&&(g=a.split(d),!(g.length>2)&&(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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral"),b={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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&&d0&&(d/=i);break}return g=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),h<=1?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=h=20?"ste":"de"},currency:{symbol:"€ "}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","bg",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","chs",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","cs",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"Kč"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","de",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","et",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","fi",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","hu",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","it",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ja",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","lv",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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&&b<=1||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","no",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","pl",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","pt-pt",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ru-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"₴"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ru",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн.",billion:"млрд.",trillion:"трлн."},ordinal:function(){return"."},currency:{symbol:"руб."}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","sk",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","th",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral"),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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","uk-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тис.",million:"млн",billion:"млрд",trillion:"блн"},ordinal:function(){return""},currency:{symbol:"₴"}})}(); \ No newline at end of file +(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="2.0.1",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,c=c.replace(/\+/g,"")),b._.includes(c,"a")&&(e=c.match(/a(k|m|b|t)?/),e=!!e&&e[1],b._.includes(c," a")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):g=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):g=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(g=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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 a.indexOf(b)!==-1},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(;f=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;fd?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*g)/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(),b):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.");this[a+"s"][b]=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(a){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))&&(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))&&(i=new RegExp(e+"{2}"),!a.match(/[^\d.,]/g)&&(g=a.split(d),!(g.length>2)&&(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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral"),b={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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&&d0&&(d/=i);break}return g=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),h<=1?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=h=20?"ste":"de"},currency:{symbol:"€ "}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","bg",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","chs",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","cs",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"Kč"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","de",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","et",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","fi",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","hu",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","it",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ja",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","lv",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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&&b<=1||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","no",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","pl",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","pt-pt",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ru-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"₴"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ru",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн.",billion:"млрд.",trillion:"трлн."},ordinal:function(){return"."},currency:{symbol:"руб."}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","sk",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","th",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral"),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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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/numeral.min.js b/min/numeral.min.js index 2072b1ff..00230c88 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -1,8 +1,8 @@ /*! @preserve * numeral.js - * version : 2.0.0 + * version : 2.0.1 * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="2.0.0",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,c=c.replace(/\+/g,"")),b._.includes(c,"a")&&(e=c.match(/a(k|m|b|t)?/),e=!!e&&e[1],b._.includes(c," a")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):g=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):g=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(g=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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 a.indexOf(b)!==-1},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(;f=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;fd?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*g)/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(),b):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.");this[a+"s"][b]=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(a){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))&&(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))&&(i=new RegExp(e+"{2}"),!a.match(/[^\d.,]/g)&&(g=a.split(d),!(g.length>2)&&(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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral"),b={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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&&d0&&(d/=i);break}return g=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),h<=1?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=h=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):g=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):g=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(g=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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 a.indexOf(b)!==-1},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(;f=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;fd?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*g)/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(),b):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.");this[a+"s"][b]=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(a){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))&&(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))&&(i=new RegExp(e+"{2}"),!a.match(/[^\d.,]/g)&&(g=a.split(d),!(g.length>2)&&(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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral"),b={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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&&d0&&(d/=i);break}return g=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),h<=1?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=h Date: Wed, 7 Dec 2016 11:03:41 -0800 Subject: [PATCH 114/150] Update link to locale test --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8346f5b6..591b1574 100644 --- a/README.md +++ b/README.md @@ -36,13 +36,13 @@ Develop [![Build Status](https://travis-ci.org/adamwdraper/Numeral-js.svg?branch 8. Submit a pull request to the `develop` branch. -### 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 From 4e5cc5165b75fe6a4d4d8a8569def974280c1222 Mon Sep 17 00:00:00 2001 From: Bostjan Pisler Date: Thu, 8 Dec 2016 16:30:39 +0100 Subject: [PATCH 115/150] sl localization --- src/locales/sl.js | 27 +++++++++++++ tests/locales/sl.js | 94 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 src/locales/sl.js create mode 100644 tests/locales/sl.js diff --git a/src/locales/sl.js b/src/locales/sl.js new file mode 100644 index 00000000..fbd82318 --- /dev/null +++ b/src/locales/sl.js @@ -0,0 +1,27 @@ +/* + * numeral.js locale configuration + * locale : slovenian (sl) + * author : Boštjan Pišler : https://github.com/BostjanPisler + */ +(function () { + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); + + numeral.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/tests/locales/sl.js b/tests/locales/sl.js new file mode 100644 index 00000000..17ad26e7 --- /dev/null +++ b/tests/locales/sl.js @@ -0,0 +1,94 @@ +// Node +if (typeof module !== 'undefined' && module.exports) { + var numeral = require('../../src/numeral'); + var expect = require('chai').expect; + var locale = require('../../src/locales/sl'); +} + +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]); + } + }); + }); +}); \ No newline at end of file From 04e6af1c66ca4e739be576319c9a26a125b3121d Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 8 Dec 2016 09:26:44 -0800 Subject: [PATCH 116/150] build --- locales.js | 27 +++++++++++++++++++++++++++ min/locales.min.js | 2 +- min/locales/sl.min.js | 1 + min/numeral-with-locales.min.js | 2 +- numeral-with-locales.js | 27 +++++++++++++++++++++++++++ 5 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 min/locales/sl.min.js diff --git a/locales.js b/locales.js index de7bdec5..cf7d78dc 100644 --- a/locales.js +++ b/locales.js @@ -850,6 +850,33 @@ }); }()); +/* + * numeral.js locale configuration + * locale : slovenian (sl) + * author : Boštjan Pišler : https://github.com/BostjanPisler + */ +(function () { + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); + + numeral.register('locale', 'sl', { + delimiters: { + thousands: '.', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'mio', + billion: 'mrd', + trillion: 'trilijon' + }, + ordinal: function () { + return '.'; + }, + currency: { + symbol: '€' + } + }); +}()); /* * numeral.js locale configuration * locale : thai (th) diff --git a/min/locales.min.js b/min/locales.min.js index f23b278a..fa7e30e2 100644 --- a/min/locales.min.js +++ b/min/locales.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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:"€ "}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","bg",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","chs",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","cs",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"Kč"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","de",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","et",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","fi",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","hu",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","it",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ja",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","lv",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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&&b<=1||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","no",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","pl",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","pt-pt",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ru-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"₴"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ru",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн.",billion:"млрд.",trillion:"трлн."},ordinal:function(){return"."},currency:{symbol:"руб."}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","sk",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","th",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral"),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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","uk-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тис.",million:"млн",billion:"млрд",trillion:"блн"},ordinal:function(){return""},currency:{symbol:"₴"}})}(); \ No newline at end of file +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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:"€ "}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","bg",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","chs",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","cs",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"Kč"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","de",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","et",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","fi",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","hu",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","it",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ja",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","lv",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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&&b<=1||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","no",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","pl",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","pt-pt",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ru-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"₴"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ru",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн.",billion:"млрд.",trillion:"трлн."},ordinal:function(){return"."},currency:{symbol:"руб."}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","sk",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","sl",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mrd",trillion:"trilijon"},ordinal:function(){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","th",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral"),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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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/sl.min.js b/min/locales/sl.min.js new file mode 100644 index 00000000..25c1d225 --- /dev/null +++ b/min/locales/sl.min.js @@ -0,0 +1 @@ +!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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/numeral-with-locales.min.js b/min/numeral-with-locales.min.js index 549d3286..29a2a1e4 100644 --- a/min/numeral-with-locales.min.js +++ b/min/numeral-with-locales.min.js @@ -5,4 +5,4 @@ * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="2.0.1",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,c=c.replace(/\+/g,"")),b._.includes(c,"a")&&(e=c.match(/a(k|m|b|t)?/),e=!!e&&e[1],b._.includes(c," a")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):g=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):g=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(g=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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 a.indexOf(b)!==-1},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(;f=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;fd?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*g)/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(),b):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.");this[a+"s"][b]=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(a){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))&&(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))&&(i=new RegExp(e+"{2}"),!a.match(/[^\d.,]/g)&&(g=a.split(d),!(g.length>2)&&(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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral"),b={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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&&d0&&(d/=i);break}return g=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),h<=1?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=h=20?"ste":"de"},currency:{symbol:"€ "}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","bg",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","chs",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","cs",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"Kč"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","de",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","et",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","fi",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","hu",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","it",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ja",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","lv",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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&&b<=1||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","no",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","pl",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","pt-pt",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ru-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"₴"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ru",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн.",billion:"млрд.",trillion:"трлн."},ordinal:function(){return"."},currency:{symbol:"руб."}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","sk",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","th",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral"),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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","uk-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тис.",million:"млн",billion:"млрд",trillion:"блн"},ordinal:function(){return""},currency:{symbol:"₴"}})}(); \ No newline at end of file +(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="2.0.1",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,c=c.replace(/\+/g,"")),b._.includes(c,"a")&&(e=c.match(/a(k|m|b|t)?/),e=!!e&&e[1],b._.includes(c," a")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):g=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):g=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(g=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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 a.indexOf(b)!==-1},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(;f=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;fd?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*g)/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(),b):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.");this[a+"s"][b]=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(a){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))&&(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))&&(i=new RegExp(e+"{2}"),!a.match(/[^\d.,]/g)&&(g=a.split(d),!(g.length>2)&&(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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral"),b={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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&&d0&&(d/=i);break}return g=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),h<=1?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=h=20?"ste":"de"},currency:{symbol:"€ "}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","bg",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","chs",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","cs",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"Kč"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","de",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","et",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","fi",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","hu",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","it",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ja",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","lv",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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&&b<=1||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","no",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","pl",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","pt-pt",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ru-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"₴"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ru",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн.",billion:"млрд.",trillion:"трлн."},ordinal:function(){return"."},currency:{symbol:"руб."}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","sk",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","sl",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mrd",trillion:"trilijon"},ordinal:function(){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","th",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral"),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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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/numeral-with-locales.js b/numeral-with-locales.js index f23913c9..1b9e3464 100644 --- a/numeral-with-locales.js +++ b/numeral-with-locales.js @@ -1816,6 +1816,33 @@ }); }()); +/* + * numeral.js locale configuration + * locale : slovenian (sl) + * author : Boštjan Pišler : https://github.com/BostjanPisler + */ +(function () { + var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); + + numeral.register('locale', 'sl', { + delimiters: { + thousands: '.', + decimal: ',' + }, + abbreviations: { + thousand: 'k', + million: 'mio', + billion: 'mrd', + trillion: 'trilijon' + }, + ordinal: function () { + return '.'; + }, + currency: { + symbol: '€' + } + }); +}()); /* * numeral.js locale configuration * locale : thai (th) From 64199f2ce3180e4da1a07ab2e3797e3bddeb8c9a Mon Sep 17 00:00:00 2001 From: naoh Date: Tue, 13 Dec 2016 13:47:25 +0800 Subject: [PATCH 117/150] Add CDNJS version badge in readme This will add the badge to show its version on CDNJS and also link to its page on CDNJS! --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 591b1574..dc0dc2ef 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,10 @@ Develop [![Build Status](https://travis-ci.org/adamwdraper/Numeral-js.svg?branch [![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 #### Important: Please create your branch from and submit pull requests to the `develop` branch. From 49f0c841dabe90129bb8bef0271d6d606d037565 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Thu, 15 Dec 2016 22:25:44 -0800 Subject: [PATCH 118/150] update modules --- Gruntfile.js | 5 +- bower.json | 2 +- component.json | 2 +- locales.js | 745 ++++++++++++++++----------- min/locales.min.js | 2 +- min/locales/be-nl.min.js | 2 +- min/locales/bg.min.js | 2 +- min/locales/chs.min.js | 2 +- min/locales/cs.min.js | 2 +- min/locales/da-dk.min.js | 2 +- min/locales/de-ch.min.js | 2 +- min/locales/de.min.js | 2 +- min/locales/en-au.min.js | 2 +- min/locales/en-gb.min.js | 2 +- min/locales/en-za.min.js | 2 +- min/locales/es-es.min.js | 2 +- min/locales/es.min.js | 2 +- min/locales/et.min.js | 2 +- min/locales/fi.min.js | 2 +- min/locales/fr-ca.min.js | 2 +- min/locales/fr-ch.min.js | 2 +- min/locales/fr.min.js | 2 +- min/locales/hu.min.js | 2 +- min/locales/it.min.js | 2 +- min/locales/ja.min.js | 2 +- min/locales/lv.min.js | 2 +- min/locales/nl-nl.min.js | 2 +- min/locales/no.min.js | 2 +- min/locales/pl.min.js | 2 +- min/locales/pt-br.min.js | 2 +- min/locales/pt-pt.min.js | 2 +- min/locales/ru-ua.min.js | 2 +- min/locales/ru.min.js | 2 +- min/locales/sk.min.js | 2 +- min/locales/sl.min.js | 2 +- min/locales/th.min.js | 2 +- min/locales/tr.min.js | 2 +- min/locales/uk-ua.min.js | 2 +- min/numeral-with-locales.min.js | 4 +- min/numeral.min.js | 4 +- numeral-with-locales.js | 870 +++++++++++++++++++------------- numeral.js | 175 ++++--- package.json | 2 +- src/formats/bytes.js | 24 +- src/formats/currency.js | 23 +- src/formats/exponential.js | 21 +- src/formats/ordinal.js | 28 +- src/formats/percentage.js | 23 +- src/formats/time.js | 21 +- src/locales/be-nl.js | 23 +- src/locales/bg.js | 21 +- src/locales/chs.js | 23 +- src/locales/cs.js | 21 +- src/locales/da-dk.js | 21 +- src/locales/de-ch.js | 21 +- src/locales/de.js | 21 +- src/locales/en-au.js | 21 +- src/locales/en-gb.js | 21 +- src/locales/en-za.js | 21 +- src/locales/es-es.js | 21 +- src/locales/es.js | 21 +- src/locales/et.js | 25 +- src/locales/fi.js | 21 +- src/locales/fr-ca.js | 21 +- src/locales/fr-ch.js | 21 +- src/locales/fr.js | 21 +- src/locales/hu.js | 21 +- src/locales/it.js | 21 +- src/locales/ja.js | 21 +- src/locales/lv.js | 21 +- src/locales/nl-nl.js | 21 +- src/locales/no.js | 21 +- src/locales/pl.js | 21 +- src/locales/pt-br.js | 21 +- src/locales/pt-pt.js | 21 +- src/locales/ru-ua.js | 13 +- src/locales/ru.js | 21 +- src/locales/sk.js | 21 +- src/locales/sl.js | 21 +- src/locales/th.js | 23 +- src/locales/tr.js | 24 +- src/locales/uk-ua.js | 13 +- src/numeral.js | 43 +- 83 files changed, 1646 insertions(+), 1104 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 9d4ab088..0968fc68 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -107,7 +107,10 @@ module.exports = function(grunt) { 'undef': true, 'sub': true, 'strict': false, - 'quotmark': 'single' + 'quotmark': 'single', + 'globals': { + 'define': true + } } } }); diff --git a/bower.json b/bower.json index a52875be..8c3f3513 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "numeral", "repo": "adamwdraper/Numeral-js", - "version": "2.0.1", + "version": "2.0.2", "description": "Format and manipulate numbers.", "keywords": [ "numeral", diff --git a/component.json b/component.json index a52875be..8c3f3513 100644 --- a/component.json +++ b/component.json @@ -1,7 +1,7 @@ { "name": "numeral", "repo": "adamwdraper/Numeral-js", - "version": "2.0.1", + "version": "2.0.2", "description": "Format and manipulate numbers.", "keywords": [ "numeral", diff --git a/locales.js b/locales.js index cf7d78dc..4f8e3ef8 100644 --- a/locales.js +++ b/locales.js @@ -1,11 +1,16 @@ -/* - * numeral.js locale configuration - * locale : belgium-dutch (be-nl) - * author : Dieter Luypaert : https://github.com/moeriki - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); - +// numeral.js locale configuration +// locale : belgium-dutch (be-nl) +// author : Dieter Luypaert : https://github.com/moeriki + +(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', 'be-nl', { delimiters: { thousands: ' ', @@ -19,23 +24,28 @@ }, ordinal : function (number) { var remainder = number % 100; - + return (number !== 0 && remainder <= 1 || remainder === 8 || remainder >= 20) ? 'ste' : 'de'; }, currency: { symbol: '€ ' } }); -}()); - -/* - * numeral.js locale configuration - * locale : Bulgarian - * author : Don Vince : https://github.com/donvince/ - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +})); +// 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: ' ', @@ -62,16 +72,21 @@ symbol: 'лв' } }); -}()); - -/* - * numeral.js locale configuration - * locale : simplified chinese (chs) - * author : badplum : https://github.com/badplum - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); - +})); + +// 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: ',', @@ -90,16 +105,21 @@ symbol: '¥' } }); -}()); +})); -/* - * numeral.js locale configuration - * locale : czech (cs) - * author : Anatoli Papirovski : https://github.com/apapirovski - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -118,16 +138,21 @@ symbol: 'Kč' } }); -}()); - -/* - * numeral.js locale configuration - * locale : danish denmark (dk) - * author : Michael Storgaard : https://github.com/mstorgaard - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +})); +// 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: '.', @@ -146,16 +171,21 @@ symbol: 'DKK' } }); -}()); - -/* - * 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 () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +})); +// 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: ' ', @@ -174,16 +204,21 @@ symbol: 'CHF' } }); -}()); - -/* - * numeral.js locale configuration - * locale : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium - * author : Marco Krage : https://github.com/sinky - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +})); +// 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: ' ', @@ -202,16 +237,21 @@ symbol: '€' } }); -}()); - -/* - * numeral.js locale configuration - * locale : English Australia - * author : Don Vince : https://github.com/donvince/ - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +})); +// 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: ',', @@ -234,16 +274,21 @@ symbol: '$' } }); -}()); - -/* - * numeral.js locale configuration - * locale : english united kingdom (uk) - * author : Dan Ristic : https://github.com/dristic - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +})); +// 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: ',', @@ -266,16 +311,21 @@ symbol: '£' } }); -}()); - -/* - * numeral.js locale configuration - * locale : english south africa (uk) - * author : Etienne Boshoff : etienne@zailab.com - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +})); +// 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: ' ', @@ -298,16 +348,21 @@ symbol: 'R' } }); -}()); - -/* - * numeral.js locale configuration - * locale : spanish Spain - * author : Hernan Garcia : https://github.com/hgarcia - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +})); +// 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: '.', @@ -331,16 +386,21 @@ symbol: '€' } }); -}()); - -/* - * numeral.js locale configuration - * locale : spanish - * author : Hernan Garcia : https://github.com/hgarcia - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +})); +// 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: '.', @@ -364,19 +424,22 @@ symbol: '$' } }); -}()); - -/* - * 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 () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +})); +// 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: ' ', @@ -395,16 +458,21 @@ symbol: '€' } }); -}()); - -/* - * numeral.js locale configuration - * locale : Finnish - * author : Sami Saada : https://github.com/samitheberber - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +})); +// 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: ' ', @@ -423,16 +491,21 @@ symbol: '€' } }); -}()); - -/* - * numeral.js locale configuration - * locale : french (Canada) (fr-ca) - * author : Léo Renaud-Allaire : https://github.com/renaudleo - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +})); +// 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: ' ', @@ -451,16 +524,21 @@ symbol: '$' } }); -}()); - -/* - * numeral.js locale configuration - * locale : french (fr-ch) - * author : Adam Draper : https://github.com/adamwdraper - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +})); +// 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: '\'', @@ -479,16 +557,21 @@ symbol: 'CHF' } }); -}()); - -/* - * numeral.js locale configuration - * locale : french (fr) - * author : Adam Draper : https://github.com/adamwdraper - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +})); +// 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: ' ', @@ -507,16 +590,21 @@ symbol: '€' } }); -}()); - -/* - * numeral.js locale configuration - * locale : Hungarian (hu) - * author : Peter Bakondy : https://github.com/pbakondy - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +})); +// 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: ' ', @@ -535,16 +623,21 @@ symbol: ' Ft' } }); -}()); - -/* - * numeral.js locale configuration - * locale : italian Italy (it) - * author : Giacomo Trombi : http://cinquepunti.it - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +})); +// 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: '.', @@ -563,16 +656,21 @@ symbol: '€' } }); -}()); - -/* - * numeral.js locale configuration - * locale : japanese - * author : teppeis : https://github.com/teppeis - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +})); +// 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: ',', @@ -591,16 +689,21 @@ symbol: '¥' } }); -}()); - -/* - * numeral.js locale configuration - * locale : Latvian (lv) - * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +})); +// 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: ' ', @@ -619,16 +722,21 @@ symbol: '€' } }); -}()); - -/* - * numeral.js locale configuration - * locale : netherlands-dutch (nl-nl) - * author : Dave Clayton : https://github.com/davedx - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +})); +// 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: '.', @@ -648,16 +756,21 @@ symbol: '€ ' } }); -}()); - -/* - * numeral.js locale configuration - * locale : norwegian (bokmål) - * author : Ove Andersen : https://github.com/azzlack - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +})); +// 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: ' ', @@ -676,16 +789,21 @@ symbol: 'kr' } }); -}()); - -/* - * numeral.js locale configuration - * locale : polish (pl) - * author : Dominik Bulaj : https://github.com/dominikbulaj - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +})); +// 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: ' ', @@ -704,16 +822,21 @@ symbol: 'PLN' } }); -}()); - -/* - * numeral.js locale configuration - * locale : portuguese brazil (pt-br) - * author : Ramiro Varandas Jr : https://github.com/ramirovjr - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +})); +// 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: '.', @@ -732,16 +855,21 @@ symbol: 'R$' } }); -}()); - -/* - * numeral.js locale configuration - * locale : portuguese (pt-pt) - * author : Diogo Resende : https://github.com/dresende - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +})); +// 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: ' ', @@ -760,14 +888,21 @@ symbol: '€' } }); -}()); +})); // numeral.js locale configuration // locale : Russian for the Ukraine (ru-ua) // author : Anatoli Papirovski : https://github.com/apapirovski -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +(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: ' ', @@ -789,16 +924,21 @@ symbol: '\u20B4' } }); -}()); +})); -/* - * numeral.js locale configuration - * locale : russian (ru) - * author : Anatoli Papirovski : https://github.com/apapirovski - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -820,16 +960,21 @@ symbol: 'руб.' } }); -}()); - -/* - * numeral.js locale configuration - * locale : slovak (sk) - * author : Ahmed Al Hafoudh : http://www.freevision.sk - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +})); +// 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: ' ', @@ -848,16 +993,21 @@ symbol: '€' } }); -}()); - -/* - * numeral.js locale configuration - * locale : slovenian (sl) - * author : Boštjan Pišler : https://github.com/BostjanPisler - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +})); +// 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: '.', @@ -876,14 +1026,22 @@ symbol: '€' } }); -}()); -/* - * numeral.js locale configuration - * locale : thai (th) - * author : Sathit Jittanupat : https://github.com/jojosati - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +})); + +// 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: { @@ -903,16 +1061,22 @@ symbol: '฿' } }); -}()); +})); -/* - * 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 () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'), - suffixes = { +// 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', @@ -964,14 +1128,21 @@ symbol: '\u20BA' } }); -}()); +})); // 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 numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +(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: ' ', @@ -993,4 +1164,4 @@ symbol: '\u20B4' } }); -}()); +})); diff --git a/min/locales.min.js b/min/locales.min.js index fa7e30e2..43b6cd12 100644 --- a/min/locales.min.js +++ b/min/locales.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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:"€ "}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","bg",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","chs",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","cs",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"Kč"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","de",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","et",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","fi",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","hu",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","it",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ja",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","lv",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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&&b<=1||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","no",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","pl",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","pt-pt",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ru-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"₴"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ru",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн.",billion:"млрд.",trillion:"трлн."},ordinal:function(){return"."},currency:{symbol:"руб."}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","sk",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","sl",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mrd",trillion:"trilijon"},ordinal:function(){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","th",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral"),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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","uk-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тис.",million:"млн",billion:"млрд",trillion:"блн"},ordinal:function(){return""},currency:{symbol:"₴"}})}(); \ No newline at end of file +!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:"€ "}})}),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:"лв"}})}),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:"¥"}})}),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č"}})}),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"}})}),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"}})}),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:"€"}})}),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:"$"}})}),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:"£"}})}),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"}})}),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:"€"}})}),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:"$"}})}),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:"€"}})}),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:"€"}})}),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:"$"}})}),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"}})}),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:"€"}})}),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"}})}),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:"€"}})}),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:"¥"}})}),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:"€"}})}),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&&b<=1||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}),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"}})}),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"}})}),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$"}})}),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:"€"}})}),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:"₴"}})}),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:"руб."}})}),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:"€"}})}),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:"€"}})}),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:"฿"}})}),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:"₺"}})}),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/be-nl.min.js b/min/locales/be-nl.min.js index febbf6f8..7c98f24b 100644 --- a/min/locales/be-nl.min.js +++ b/min/locales/be-nl.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 +!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 index 47070f0d..eb527e1f 100644 --- a/min/locales/bg.min.js +++ b/min/locales/bg.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","bg",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}})}(); \ No newline at end of file +!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 index 71483dc6..41818b04 100644 --- a/min/locales/chs.min.js +++ b/min/locales/chs.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","chs",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(); \ No newline at end of file +!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 index 2cc68bcb..bde3dd59 100644 --- a/min/locales/cs.min.js +++ b/min/locales/cs.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 +!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 index cffb43e9..f493b252 100644 --- a/min/locales/da-dk.min.js +++ b/min/locales/da-dk.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 +!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 index 7be400f7..18469430 100644 --- a/min/locales/de-ch.min.js +++ b/min/locales/de-ch.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 +!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 index 006ca730..baba5a1d 100644 --- a/min/locales/de.min.js +++ b/min/locales/de.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 +!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 index caa38e2e..ad231d78 100644 --- a/min/locales/en-au.min.js +++ b/min/locales/en-au.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 +!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 index c937f656..caea4d24 100644 --- a/min/locales/en-gb.min.js +++ b/min/locales/en-gb.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 +!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 index 7d64f495..48838e98 100644 --- a/min/locales/en-za.min.js +++ b/min/locales/en-za.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 +!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 index 56bd4d40..1bf25b43 100644 --- a/min/locales/es-es.min.js +++ b/min/locales/es-es.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 +!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 index 00b2005c..7dc95925 100644 --- a/min/locales/es.min.js +++ b/min/locales/es.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 +!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 index 59da7f3d..43e41687 100644 --- a/min/locales/et.min.js +++ b/min/locales/et.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 +!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 index 613cf43c..2d3d119b 100644 --- a/min/locales/fi.min.js +++ b/min/locales/fi.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 +!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 index 93187abd..36ea3ee8 100644 --- a/min/locales/fr-ca.min.js +++ b/min/locales/fr-ca.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 +!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 index 84b26b32..87e646b2 100644 --- a/min/locales/fr-ch.min.js +++ b/min/locales/fr-ch.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 +!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 index de3ef306..ef5d9798 100644 --- a/min/locales/fr.min.js +++ b/min/locales/fr.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 +!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 index eefcd79a..a18bfe74 100644 --- a/min/locales/hu.min.js +++ b/min/locales/hu.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 +!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 index 610374d2..0663447e 100644 --- a/min/locales/it.min.js +++ b/min/locales/it.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 +!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 index 09921910..11bd5911 100644 --- a/min/locales/ja.min.js +++ b/min/locales/ja.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ja",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(); \ No newline at end of file +!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 index 94d75371..9cf210fd 100644 --- a/min/locales/lv.min.js +++ b/min/locales/lv.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 +!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-nl.min.js b/min/locales/nl-nl.min.js index 981dc4eb..17914720 100644 --- a/min/locales/nl-nl.min.js +++ b/min/locales/nl-nl.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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&&b<=1||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}(); \ No newline at end of file +!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&&b<=1||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 index 885f6b6e..9ed349a7 100644 --- a/min/locales/no.min.js +++ b/min/locales/no.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 +!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 index d674b360..633f0741 100644 --- a/min/locales/pl.min.js +++ b/min/locales/pl.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 +!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 index 114de591..5cc66de6 100644 --- a/min/locales/pt-br.min.js +++ b/min/locales/pt-br.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 +!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 index 250e741a..48fa0d90 100644 --- a/min/locales/pt-pt.min.js +++ b/min/locales/pt-pt.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 +!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 index fe920362..619444d9 100644 --- a/min/locales/ru-ua.min.js +++ b/min/locales/ru-ua.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 +!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 index 0348802d..f3d19ad5 100644 --- a/min/locales/ru.min.js +++ b/min/locales/ru.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ru",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн.",billion:"млрд.",trillion:"трлн."},ordinal:function(){return"."},currency:{symbol:"руб."}})}(); \ No newline at end of file +!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 index 8cd3eb87..0baf1952 100644 --- a/min/locales/sk.min.js +++ b/min/locales/sk.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 +!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 index 25c1d225..def40e29 100644 --- a/min/locales/sl.min.js +++ b/min/locales/sl.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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 +!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 index c4595483..fd49a50c 100644 --- a/min/locales/th.min.js +++ b/min/locales/th.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","th",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}})}(); \ No newline at end of file +!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 index 2872d938..4f77e39f 100644 --- a/min/locales/tr.min.js +++ b/min/locales/tr.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral"),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 +!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 index 0a6f7e20..9120e3f0 100644 --- a/min/locales/uk-ua.min.js +++ b/min/locales/uk-ua.min.js @@ -1 +1 @@ -!function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","uk-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тис.",million:"млн",billion:"млрд",trillion:"блн"},ordinal:function(){return""},currency:{symbol:"₴"}})}(); \ No newline at end of file +!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/numeral-with-locales.min.js b/min/numeral-with-locales.min.js index 29a2a1e4..2a343eb5 100644 --- a/min/numeral-with-locales.min.js +++ b/min/numeral-with-locales.min.js @@ -1,8 +1,8 @@ /*! @preserve * numeral.js - * version : 2.0.1 + * version : 2.0.2 * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="2.0.1",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,c=c.replace(/\+/g,"")),b._.includes(c,"a")&&(e=c.match(/a(k|m|b|t)?/),e=!!e&&e[1],b._.includes(c," a")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):g=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):g=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(g=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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 a.indexOf(b)!==-1},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(;f=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;fd?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*g)/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(),b):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.");this[a+"s"][b]=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(a){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))&&(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))&&(i=new RegExp(e+"{2}"),!a.match(/[^\d.,]/g)&&(g=a.split(d),!(g.length>2)&&(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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral"),b={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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&&d0&&(d/=i);break}return g=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),h<=1?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=h=20?"ste":"de"},currency:{symbol:"€ "}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","bg",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"хил",million:"млн",billion:"млрд",trillion:"трлн"},ordinal:function(a){return""},currency:{symbol:"лв"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","chs",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","cs",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"Kč"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","de",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","et",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","fi",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","hu",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(a){return"."},currency:{symbol:" Ft"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","it",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ja",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(a){return"."},currency:{symbol:"¥"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","lv",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(a){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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&&b<=1||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","no",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"."},currency:{symbol:"kr"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","pl",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(a){return"."},currency:{symbol:"PLN"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","pt-pt",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return"º"},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ru-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"₴"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","ru",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн.",billion:"млрд.",trillion:"трлн."},ordinal:function(){return"."},currency:{symbol:"руб."}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","sk",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","sl",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mrd",trillion:"trilijon"},ordinal:function(){return"."},currency:{symbol:"€"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","th",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(a){return"."},currency:{symbol:"฿"}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral"),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(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("locale","uk-ua",{delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тис.",million:"млн",billion:"млрд",trillion:"блн"},ordinal:function(){return""},currency:{symbol:"₴"}})}(); \ 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.2",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,c=c.replace(/\+/g,"")),b._.includes(c,"a")&&(e=c.match(/a(k|m|b|t)?/),e=!!e&&e[1],b._.includes(c," a")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):g=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):g=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(g=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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 a.indexOf(b)!==-1},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(;f=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;fd?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*g)/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(),b):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(a){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))&&(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))&&(i=new RegExp(e+"{2}"),!a.match(/[^\d.,]/g)&&(g=a.split(d),!(g.length>2)&&(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:"$"}}),b}),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={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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&&d0&&(d/=i);break}return g=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}),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("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),h<=1?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=h=20?"ste":"de"},currency:{symbol:"€ "}})}),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:"лв"}})}),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:"¥"}})}),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č"}})}),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"}})}),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"}})}),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:"€"}})}),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:"$"}})}),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:"£"}})}),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"}})}),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:"€"}})}),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:"$"}})}),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:"€"}})}),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:"€"}})}),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:"$"}})}),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"}})}),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:"€"}})}),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"}})}),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:"€"}})}),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:"¥"}})}),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:"€"}})}),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&&b<=1||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}),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"}})}),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"}})}),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$"}})}),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:"€"}})}),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:"₴"}})}),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:"руб."}})}),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:"€"}})}),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:"€"}})}),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:"฿"}})}),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:"₺"}})}),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/numeral.min.js b/min/numeral.min.js index 00230c88..6aad8562 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -1,8 +1,8 @@ /*! @preserve * numeral.js - * version : 2.0.1 + * version : 2.0.2 * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -(function(){function a(a,b){this._input=a,this._value=b}var b,c,d="2.0.1",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,c=c.replace(/\+/g,"")),b._.includes(c,"a")&&(e=c.match(/a(k|m|b|t)?/),e=!!e&&e[1],b._.includes(c," a")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):g=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):g=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(g=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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 a.indexOf(b)!==-1},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(;f=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;fd?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*g)/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(),b):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.");this[a+"s"][b]=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(a){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))&&(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))&&(i=new RegExp(e+"{2}"),!a.match(/[^\d.,]/g)&&(g=a.split(d),!(g.length>2)&&(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:"$"}}),"undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"==typeof ender&&(this.numeral=b),"function"==typeof define&&define.amd&&define([],function(){return b})}).call(this),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral"),b={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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&&d0&&(d/=i);break}return g=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){var a="undefined"!=typeof window&&window.numeral?window.numeral:require("../numeral");a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),h<=1?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=h=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):g=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):g=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(g=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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 a.indexOf(b)!==-1},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(;f=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;fd?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*g)/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(),b):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(a){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))&&(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))&&(i=new RegExp(e+"{2}"),!a.match(/[^\d.,]/g)&&(g=a.split(d),!(g.length>2)&&(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:"$"}}),b}),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={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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&&d0&&(d/=i);break}return g=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}),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("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),h<=1?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=h= 20) ? 'ste' : 'de'; }, currency: { symbol: '€ ' } }); -}()); +})); -/* - * numeral.js locale configuration - * locale : Bulgarian - * author : Don Vince : https://github.com/donvince/ - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -1028,16 +1047,21 @@ symbol: 'лв' } }); -}()); - -/* - * numeral.js locale configuration - * locale : simplified chinese (chs) - * author : badplum : https://github.com/badplum - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); - +})); + +// 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: ',', @@ -1056,16 +1080,21 @@ symbol: '¥' } }); -}()); +})); -/* - * numeral.js locale configuration - * locale : czech (cs) - * author : Anatoli Papirovski : https://github.com/apapirovski - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -1084,16 +1113,21 @@ symbol: 'Kč' } }); -}()); +})); -/* - * numeral.js locale configuration - * locale : danish denmark (dk) - * author : Michael Storgaard : https://github.com/mstorgaard - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: '.', @@ -1112,16 +1146,21 @@ symbol: 'DKK' } }); -}()); +})); -/* - * 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 () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -1140,16 +1179,21 @@ symbol: 'CHF' } }); -}()); +})); -/* - * numeral.js locale configuration - * locale : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium - * author : Marco Krage : https://github.com/sinky - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -1168,16 +1212,21 @@ symbol: '€' } }); -}()); +})); -/* - * numeral.js locale configuration - * locale : English Australia - * author : Don Vince : https://github.com/donvince/ - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ',', @@ -1200,16 +1249,21 @@ symbol: '$' } }); -}()); +})); -/* - * numeral.js locale configuration - * locale : english united kingdom (uk) - * author : Dan Ristic : https://github.com/dristic - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ',', @@ -1232,16 +1286,21 @@ symbol: '£' } }); -}()); +})); -/* - * numeral.js locale configuration - * locale : english south africa (uk) - * author : Etienne Boshoff : etienne@zailab.com - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -1264,16 +1323,21 @@ symbol: 'R' } }); -}()); +})); -/* - * numeral.js locale configuration - * locale : spanish Spain - * author : Hernan Garcia : https://github.com/hgarcia - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: '.', @@ -1297,16 +1361,21 @@ symbol: '€' } }); -}()); +})); -/* - * numeral.js locale configuration - * locale : spanish - * author : Hernan Garcia : https://github.com/hgarcia - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: '.', @@ -1330,19 +1399,22 @@ symbol: '$' } }); -}()); - -/* - * 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 () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +})); +// 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: ' ', @@ -1361,16 +1433,21 @@ symbol: '€' } }); -}()); +})); -/* - * numeral.js locale configuration - * locale : Finnish - * author : Sami Saada : https://github.com/samitheberber - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -1389,16 +1466,21 @@ symbol: '€' } }); -}()); +})); -/* - * numeral.js locale configuration - * locale : french (Canada) (fr-ca) - * author : Léo Renaud-Allaire : https://github.com/renaudleo - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -1417,16 +1499,21 @@ symbol: '$' } }); -}()); +})); -/* - * numeral.js locale configuration - * locale : french (fr-ch) - * author : Adam Draper : https://github.com/adamwdraper - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: '\'', @@ -1445,16 +1532,21 @@ symbol: 'CHF' } }); -}()); +})); -/* - * numeral.js locale configuration - * locale : french (fr) - * author : Adam Draper : https://github.com/adamwdraper - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -1473,16 +1565,21 @@ symbol: '€' } }); -}()); +})); -/* - * numeral.js locale configuration - * locale : Hungarian (hu) - * author : Peter Bakondy : https://github.com/pbakondy - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -1501,16 +1598,21 @@ symbol: ' Ft' } }); -}()); +})); -/* - * numeral.js locale configuration - * locale : italian Italy (it) - * author : Giacomo Trombi : http://cinquepunti.it - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: '.', @@ -1529,16 +1631,21 @@ symbol: '€' } }); -}()); +})); -/* - * numeral.js locale configuration - * locale : japanese - * author : teppeis : https://github.com/teppeis - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ',', @@ -1557,16 +1664,21 @@ symbol: '¥' } }); -}()); +})); -/* - * numeral.js locale configuration - * locale : Latvian (lv) - * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -1585,16 +1697,21 @@ symbol: '€' } }); -}()); +})); -/* - * numeral.js locale configuration - * locale : netherlands-dutch (nl-nl) - * author : Dave Clayton : https://github.com/davedx - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: '.', @@ -1614,16 +1731,21 @@ symbol: '€ ' } }); -}()); +})); -/* - * numeral.js locale configuration - * locale : norwegian (bokmål) - * author : Ove Andersen : https://github.com/azzlack - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -1642,16 +1764,21 @@ symbol: 'kr' } }); -}()); +})); -/* - * numeral.js locale configuration - * locale : polish (pl) - * author : Dominik Bulaj : https://github.com/dominikbulaj - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -1670,16 +1797,21 @@ symbol: 'PLN' } }); -}()); +})); -/* - * numeral.js locale configuration - * locale : portuguese brazil (pt-br) - * author : Ramiro Varandas Jr : https://github.com/ramirovjr - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: '.', @@ -1698,16 +1830,21 @@ symbol: 'R$' } }); -}()); +})); -/* - * numeral.js locale configuration - * locale : portuguese (pt-pt) - * author : Diogo Resende : https://github.com/dresende - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -1726,14 +1863,21 @@ symbol: '€' } }); -}()); +})); // numeral.js locale configuration // locale : Russian for the Ukraine (ru-ua) // author : Anatoli Papirovski : https://github.com/apapirovski -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +(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: ' ', @@ -1755,16 +1899,21 @@ symbol: '\u20B4' } }); -}()); +})); -/* - * numeral.js locale configuration - * locale : russian (ru) - * author : Anatoli Papirovski : https://github.com/apapirovski - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -1786,16 +1935,21 @@ symbol: 'руб.' } }); -}()); +})); -/* - * numeral.js locale configuration - * locale : slovak (sk) - * author : Ahmed Al Hafoudh : http://www.freevision.sk - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -1814,16 +1968,21 @@ symbol: '€' } }); -}()); +})); -/* - * numeral.js locale configuration - * locale : slovenian (sl) - * author : Boštjan Pišler : https://github.com/BostjanPisler - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: '.', @@ -1842,14 +2001,22 @@ symbol: '€' } }); -}()); -/* - * numeral.js locale configuration - * locale : thai (th) - * author : Sathit Jittanupat : https://github.com/jojosati - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +})); + +// 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: { @@ -1869,16 +2036,22 @@ symbol: '฿' } }); -}()); +})); -/* - * 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 () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'), - suffixes = { +// 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', @@ -1930,14 +2103,21 @@ symbol: '\u20BA' } }); -}()); +})); // 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 numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +(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: ' ', @@ -1959,4 +2139,4 @@ symbol: '\u20B4' } }); -}()); +})); diff --git a/numeral.js b/numeral.js index 57bf6a3b..fcab4a0f 100644 --- a/numeral.js +++ b/numeral.js @@ -1,19 +1,27 @@ /*! @preserve * numeral.js - * version : 2.0.1 + * version : 2.0.2 * 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 () { /************************************ Variables ************************************/ var numeral, _, - VERSION = '2.0.1', + VERSION = '2.0.2', formats = {}, locales = {}, defaults = { @@ -419,6 +427,8 @@ } this[type + 's'][name] = format; + + return format; }; @@ -637,40 +647,23 @@ } }); + return numeral; +})); - /************************************ - Exposing Numeral - ************************************/ - - // CommonJS module is defined - if (typeof module !== 'undefined' && module.exports) { - module.exports = numeral; - } - - /*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; - } +// numeral.js format configuration +// format : bytes +// author : Adam Draper : https://github.com/adamwdraper - /*global define:false */ +(function (global, factory) { if (typeof define === 'function' && define.amd) { - define([], function() { - return numeral; - }); + define(['../numeral'], factory); + } else if (typeof module === 'object' && module.exports) { + factory(require('../numeral')); + } else { + factory(global.numeral); } -}).call(this); - -/* - * numeral.js format configuration - * format : bytes - * author : Adam Draper : https://github.com/adamwdraper - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'), - decimal = { +}(this, function (numeral) { + var decimal = { base: 1000, suffixes: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] }, @@ -740,16 +733,21 @@ return value; } }); -}()); +})); -/* - * numeral.js format configuration - * format : currency - * author : Adam Draper : https://github.com/adamwdraper - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: /(\$)/ @@ -797,16 +795,21 @@ return output; } }); -}()); +})); -/* - * numeral.js format configuration - * format : exponential - * author : Adam Draper : https://github.com/adamwdraper - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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-)/, @@ -839,25 +842,21 @@ return numeral._.reduce([value, Math.pow(10, power)], cback, 1); } }); -}()); +})); -/* - * numeral.js format configuration - * format : ordinal - * author : Adam Draper : https://github.com/adamwdraper - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); - - // get numeral from environment - if (typeof window !== 'undefined' && this.numeral) { - // Browser - numeral = this.numeral; - } else if (typeof module !== 'undefined' && module.exports) { - // Node - numeral = require('../numeral'); - } +// 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)/ @@ -877,16 +876,21 @@ return output + ordinal; } }); -}()); +})); -/* - * numeral.js format configuration - * format : percentage - * author : Adam Draper : https://github.com/adamwdraper - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: /(%)/, @@ -919,16 +923,21 @@ return numeral._.stringToNumber(string) * 0.01; } }); -}()); +})); -/* - * numeral.js format configuration - * format : time - * author : Adam Draper : https://github.com/adamwdraper - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: /(:)/, @@ -962,4 +971,4 @@ return Number(seconds); } }); -}()); +})); diff --git a/package.json b/package.json index f8544185..f4ee4100 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "numeral", - "version": "2.0.1", + "version": "2.0.2", "description": "Format and manipulate numbers.", "homepage": "http://numeraljs.com/", "author": { diff --git a/src/formats/bytes.js b/src/formats/bytes.js index f22d587c..d39a8598 100644 --- a/src/formats/bytes.js +++ b/src/formats/bytes.js @@ -1,11 +1,17 @@ -/* - * numeral.js format configuration - * format : bytes - * author : Adam Draper : https://github.com/adamwdraper - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'), - decimal = { +// 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'] }, @@ -75,4 +81,4 @@ return value; } }); -}()); +})); diff --git a/src/formats/currency.js b/src/formats/currency.js index 9acc9b97..938466e4 100644 --- a/src/formats/currency.js +++ b/src/formats/currency.js @@ -1,11 +1,16 @@ -/* - * numeral.js format configuration - * format : currency - * author : Adam Draper : https://github.com/adamwdraper - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); - +// 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: /(\$)/ @@ -53,4 +58,4 @@ return output; } }); -}()); +})); diff --git a/src/formats/exponential.js b/src/formats/exponential.js index 658a0572..21459980 100644 --- a/src/formats/exponential.js +++ b/src/formats/exponential.js @@ -1,11 +1,16 @@ -/* - * numeral.js format configuration - * format : exponential - * author : Adam Draper : https://github.com/adamwdraper - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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-)/, @@ -38,4 +43,4 @@ return numeral._.reduce([value, Math.pow(10, power)], cback, 1); } }); -}()); +})); diff --git a/src/formats/ordinal.js b/src/formats/ordinal.js index 53d3d6a2..89647859 100644 --- a/src/formats/ordinal.js +++ b/src/formats/ordinal.js @@ -1,20 +1,16 @@ -/* - * numeral.js format configuration - * format : ordinal - * author : Adam Draper : https://github.com/adamwdraper - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// numeral.js format configuration +// format : ordinal +// author : Adam Draper : https://github.com/adamwdraper - // get numeral from environment - if (typeof window !== 'undefined' && this.numeral) { - // Browser - numeral = this.numeral; - } else if (typeof module !== 'undefined' && module.exports) { - // Node - numeral = require('../numeral'); +(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)/ @@ -34,4 +30,4 @@ return output + ordinal; } }); -}()); +})); diff --git a/src/formats/percentage.js b/src/formats/percentage.js index eb868d8c..bd4068fd 100644 --- a/src/formats/percentage.js +++ b/src/formats/percentage.js @@ -1,11 +1,16 @@ -/* - * numeral.js format configuration - * format : percentage - * author : Adam Draper : https://github.com/adamwdraper - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); - +// 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: /(%)/, @@ -38,4 +43,4 @@ return numeral._.stringToNumber(string) * 0.01; } }); -}()); +})); diff --git a/src/formats/time.js b/src/formats/time.js index 765409d9..b2d6737f 100644 --- a/src/formats/time.js +++ b/src/formats/time.js @@ -1,11 +1,16 @@ -/* - * numeral.js format configuration - * format : time - * author : Adam Draper : https://github.com/adamwdraper - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: /(:)/, @@ -39,4 +44,4 @@ return Number(seconds); } }); -}()); +})); diff --git a/src/locales/be-nl.js b/src/locales/be-nl.js index f354603c..15d948f5 100644 --- a/src/locales/be-nl.js +++ b/src/locales/be-nl.js @@ -1,11 +1,16 @@ -/* - * numeral.js locale configuration - * locale : belgium-dutch (be-nl) - * author : Dieter Luypaert : https://github.com/moeriki - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// numeral.js locale configuration +// locale : belgium-dutch (be-nl) +// author : Dieter Luypaert : https://github.com/moeriki +(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', 'be-nl', { delimiters: { thousands: ' ', @@ -19,11 +24,11 @@ }, 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/bg.js b/src/locales/bg.js index 2c236ab6..ef71941c 100644 --- a/src/locales/bg.js +++ b/src/locales/bg.js @@ -1,11 +1,16 @@ -/* - * numeral.js locale configuration - * locale : Bulgarian - * author : Don Vince : https://github.com/donvince/ - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -32,4 +37,4 @@ symbol: 'лв' } }); -}()); +})); diff --git a/src/locales/chs.js b/src/locales/chs.js index 793ad468..1bcc9462 100644 --- a/src/locales/chs.js +++ b/src/locales/chs.js @@ -1,11 +1,16 @@ -/* - * numeral.js locale configuration - * locale : simplified chinese (chs) - * author : badplum : https://github.com/badplum - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); - +// 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: ',', @@ -24,4 +29,4 @@ symbol: '¥' } }); -}()); +})); diff --git a/src/locales/cs.js b/src/locales/cs.js index 9da485b8..316051f2 100644 --- a/src/locales/cs.js +++ b/src/locales/cs.js @@ -1,11 +1,16 @@ -/* - * numeral.js locale configuration - * locale : czech (cs) - * author : Anatoli Papirovski : https://github.com/apapirovski - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -24,4 +29,4 @@ symbol: 'Kč' } }); -}()); +})); diff --git a/src/locales/da-dk.js b/src/locales/da-dk.js index 252c6430..c21e5a78 100644 --- a/src/locales/da-dk.js +++ b/src/locales/da-dk.js @@ -1,11 +1,16 @@ -/* - * numeral.js locale configuration - * locale : danish denmark (dk) - * author : Michael Storgaard : https://github.com/mstorgaard - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: '.', @@ -24,4 +29,4 @@ symbol: 'DKK' } }); -}()); +})); diff --git a/src/locales/de-ch.js b/src/locales/de-ch.js index 5a02adbd..5921e46c 100644 --- a/src/locales/de-ch.js +++ b/src/locales/de-ch.js @@ -1,11 +1,16 @@ -/* - * 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 () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -24,4 +29,4 @@ symbol: 'CHF' } }); -}()); +})); diff --git a/src/locales/de.js b/src/locales/de.js index a5ee36d1..87f87880 100644 --- a/src/locales/de.js +++ b/src/locales/de.js @@ -1,11 +1,16 @@ -/* - * numeral.js locale configuration - * locale : German (de) – generally useful in Germany, Austria, Luxembourg, Belgium - * author : Marco Krage : https://github.com/sinky - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -24,4 +29,4 @@ symbol: '€' } }); -}()); +})); diff --git a/src/locales/en-au.js b/src/locales/en-au.js index 8d3297af..6202c842 100644 --- a/src/locales/en-au.js +++ b/src/locales/en-au.js @@ -1,11 +1,16 @@ -/* - * numeral.js locale configuration - * locale : English Australia - * author : Don Vince : https://github.com/donvince/ - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ',', @@ -28,4 +33,4 @@ symbol: '$' } }); -}()); +})); diff --git a/src/locales/en-gb.js b/src/locales/en-gb.js index f38b51f8..a51190eb 100644 --- a/src/locales/en-gb.js +++ b/src/locales/en-gb.js @@ -1,11 +1,16 @@ -/* - * numeral.js locale configuration - * locale : english united kingdom (uk) - * author : Dan Ristic : https://github.com/dristic - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ',', @@ -28,4 +33,4 @@ symbol: '£' } }); -}()); +})); diff --git a/src/locales/en-za.js b/src/locales/en-za.js index 96c47089..8417268d 100644 --- a/src/locales/en-za.js +++ b/src/locales/en-za.js @@ -1,11 +1,16 @@ -/* - * numeral.js locale configuration - * locale : english south africa (uk) - * author : Etienne Boshoff : etienne@zailab.com - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -28,4 +33,4 @@ symbol: 'R' } }); -}()); +})); diff --git a/src/locales/es-es.js b/src/locales/es-es.js index d9ae9943..31e7de5b 100644 --- a/src/locales/es-es.js +++ b/src/locales/es-es.js @@ -1,11 +1,16 @@ -/* - * numeral.js locale configuration - * locale : spanish Spain - * author : Hernan Garcia : https://github.com/hgarcia - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: '.', @@ -29,4 +34,4 @@ symbol: '€' } }); -}()); +})); diff --git a/src/locales/es.js b/src/locales/es.js index 2cdeb99a..7ca71950 100644 --- a/src/locales/es.js +++ b/src/locales/es.js @@ -1,11 +1,16 @@ -/* - * numeral.js locale configuration - * locale : spanish - * author : Hernan Garcia : https://github.com/hgarcia - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: '.', @@ -29,4 +34,4 @@ symbol: '$' } }); -}()); +})); diff --git a/src/locales/et.js b/src/locales/et.js index bdd03d8f..f8269e12 100644 --- a/src/locales/et.js +++ b/src/locales/et.js @@ -1,14 +1,17 @@ -/* - * 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 () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -27,4 +30,4 @@ symbol: '€' } }); -}()); +})); diff --git a/src/locales/fi.js b/src/locales/fi.js index 8460a553..25eaa7fd 100644 --- a/src/locales/fi.js +++ b/src/locales/fi.js @@ -1,11 +1,16 @@ -/* - * numeral.js locale configuration - * locale : Finnish - * author : Sami Saada : https://github.com/samitheberber - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -24,4 +29,4 @@ symbol: '€' } }); -}()); +})); diff --git a/src/locales/fr-ca.js b/src/locales/fr-ca.js index 7d983e2d..f8dd2061 100644 --- a/src/locales/fr-ca.js +++ b/src/locales/fr-ca.js @@ -1,11 +1,16 @@ -/* - * numeral.js locale configuration - * locale : french (Canada) (fr-ca) - * author : Léo Renaud-Allaire : https://github.com/renaudleo - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -24,4 +29,4 @@ symbol: '$' } }); -}()); +})); diff --git a/src/locales/fr-ch.js b/src/locales/fr-ch.js index 1f3abb33..ea29b39c 100644 --- a/src/locales/fr-ch.js +++ b/src/locales/fr-ch.js @@ -1,11 +1,16 @@ -/* - * numeral.js locale configuration - * locale : french (fr-ch) - * author : Adam Draper : https://github.com/adamwdraper - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: '\'', @@ -24,4 +29,4 @@ symbol: 'CHF' } }); -}()); +})); diff --git a/src/locales/fr.js b/src/locales/fr.js index 029203b6..5ddc609d 100644 --- a/src/locales/fr.js +++ b/src/locales/fr.js @@ -1,11 +1,16 @@ -/* - * numeral.js locale configuration - * locale : french (fr) - * author : Adam Draper : https://github.com/adamwdraper - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -24,4 +29,4 @@ symbol: '€' } }); -}()); +})); diff --git a/src/locales/hu.js b/src/locales/hu.js index dab4b6d1..a3d7638a 100644 --- a/src/locales/hu.js +++ b/src/locales/hu.js @@ -1,11 +1,16 @@ -/* - * numeral.js locale configuration - * locale : Hungarian (hu) - * author : Peter Bakondy : https://github.com/pbakondy - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -24,4 +29,4 @@ symbol: ' Ft' } }); -}()); +})); diff --git a/src/locales/it.js b/src/locales/it.js index 585bea92..a5d3406e 100644 --- a/src/locales/it.js +++ b/src/locales/it.js @@ -1,11 +1,16 @@ -/* - * numeral.js locale configuration - * locale : italian Italy (it) - * author : Giacomo Trombi : http://cinquepunti.it - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: '.', @@ -24,4 +29,4 @@ symbol: '€' } }); -}()); +})); diff --git a/src/locales/ja.js b/src/locales/ja.js index 7b67f582..bb6c8a1e 100644 --- a/src/locales/ja.js +++ b/src/locales/ja.js @@ -1,11 +1,16 @@ -/* - * numeral.js locale configuration - * locale : japanese - * author : teppeis : https://github.com/teppeis - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ',', @@ -24,4 +29,4 @@ symbol: '¥' } }); -}()); +})); diff --git a/src/locales/lv.js b/src/locales/lv.js index 05590fb8..cc46c0e7 100644 --- a/src/locales/lv.js +++ b/src/locales/lv.js @@ -1,11 +1,16 @@ -/* - * numeral.js locale configuration - * locale : Latvian (lv) - * author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -24,4 +29,4 @@ symbol: '€' } }); -}()); +})); diff --git a/src/locales/nl-nl.js b/src/locales/nl-nl.js index 49c5e51d..00f70f7c 100644 --- a/src/locales/nl-nl.js +++ b/src/locales/nl-nl.js @@ -1,11 +1,16 @@ -/* - * numeral.js locale configuration - * locale : netherlands-dutch (nl-nl) - * author : Dave Clayton : https://github.com/davedx - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: '.', @@ -25,4 +30,4 @@ symbol: '€ ' } }); -}()); +})); diff --git a/src/locales/no.js b/src/locales/no.js index 9f44feb9..2a2b06c8 100644 --- a/src/locales/no.js +++ b/src/locales/no.js @@ -1,11 +1,16 @@ -/* - * numeral.js locale configuration - * locale : norwegian (bokmål) - * author : Ove Andersen : https://github.com/azzlack - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -24,4 +29,4 @@ symbol: 'kr' } }); -}()); +})); diff --git a/src/locales/pl.js b/src/locales/pl.js index 801ad448..b336c090 100644 --- a/src/locales/pl.js +++ b/src/locales/pl.js @@ -1,11 +1,16 @@ -/* - * numeral.js locale configuration - * locale : polish (pl) - * author : Dominik Bulaj : https://github.com/dominikbulaj - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -24,4 +29,4 @@ symbol: 'PLN' } }); -}()); +})); diff --git a/src/locales/pt-br.js b/src/locales/pt-br.js index 8650b27c..94d384b3 100644 --- a/src/locales/pt-br.js +++ b/src/locales/pt-br.js @@ -1,11 +1,16 @@ -/* - * numeral.js locale configuration - * locale : portuguese brazil (pt-br) - * author : Ramiro Varandas Jr : https://github.com/ramirovjr - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: '.', @@ -24,4 +29,4 @@ symbol: 'R$' } }); -}()); +})); diff --git a/src/locales/pt-pt.js b/src/locales/pt-pt.js index 27e34b17..9bf59770 100644 --- a/src/locales/pt-pt.js +++ b/src/locales/pt-pt.js @@ -1,11 +1,16 @@ -/* - * numeral.js locale configuration - * locale : portuguese (pt-pt) - * author : Diogo Resende : https://github.com/dresende - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -24,4 +29,4 @@ symbol: '€' } }); -}()); +})); diff --git a/src/locales/ru-ua.js b/src/locales/ru-ua.js index 4b46e542..798f94f4 100644 --- a/src/locales/ru-ua.js +++ b/src/locales/ru-ua.js @@ -1,9 +1,16 @@ // numeral.js locale configuration // locale : Russian for the Ukraine (ru-ua) // author : Anatoli Papirovski : https://github.com/apapirovski -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +(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: ' ', @@ -25,4 +32,4 @@ symbol: '\u20B4' } }); -}()); +})); diff --git a/src/locales/ru.js b/src/locales/ru.js index db4b2c7a..34dfb7f9 100644 --- a/src/locales/ru.js +++ b/src/locales/ru.js @@ -1,11 +1,16 @@ -/* - * numeral.js locale configuration - * locale : russian (ru) - * author : Anatoli Papirovski : https://github.com/apapirovski - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -27,4 +32,4 @@ symbol: 'руб.' } }); -}()); +})); diff --git a/src/locales/sk.js b/src/locales/sk.js index aa3ee673..cb0e898d 100644 --- a/src/locales/sk.js +++ b/src/locales/sk.js @@ -1,11 +1,16 @@ -/* - * numeral.js locale configuration - * locale : slovak (sk) - * author : Ahmed Al Hafoudh : http://www.freevision.sk - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: ' ', @@ -24,4 +29,4 @@ symbol: '€' } }); -}()); +})); diff --git a/src/locales/sl.js b/src/locales/sl.js index fbd82318..2f1117eb 100644 --- a/src/locales/sl.js +++ b/src/locales/sl.js @@ -1,11 +1,16 @@ -/* - * numeral.js locale configuration - * locale : slovenian (sl) - * author : Boštjan Pišler : https://github.com/BostjanPisler - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: '.', @@ -24,4 +29,4 @@ symbol: '€' } }); -}()); \ No newline at end of file +})); diff --git a/src/locales/th.js b/src/locales/th.js index 98f789d8..d3e08d00 100644 --- a/src/locales/th.js +++ b/src/locales/th.js @@ -1,10 +1,17 @@ -/* - * numeral.js locale configuration - * locale : thai (th) - * author : Sathit Jittanupat : https://github.com/jojosati - */ -(function () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +// 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: { @@ -24,4 +31,4 @@ symbol: '฿' } }); -}()); +})); diff --git a/src/locales/tr.js b/src/locales/tr.js index f39c3435..07f7ffdd 100644 --- a/src/locales/tr.js +++ b/src/locales/tr.js @@ -1,11 +1,17 @@ -/* - * 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 () { - var numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'), - suffixes = { +// 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', @@ -57,4 +63,4 @@ symbol: '\u20BA' } }); -}()); +})); diff --git a/src/locales/uk-ua.js b/src/locales/uk-ua.js index cc1e48d6..34b31037 100644 --- a/src/locales/uk-ua.js +++ b/src/locales/uk-ua.js @@ -1,9 +1,16 @@ // 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 numeral = typeof window !== 'undefined' && window.numeral ? window.numeral : require('../numeral'); +(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: ' ', @@ -25,4 +32,4 @@ symbol: '\u20B4' } }); -}()); +})); diff --git a/src/numeral.js b/src/numeral.js index a7812902..8bc558a5 100644 --- a/src/numeral.js +++ b/src/numeral.js @@ -1,19 +1,27 @@ /*! @preserve * numeral.js - * version : 2.0.1 + * version : 2.0.2 * 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 () { /************************************ Variables ************************************/ var numeral, _, - VERSION = '2.0.1', + VERSION = '2.0.2', formats = {}, locales = {}, defaults = { @@ -419,6 +427,8 @@ } this[type + 's'][name] = format; + + return format; }; @@ -637,28 +647,5 @@ } }); - - /************************************ - Exposing Numeral - ************************************/ - - // CommonJS module is defined - if (typeof module !== 'undefined' && module.exports) { - module.exports = numeral; - } - - /*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; - } - - /*global define:false */ - if (typeof define === 'function' && define.amd) { - define([], function() { - return numeral; - }); - } -}).call(this); + return numeral; +})); From 1eb0f76dbe8874a5ee190f31d2ad840f39c4075f Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Fri, 16 Dec 2016 00:25:26 -0800 Subject: [PATCH 119/150] update build with custom wrappers --- .gitignore | 1 + Gruntfile.js | 121 +- locales.js | 602 ++------- min/locales.min.js | 8 +- min/numeral-with-locales.min.js | 8 - min/numeral.min.js | 8 +- numeral-with-locales.js | 2142 ------------------------------- numeral.js | 105 +- templates/anon.js | 3 + templates/types.js | 18 + 10 files changed, 283 insertions(+), 2733 deletions(-) delete mode 100644 min/numeral-with-locales.min.js delete mode 100644 numeral-with-locales.js create mode 100644 templates/anon.js create mode 100644 templates/types.js diff --git a/.gitignore b/.gitignore index 23aa3505..2b80bbd1 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ Icon # -------------------- node_modules/ .sass-cache +temp/ diff --git a/Gruntfile.js b/Gruntfile.js index 0968fc68..5fd604b6 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,27 +1,34 @@ -var fs = require('fs'); - module.exports = function(grunt) { - var minifiedFiles = { - 'min/numeral.min.js' : [ - 'numeral.js' - ], - 'min/locales.min.js': [ - 'locales.js' - ], - 'min/numeral-with-locales.min.js': [ - 'numeral-with-locales.js' - ] - }; + var compileFile = 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('./src/locales').forEach(function (path) { - var file = path.slice(0, -3), - destination = 'min/locales/' + file + '.min.js', - src = ['src/locales/' + 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', grunt.template.process(template, { + data: { + type: type, + content: content + } + })); + }; grunt.initConfig({ mochaTest : { @@ -58,9 +65,36 @@ module.exports = function(grunt) { configFile: 'karma-ci.conf.js' } }, + 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' @@ -70,23 +104,15 @@ module.exports = function(grunt) { numeral: { src: [ 'src/numeral.js', - 'src/formats/*.js' + 'temp/formats.js' ], dest: 'numeral.js' }, locales: { src: [ - 'src/locales/*.js' + 'temp/locales.js' ], dest: 'locales.js' - }, - numeralWithLocales: { - src: [ - 'src/numeral.js', - 'src/formats/*.js', - 'src/locales/*.js' - ], - dest: 'numeral-with-locales.js' } }, jshint: { @@ -121,6 +147,36 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-mocha-test'); grunt.loadNpmTasks('grunt-karma'); + grunt.registerTask('build:locales', function() { + var template = grunt.file.read('templates/locales.js'); + var anon = grunt.file.read('templates/anon.js'); + var files = grunt.file.expand([ + 'src/locales/*.js' + ]); + var regexp = /}\(this, function \(numeral\) {\s([\s\S]+)(?:\s}\)\);)/; + var content = ''; + var file; + var i; + + for (i = 0; i < files.length; i++) { + file = grunt.file.read(files[i]); + + content += '\n' + grunt.template.process(anon, { + data: { + content: file.match(regexp)[1] + } + }) + '\n'; + } + + grunt.file.write('locales.js', grunt.template.process(template, { + data: { + content: content + } + })); + }); + + grunt.registerMultiTask('compile', compileFile); + grunt.registerTask('default', [ 'test' ]); @@ -143,6 +199,7 @@ module.exports = function(grunt) { // P grunt.registerTask('build', [ + 'compile', 'concat', 'uglify' ]); diff --git a/locales.js b/locales.js index 4f8e3ef8..0b66f855 100644 --- a/locales.js +++ b/locales.js @@ -1,17 +1,22 @@ -// numeral.js locale configuration -// locale : belgium-dutch (be-nl) -// author : Dieter Luypaert : https://github.com/moeriki +/*! @preserve + * numeral.js + * locales: 2.0.2 + * license : MIT + * http://adamwdraper.github.com/Numeral-js/ + */ (function (global, factory) { if (typeof define === 'function' && define.amd) { - define(['../numeral'], factory); + define(['numeral'], factory); } else if (typeof module === 'object' && module.exports) { - factory(require('../numeral')); + factory(require('numeral')); } else { factory(global.numeral); } }(this, function (numeral) { - numeral.register('locale', 'be-nl', { + +(function() { + numeral.register('locale', 'be-nl', { delimiters: { thousands: ' ', decimal : ',' @@ -31,22 +36,11 @@ symbol: '€ ' } }); -})); +})(); -// 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', { +(function() { + numeral.register('locale', 'bg', { delimiters: { thousands: ' ', decimal: ',' @@ -72,55 +66,34 @@ symbol: 'лв' } }); -})); +})(); -// 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: '¥' - } - }); -})); -// numeral.js locale configuration -// locale : czech (cs) -// author : Anatoli Papirovski : https://github.com/apapirovski +(function() { + + numeral.register('locale', 'chs', { + delimiters: { + thousands: ',', + decimal: '.' + }, + abbreviations: { + thousand: '千', + million: '百万', + billion: '十亿', + trillion: '兆' + }, + ordinal: function (number) { + return '.'; + }, + currency: { + symbol: '¥' + } + }); +})(); + -(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', { +(function() { + numeral.register('locale', 'cs', { delimiters: { thousands: ' ', decimal: ',' @@ -138,22 +111,11 @@ symbol: 'Kč' } }); -})); +})(); -// 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', { +(function() { + numeral.register('locale', 'da-dk', { delimiters: { thousands: '.', decimal: ',' @@ -171,22 +133,11 @@ symbol: 'DKK' } }); -})); +})(); -// 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', { +(function() { + numeral.register('locale', 'de-ch', { delimiters: { thousands: ' ', decimal: ',' @@ -204,22 +155,11 @@ symbol: 'CHF' } }); -})); +})(); -// 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', { +(function() { + numeral.register('locale', 'de', { delimiters: { thousands: ' ', decimal: ',' @@ -237,22 +177,11 @@ symbol: '€' } }); -})); +})(); -// 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', { +(function() { + numeral.register('locale', 'en-au', { delimiters: { thousands: ',', decimal: '.' @@ -274,22 +203,11 @@ symbol: '$' } }); -})); +})(); -// 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', { +(function() { + numeral.register('locale', 'en-gb', { delimiters: { thousands: ',', decimal: '.' @@ -311,22 +229,11 @@ symbol: '£' } }); -})); +})(); -// 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', { +(function() { + numeral.register('locale', 'en-za', { delimiters: { thousands: ' ', decimal: ',' @@ -348,22 +255,11 @@ symbol: 'R' } }); -})); +})(); -// 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', { +(function() { + numeral.register('locale', 'es-es', { delimiters: { thousands: '.', decimal: ',' @@ -386,22 +282,11 @@ symbol: '€' } }); -})); +})(); -// 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', { +(function() { + numeral.register('locale', 'es', { delimiters: { thousands: '.', decimal: ',' @@ -424,23 +309,11 @@ symbol: '$' } }); -})); +})(); -// 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', { +(function() { + numeral.register('locale', 'et', { delimiters: { thousands: ' ', decimal: ',' @@ -458,22 +331,11 @@ symbol: '€' } }); -})); +})(); -// 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', { +(function() { + numeral.register('locale', 'fi', { delimiters: { thousands: ' ', decimal: ',' @@ -491,22 +353,11 @@ symbol: '€' } }); -})); +})(); -// 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', { +(function() { + numeral.register('locale', 'fr-ca', { delimiters: { thousands: ' ', decimal: ',' @@ -524,22 +375,11 @@ symbol: '$' } }); -})); +})(); -// 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', { +(function() { + numeral.register('locale', 'fr-ch', { delimiters: { thousands: '\'', decimal: '.' @@ -557,22 +397,11 @@ symbol: 'CHF' } }); -})); +})(); -// 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', { +(function() { + numeral.register('locale', 'fr', { delimiters: { thousands: ' ', decimal: ',' @@ -590,22 +419,11 @@ symbol: '€' } }); -})); +})(); -// 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', { +(function() { + numeral.register('locale', 'hu', { delimiters: { thousands: ' ', decimal: ',' @@ -623,22 +441,11 @@ symbol: ' Ft' } }); -})); +})(); -// 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', { +(function() { + numeral.register('locale', 'it', { delimiters: { thousands: '.', decimal: ',' @@ -656,22 +463,11 @@ symbol: '€' } }); -})); +})(); -// 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', { +(function() { + numeral.register('locale', 'ja', { delimiters: { thousands: ',', decimal: '.' @@ -689,22 +485,11 @@ symbol: '¥' } }); -})); +})(); -// 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', { +(function() { + numeral.register('locale', 'lv', { delimiters: { thousands: ' ', decimal: ',' @@ -722,22 +507,11 @@ symbol: '€' } }); -})); +})(); -// 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', { +(function() { + numeral.register('locale', 'nl-nl', { delimiters: { thousands: '.', decimal : ',' @@ -756,22 +530,11 @@ symbol: '€ ' } }); -})); +})(); -// 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', { +(function() { + numeral.register('locale', 'no', { delimiters: { thousands: ' ', decimal: ',' @@ -789,22 +552,11 @@ symbol: 'kr' } }); -})); +})(); -// 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', { +(function() { + numeral.register('locale', 'pl', { delimiters: { thousands: ' ', decimal: ',' @@ -822,22 +574,11 @@ symbol: 'PLN' } }); -})); +})(); -// 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', { +(function() { + numeral.register('locale', 'pt-br', { delimiters: { thousands: '.', decimal: ',' @@ -855,22 +596,11 @@ symbol: 'R$' } }); -})); +})(); -// 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', { +(function() { + numeral.register('locale', 'pt-pt', { delimiters: { thousands: ' ', decimal: ',' @@ -888,22 +618,11 @@ symbol: '€' } }); -})); +})(); -// 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', { +(function() { + numeral.register('locale', 'ru-ua', { delimiters: { thousands: ' ', decimal: ',' @@ -924,22 +643,11 @@ symbol: '\u20B4' } }); -})); +})(); -// 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', { +(function() { + numeral.register('locale', 'ru', { delimiters: { thousands: ' ', decimal: ',' @@ -960,22 +668,11 @@ symbol: 'руб.' } }); -})); +})(); -// 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', { +(function() { + numeral.register('locale', 'sk', { delimiters: { thousands: ' ', decimal: ',' @@ -993,22 +690,11 @@ symbol: '€' } }); -})); +})(); -// 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', { +(function() { + numeral.register('locale', 'sl', { delimiters: { thousands: '.', decimal: ',' @@ -1026,22 +712,11 @@ symbol: '€' } }); -})); +})(); -// 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) { +(function() { + numeral.register('locale', 'th', { delimiters: { @@ -1061,22 +736,11 @@ symbol: '฿' } }); -})); +})(); -// 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 = { +(function() { + var suffixes = { 1: '\'inci', 5: '\'inci', 8: '\'inci', @@ -1128,22 +792,11 @@ symbol: '\u20BA' } }); -})); +})(); -// 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', { +(function() { + numeral.register('locale', 'uk-ua', { delimiters: { thousands: ' ', decimal: ',' @@ -1164,4 +817,7 @@ symbol: '\u20B4' } }); +})(); + + })); diff --git a/min/locales.min.js b/min/locales.min.js index 43b6cd12..33c24cc6 100644 --- a/min/locales.min.js +++ b/min/locales.min.js @@ -1 +1,7 @@ -!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:"€ "}})}),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:"лв"}})}),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:"¥"}})}),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č"}})}),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"}})}),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"}})}),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:"€"}})}),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:"$"}})}),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:"£"}})}),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"}})}),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:"€"}})}),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:"$"}})}),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:"€"}})}),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:"€"}})}),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:"$"}})}),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"}})}),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:"€"}})}),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"}})}),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:"€"}})}),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:"¥"}})}),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:"€"}})}),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&&b<=1||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}),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"}})}),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"}})}),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$"}})}),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:"€"}})}),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:"₴"}})}),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:"руб."}})}),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:"€"}})}),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:"€"}})}),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:"฿"}})}),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:"₺"}})}),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 +/*! @preserve + * numeral.js + * locales: 2.0.2 + * 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","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:"€ "}})}(),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-nl",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mln",billion:"mrd",trillion:"bln"},ordinal:function(a){var b=a%100;return 0!==a&&b<=1||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:"₴"}})}()}); \ No newline at end of file diff --git a/min/numeral-with-locales.min.js b/min/numeral-with-locales.min.js deleted file mode 100644 index 2a343eb5..00000000 --- a/min/numeral-with-locales.min.js +++ /dev/null @@ -1,8 +0,0 @@ -/*! @preserve - * numeral.js - * version : 2.0.2 - * author : Adam Draper - * license : MIT - * http://adamwdraper.github.com/Numeral-js/ - */ -!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.2",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,c=c.replace(/\+/g,"")),b._.includes(c,"a")&&(e=c.match(/a(k|m|b|t)?/),e=!!e&&e[1],b._.includes(c," a")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):g=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):g=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(g=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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 a.indexOf(b)!==-1},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(;f=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;fd?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*g)/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(),b):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(a){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))&&(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))&&(i=new RegExp(e+"{2}"),!a.match(/[^\d.,]/g)&&(g=a.split(d),!(g.length>2)&&(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:"$"}}),b}),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={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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&&d0&&(d/=i);break}return g=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}),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("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),h<=1?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=h=20?"ste":"de"},currency:{symbol:"€ "}})}),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:"лв"}})}),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:"¥"}})}),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č"}})}),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"}})}),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"}})}),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:"€"}})}),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:"$"}})}),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:"£"}})}),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"}})}),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:"€"}})}),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:"$"}})}),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:"€"}})}),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:"€"}})}),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:"$"}})}),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"}})}),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:"€"}})}),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"}})}),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:"€"}})}),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:"¥"}})}),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:"€"}})}),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&&b<=1||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}),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"}})}),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"}})}),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$"}})}),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:"€"}})}),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:"₴"}})}),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:"руб."}})}),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:"€"}})}),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:"€"}})}),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:"฿"}})}),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:"₺"}})}),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/numeral.min.js b/min/numeral.min.js index 6aad8562..da9c7cbc 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,10 @@ * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -!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.2",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,c=c.replace(/\+/g,"")),b._.includes(c,"a")&&(e=c.match(/a(k|m|b|t)?/),e=!!e&&e[1],b._.includes(c," a")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):g=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):g=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(g=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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 a.indexOf(b)!==-1},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(;f=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;fd?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*g)/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(),b):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(a){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))&&(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))&&(i=new RegExp(e+"{2}"),!a.match(/[^\d.,]/g)&&(g=a.split(d),!(g.length>2)&&(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:"$"}}),b}),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={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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&&d0&&(d/=i);break}return g=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}),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("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),h<=1?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=h=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):g=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):g=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(g=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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 a.indexOf(b)!==-1},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(;f=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;fd?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*g)/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(),b):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(a){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))&&(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))&&(i=new RegExp(e+"{2}"),!a.match(/[^\d.,]/g)&&(g=a.split(d),!(g.length>2)&&(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:"$"}}),b}),/*! @preserve + * numeral.js + * formats: 2.0.2 + * 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(){var b={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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&&d0&&(d/=i);break}return g=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),h<=1?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=h= 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; - } - } - - - if (numeral._.includes(format, '[.]')) { - optDec = true; - format = format.replace('[.]', '.'); - } - - int = value.toString().split('.')[0]; - precision = format.split('.')[1]; - thousands = format.indexOf(','); - - 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, null, roundingFunction); - } - - // format number - if (numeral._.includes(int, '-')) { - int = int.slice(1); - neg = true; - } - - if (thousands > -1) { - int = int.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + locale.delimiters.thousands); - } - - if (format.indexOf('.') === 0) { - int = ''; - } - - return (negP && neg ? '(' : '') + (!negP && neg ? '-' : '') + (!neg && signed ? '+' : '') + int + decimal + (abbr ? abbr : '') + (negP && neg ? ')' : ''); - }, - // 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; - }, - 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); - - //roundingFunction = (roundingFunction !== undefined ? roundingFunction : Math.round); - // Multiply up by precision, round accurately, then divide and use native toFixed(): - output = (roundingFunction(value * power) / 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) { - return options.currentLocale; - } - - options.currentLocale = key.toLowerCase(); - - return numeral; - }; - - // 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; -})); - -// 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'] - }; - - numeral.register('format', 'bytes', { - regexps: { - format: /([0\s]i?b)/, - unformat: new RegExp('(' + decimal.suffixes.concat(binary.suffixes).join('|') + ')') - }, - 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; - } - }); -})); - -// 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], - symbolIndex = format.indexOf('$'), - openParenIndex = format.indexOf('('), - minusSignIndex = format.indexOf('-'), - space = numeral._.includes(format, ' $') || numeral._.includes(format, '$ ') ? ' ' : '', - spliceIndex, - output; - - // strip format of spaces and $ - format = format.replace(/\s?\$\s?/, ''); - - // format the number - output = numeral._.numberToFormat(value, format, roundingFunction); - - // position the symbol - if (symbolIndex <= 1) { - if (numeral._.includes(output, '(') || numeral._.includes(output, '-')) { - output = output.split(''); - - spliceIndex = symbolIndex < openParenIndex || symbolIndex < minusSignIndex ? 0 : 1; - - output.splice(spliceIndex, 0, locale.currency.symbol + space); - - output = output.join(''); - } else { - output = locale.currency.symbol + space + output; - } - } else { - if (numeral._.includes(output, ')')) { - output = output.split(''); - - output.splice(-1, 0, space + locale.currency.symbol); - - output = output.join(''); - } else { - output = output + space + locale.currency.symbol; - } - } - - return output; - } - }); -})); - -// 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); - } - }); -})); - -// 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; - } - }); -})); - -// 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; - - 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) { - return numeral._.stringToNumber(string) * 0.01; - } - }); -})); - -// 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); - } - }); -})); - -// numeral.js locale configuration -// locale : belgium-dutch (be-nl) -// author : Dieter Luypaert : https://github.com/moeriki - -(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', 'be-nl', { - 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: '€ ' - } - }); -})); - -// 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: 'лв' - } - }); -})); - -// 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: '¥' - } - }); -})); - -// 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č' - } - }); -})); - -// 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' - } - }); -})); - -// 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' - } - }); -})); - -// 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: '€' - } - }); -})); - -// 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: '$' - } - }); -})); - -// 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: '£' - } - }); -})); - -// 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' - } - }); -})); - -// 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: '€' - } - }); -})); - -// 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: '$' - } - }); -})); - -// 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: '€' - } - }); -})); - -// 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: '€' - } - }); -})); - -// 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: '$' - } - }); -})); - -// 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' - } - }); -})); - -// 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: '€' - } - }); -})); - -// 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' - } - }); -})); - -// 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: '€' - } - }); -})); - -// 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: '¥' - } - }); -})); - -// 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: '€' - } - }); -})); - -// 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: '€ ' - } - }); -})); - -// 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' - } - }); -})); - -// 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' - } - }); -})); - -// 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$' - } - }); -})); - -// 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: '€' - } - }); -})); - -// 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' - } - }); -})); - -// 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: 'руб.' - } - }); -})); - -// 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: '€' - } - }); -})); - -// 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: '€' - } - }); -})); - -// 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: '฿' - } - }); -})); - -// 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' - } - }); -})); - -// 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/numeral.js b/numeral.js index fcab4a0f..5a0ad090 100644 --- a/numeral.js +++ b/numeral.js @@ -650,20 +650,25 @@ return numeral; })); -// numeral.js format configuration -// format : bytes -// author : Adam Draper : https://github.com/adamwdraper +/*! @preserve + * numeral.js + * formats: 2.0.2 + * license : MIT + * http://adamwdraper.github.com/Numeral-js/ + */ (function (global, factory) { if (typeof define === 'function' && define.amd) { - define(['../numeral'], factory); + define(['numeral'], factory); } else if (typeof module === 'object' && module.exports) { - factory(require('../numeral')); + factory(require('numeral')); } else { factory(global.numeral); } }(this, function (numeral) { - var decimal = { + +(function() { + var decimal = { base: 1000, suffixes: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] }, @@ -733,22 +738,11 @@ return value; } }); -})); +})(); -// 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', { +(function() { + numeral.register('format', 'currency', { regexps: { format: /(\$)/ }, @@ -795,22 +789,11 @@ return output; } }); -})); +})(); -// 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', { +(function() { + numeral.register('format', 'exponential', { regexps: { format: /(e\+|e-)/, unformat: /(e\+|e-)/ @@ -842,22 +825,11 @@ return numeral._.reduce([value, Math.pow(10, power)], cback, 1); } }); -})); +})(); -// 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', { +(function() { + numeral.register('format', 'ordinal', { regexps: { format: /(o)/ }, @@ -876,22 +848,11 @@ return output + ordinal; } }); -})); +})(); -// 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', { +(function() { + numeral.register('format', 'percentage', { regexps: { format: /(%)/, unformat: /(%)/ @@ -923,22 +884,11 @@ return numeral._.stringToNumber(string) * 0.01; } }); -})); +})(); -// 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', { +(function() { + numeral.register('format', 'time', { regexps: { format: /(:)/, unformat: /(:)/ @@ -971,4 +921,7 @@ return Number(seconds); } }); +})(); + + })); 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..88a63a28 --- /dev/null +++ b/templates/types.js @@ -0,0 +1,18 @@ +/*! @preserve + * numeral.js + * <%= type %>: 2.0.2 + * 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 %> +})); From 0d9c740e9668fcb5228105398a9c15a9f30692c1 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Fri, 16 Dec 2016 22:23:08 -0800 Subject: [PATCH 120/150] create dist dir for final builds --- Gruntfile.js | 113 ++++++++++++----------------- locales.js => dist/locales.js | 2 +- dist/locales.min.js | 7 ++ {min => dist}/locales/be-nl.min.js | 2 +- {min => dist}/locales/bg.min.js | 0 {min => dist}/locales/chs.min.js | 0 {min => dist}/locales/cs.min.js | 0 {min => dist}/locales/da-dk.min.js | 0 {min => dist}/locales/de-ch.min.js | 0 {min => dist}/locales/de.min.js | 0 {min => dist}/locales/en-au.min.js | 0 {min => dist}/locales/en-gb.min.js | 0 {min => dist}/locales/en-za.min.js | 0 {min => dist}/locales/es-es.min.js | 0 {min => dist}/locales/es.min.js | 0 {min => dist}/locales/et.min.js | 0 {min => dist}/locales/fi.min.js | 0 {min => dist}/locales/fr-ca.min.js | 0 {min => dist}/locales/fr-ch.min.js | 0 {min => dist}/locales/fr.min.js | 0 {min => dist}/locales/hu.min.js | 0 {min => dist}/locales/it.min.js | 0 {min => dist}/locales/ja.min.js | 0 {min => dist}/locales/lv.min.js | 0 {min => dist}/locales/nl-nl.min.js | 2 +- {min => dist}/locales/no.min.js | 0 {min => dist}/locales/pl.min.js | 0 {min => dist}/locales/pt-br.min.js | 0 {min => dist}/locales/pt-pt.min.js | 0 {min => dist}/locales/ru-ua.min.js | 0 {min => dist}/locales/ru.min.js | 0 {min => dist}/locales/sk.min.js | 0 {min => dist}/locales/sl.min.js | 0 {min => dist}/locales/th.min.js | 0 {min => dist}/locales/tr.min.js | 0 {min => dist}/locales/uk-ua.min.js | 0 dist/numeral.min.js | 8 ++ min/locales.min.js | 7 -- min/numeral.min.js | 14 ---- numeral.js | 30 ++------ package.json | 1 - src/numeral.js | 8 +- templates/types.js | 2 +- tests/formats/bytes.js | 3 +- tests/formats/currency.js | 3 +- tests/formats/exponential.js | 3 +- tests/formats/ordinal.js | 3 +- tests/formats/percentage.js | 3 +- tests/formats/time.js | 3 +- tests/locales/be-nl.js | 4 +- tests/locales/bg.js | 4 +- tests/locales/chs.js | 4 +- tests/locales/cs.js | 4 +- tests/locales/da-dk.js | 4 +- tests/locales/de-ch.js | 4 +- tests/locales/de.js | 4 +- tests/locales/en-au.js | 4 +- tests/locales/en-gb.js | 4 +- tests/locales/en-za.js | 4 +- tests/locales/es-es.js | 4 +- tests/locales/es.js | 4 +- tests/locales/et.js | 4 +- tests/locales/fi.js | 4 +- tests/locales/fr-ca.js | 4 +- tests/locales/fr-ch.js | 4 +- tests/locales/fr.js | 4 +- tests/locales/hu.js | 4 +- tests/locales/it.js | 4 +- tests/locales/ja.js | 4 +- tests/locales/lv.js | 4 +- tests/locales/nl-nl.js | 4 +- tests/locales/no.js | 4 +- tests/locales/pl.js | 4 +- tests/locales/pt-br.js | 4 +- tests/locales/pt-pt.js | 4 +- tests/locales/ru-ua.js | 4 +- tests/locales/ru.js | 4 +- tests/locales/sk.js | 4 +- tests/locales/sl.js | 6 +- tests/locales/th.js | 4 +- tests/locales/tr.js | 4 +- tests/locales/uk-ua.js | 4 +- tests/numeral.js | 2 +- 83 files changed, 149 insertions(+), 201 deletions(-) rename locales.js => dist/locales.js (99%) create mode 100644 dist/locales.min.js rename {min => dist}/locales/be-nl.min.js (84%) rename {min => dist}/locales/bg.min.js (100%) rename {min => dist}/locales/chs.min.js (100%) rename {min => dist}/locales/cs.min.js (100%) rename {min => dist}/locales/da-dk.min.js (100%) rename {min => dist}/locales/de-ch.min.js (100%) rename {min => dist}/locales/de.min.js (100%) rename {min => dist}/locales/en-au.min.js (100%) rename {min => dist}/locales/en-gb.min.js (100%) rename {min => dist}/locales/en-za.min.js (100%) rename {min => dist}/locales/es-es.min.js (100%) rename {min => dist}/locales/es.min.js (100%) rename {min => dist}/locales/et.min.js (100%) rename {min => dist}/locales/fi.min.js (100%) rename {min => dist}/locales/fr-ca.min.js (100%) rename {min => dist}/locales/fr-ch.min.js (100%) rename {min => dist}/locales/fr.min.js (100%) rename {min => dist}/locales/hu.min.js (100%) rename {min => dist}/locales/it.min.js (100%) rename {min => dist}/locales/ja.min.js (100%) rename {min => dist}/locales/lv.min.js (100%) rename {min => dist}/locales/nl-nl.min.js (84%) rename {min => dist}/locales/no.min.js (100%) rename {min => dist}/locales/pl.min.js (100%) rename {min => dist}/locales/pt-br.min.js (100%) rename {min => dist}/locales/pt-pt.min.js (100%) rename {min => dist}/locales/ru-ua.min.js (100%) rename {min => dist}/locales/ru.min.js (100%) rename {min => dist}/locales/sk.min.js (100%) rename {min => dist}/locales/sl.min.js (100%) rename {min => dist}/locales/th.min.js (100%) rename {min => dist}/locales/tr.min.js (100%) rename {min => dist}/locales/uk-ua.min.js (100%) create mode 100644 dist/numeral.min.js delete mode 100644 min/locales.min.js delete mode 100644 min/numeral.min.js diff --git a/Gruntfile.js b/Gruntfile.js index 5fd604b6..70301511 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,13 +1,13 @@ module.exports = function(grunt) { - var compileFile = function() { + 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 regexp = /\}\(this, function \(numeral\) \{\s([\s\S]+)(?:\s\}\)\);)/; var content = ''; var file; var i; @@ -22,12 +22,26 @@ module.exports = function(grunt) { }) + '\n'; } - grunt.file.write('temp/' + type + '.js', grunt.template.process(template, { - data: { - type: type, - content: content - } - })); + grunt.file.write('temp/' + type + '.js', content); + + if (type === 'locales') { + grunt.file.write('dist/' + type + '.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); }; grunt.initConfig({ @@ -82,16 +96,24 @@ module.exports = function(grunt) { src: [ 'locales/*.js' ], - dest: 'min/', + dest: 'dist/', ext: '.min.js' }, { expand: true, + cwd: 'dist/', src: [ - 'numeral.js', 'locales.js' ], - dest: 'min/', + dest: 'dist/', + ext: '.min.js' + }, + { + expand: true, + src: [ + 'numeral.js' + ], + dest: 'dist/', ext: '.min.js' } ] @@ -100,21 +122,6 @@ module.exports = function(grunt) { preserveComments: 'some' } }, - concat: { - numeral: { - src: [ - 'src/numeral.js', - 'temp/formats.js' - ], - dest: 'numeral.js' - }, - locales: { - src: [ - 'temp/locales.js' - ], - dest: 'locales.js' - } - }, jshint: { all: [ 'Gruntfile.js', @@ -129,7 +136,6 @@ module.exports = function(grunt) { 'eqnull': true, 'newcap': true, 'noarg': true, - 'onevar': true, 'undef': true, 'sub': true, 'strict': false, @@ -143,70 +149,47 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-jshint'); - grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-mocha-test'); grunt.loadNpmTasks('grunt-karma'); - grunt.registerTask('build:locales', function() { - var template = grunt.file.read('templates/locales.js'); - var anon = grunt.file.read('templates/anon.js'); - var files = grunt.file.expand([ - 'src/locales/*.js' - ]); - var regexp = /}\(this, function \(numeral\) {\s([\s\S]+)(?:\s}\)\);)/; - var content = ''; - var file; - var i; - - for (i = 0; i < files.length; i++) { - file = grunt.file.read(files[i]); - - content += '\n' + grunt.template.process(anon, { - data: { - content: file.match(regexp)[1] - } - }) + '\n'; - } + grunt.registerTask('default', [ + 'test' + ]); - grunt.file.write('locales.js', grunt.template.process(template, { - data: { - content: content - } - })); - }); + grunt.registerMultiTask('compile', compileType); - grunt.registerMultiTask('compile', compileFile); + grunt.registerTask('compile:numeral', compileNumeral); - grunt.registerTask('default', [ - 'test' + grunt.registerTask('build', [ + 'jshint', + 'compile', + 'compile:numeral' ]); grunt.registerTask('test', [ - 'jshint', + 'build', 'mochaTest', 'karma:local' ]); grunt.registerTask('test:npm', [ - 'jshint', + 'build', 'mochaTest' ]); grunt.registerTask('test:browser', [ - 'jshint', + 'build', 'karma:local' ]); - // P - grunt.registerTask('build', [ - 'compile', - 'concat', + grunt.registerTask('dist', [ + 'build', 'uglify' ]); // Travis CI task. grunt.registerTask('travis', [ - 'jshint', + 'build', 'mochaTest', 'karma:ci' ]); diff --git a/locales.js b/dist/locales.js similarity index 99% rename from locales.js rename to dist/locales.js index 0b66f855..dec1794b 100644 --- a/locales.js +++ b/dist/locales.js @@ -9,7 +9,7 @@ if (typeof define === 'function' && define.amd) { define(['numeral'], factory); } else if (typeof module === 'object' && module.exports) { - factory(require('numeral')); + factory(require('../numeral')); } else { factory(global.numeral); } diff --git a/dist/locales.min.js b/dist/locales.min.js new file mode 100644 index 00000000..99a74b47 --- /dev/null +++ b/dist/locales.min.js @@ -0,0 +1,7 @@ +/*! @preserve + * numeral.js + * locales: 2.0.2 + * 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","be-nl",{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","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-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:"₴"}})}()}); \ No newline at end of file diff --git a/min/locales/be-nl.min.js b/dist/locales/be-nl.min.js similarity index 84% rename from min/locales/be-nl.min.js rename to dist/locales/be-nl.min.js index 7c98f24b..9ede6827 100644 --- a/min/locales/be-nl.min.js +++ b/dist/locales/be-nl.min.js @@ -1 +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 +!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&&1>=b||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}); \ No newline at end of file diff --git a/min/locales/bg.min.js b/dist/locales/bg.min.js similarity index 100% rename from min/locales/bg.min.js rename to dist/locales/bg.min.js diff --git a/min/locales/chs.min.js b/dist/locales/chs.min.js similarity index 100% rename from min/locales/chs.min.js rename to dist/locales/chs.min.js diff --git a/min/locales/cs.min.js b/dist/locales/cs.min.js similarity index 100% rename from min/locales/cs.min.js rename to dist/locales/cs.min.js diff --git a/min/locales/da-dk.min.js b/dist/locales/da-dk.min.js similarity index 100% rename from min/locales/da-dk.min.js rename to dist/locales/da-dk.min.js diff --git a/min/locales/de-ch.min.js b/dist/locales/de-ch.min.js similarity index 100% rename from min/locales/de-ch.min.js rename to dist/locales/de-ch.min.js diff --git a/min/locales/de.min.js b/dist/locales/de.min.js similarity index 100% rename from min/locales/de.min.js rename to dist/locales/de.min.js diff --git a/min/locales/en-au.min.js b/dist/locales/en-au.min.js similarity index 100% rename from min/locales/en-au.min.js rename to dist/locales/en-au.min.js diff --git a/min/locales/en-gb.min.js b/dist/locales/en-gb.min.js similarity index 100% rename from min/locales/en-gb.min.js rename to dist/locales/en-gb.min.js diff --git a/min/locales/en-za.min.js b/dist/locales/en-za.min.js similarity index 100% rename from min/locales/en-za.min.js rename to dist/locales/en-za.min.js diff --git a/min/locales/es-es.min.js b/dist/locales/es-es.min.js similarity index 100% rename from min/locales/es-es.min.js rename to dist/locales/es-es.min.js diff --git a/min/locales/es.min.js b/dist/locales/es.min.js similarity index 100% rename from min/locales/es.min.js rename to dist/locales/es.min.js diff --git a/min/locales/et.min.js b/dist/locales/et.min.js similarity index 100% rename from min/locales/et.min.js rename to dist/locales/et.min.js diff --git a/min/locales/fi.min.js b/dist/locales/fi.min.js similarity index 100% rename from min/locales/fi.min.js rename to dist/locales/fi.min.js diff --git a/min/locales/fr-ca.min.js b/dist/locales/fr-ca.min.js similarity index 100% rename from min/locales/fr-ca.min.js rename to dist/locales/fr-ca.min.js diff --git a/min/locales/fr-ch.min.js b/dist/locales/fr-ch.min.js similarity index 100% rename from min/locales/fr-ch.min.js rename to dist/locales/fr-ch.min.js diff --git a/min/locales/fr.min.js b/dist/locales/fr.min.js similarity index 100% rename from min/locales/fr.min.js rename to dist/locales/fr.min.js diff --git a/min/locales/hu.min.js b/dist/locales/hu.min.js similarity index 100% rename from min/locales/hu.min.js rename to dist/locales/hu.min.js diff --git a/min/locales/it.min.js b/dist/locales/it.min.js similarity index 100% rename from min/locales/it.min.js rename to dist/locales/it.min.js diff --git a/min/locales/ja.min.js b/dist/locales/ja.min.js similarity index 100% rename from min/locales/ja.min.js rename to dist/locales/ja.min.js diff --git a/min/locales/lv.min.js b/dist/locales/lv.min.js similarity index 100% rename from min/locales/lv.min.js rename to dist/locales/lv.min.js diff --git a/min/locales/nl-nl.min.js b/dist/locales/nl-nl.min.js similarity index 84% rename from min/locales/nl-nl.min.js rename to dist/locales/nl-nl.min.js index 17914720..1e50e799 100644 --- a/min/locales/nl-nl.min.js +++ b/dist/locales/nl-nl.min.js @@ -1 +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&&b<=1||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}); \ No newline at end of file +!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/dist/locales/no.min.js similarity index 100% rename from min/locales/no.min.js rename to dist/locales/no.min.js diff --git a/min/locales/pl.min.js b/dist/locales/pl.min.js similarity index 100% rename from min/locales/pl.min.js rename to dist/locales/pl.min.js diff --git a/min/locales/pt-br.min.js b/dist/locales/pt-br.min.js similarity index 100% rename from min/locales/pt-br.min.js rename to dist/locales/pt-br.min.js diff --git a/min/locales/pt-pt.min.js b/dist/locales/pt-pt.min.js similarity index 100% rename from min/locales/pt-pt.min.js rename to dist/locales/pt-pt.min.js diff --git a/min/locales/ru-ua.min.js b/dist/locales/ru-ua.min.js similarity index 100% rename from min/locales/ru-ua.min.js rename to dist/locales/ru-ua.min.js diff --git a/min/locales/ru.min.js b/dist/locales/ru.min.js similarity index 100% rename from min/locales/ru.min.js rename to dist/locales/ru.min.js diff --git a/min/locales/sk.min.js b/dist/locales/sk.min.js similarity index 100% rename from min/locales/sk.min.js rename to dist/locales/sk.min.js diff --git a/min/locales/sl.min.js b/dist/locales/sl.min.js similarity index 100% rename from min/locales/sl.min.js rename to dist/locales/sl.min.js diff --git a/min/locales/th.min.js b/dist/locales/th.min.js similarity index 100% rename from min/locales/th.min.js rename to dist/locales/th.min.js diff --git a/min/locales/tr.min.js b/dist/locales/tr.min.js similarity index 100% rename from min/locales/tr.min.js rename to dist/locales/tr.min.js diff --git a/min/locales/uk-ua.min.js b/dist/locales/uk-ua.min.js similarity index 100% rename from min/locales/uk-ua.min.js rename to dist/locales/uk-ua.min.js diff --git a/dist/numeral.min.js b/dist/numeral.min.js new file mode 100644 index 00000000..98fe70d4 --- /dev/null +++ b/dist/numeral.min.js @@ -0,0 +1,8 @@ +/*! @preserve + * numeral.js + * version : 2.0.2 + * author : Adam Draper + * license : MIT + * http://adamwdraper.github.com/Numeral-js/ + */ +!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.2",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,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")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):p>g&&g>=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):q>g&&g>=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(r>g&&g>=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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)},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*g)/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(){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"]};b.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+a.suffixes.concat(c.suffixes).join("|")+")")},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=b.locales[b.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=b._.includes(c," $")||b._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=b._.numberToFormat(a,c,d),1>=h?b._.includes(f,"(")||b._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:b._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),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 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){return.01*b._.stringToNumber(a)}})}(),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/min/locales.min.js b/min/locales.min.js deleted file mode 100644 index 33c24cc6..00000000 --- a/min/locales.min.js +++ /dev/null @@ -1,7 +0,0 @@ -/*! @preserve - * numeral.js - * locales: 2.0.2 - * 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","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:"€ "}})}(),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-nl",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mln",billion:"mrd",trillion:"bln"},ordinal:function(a){var b=a%100;return 0!==a&&b<=1||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:"₴"}})}()}); \ No newline at end of file diff --git a/min/numeral.min.js b/min/numeral.min.js deleted file mode 100644 index da9c7cbc..00000000 --- a/min/numeral.min.js +++ /dev/null @@ -1,14 +0,0 @@ -/*! @preserve - * numeral.js - * version : 2.0.2 - * author : Adam Draper - * license : MIT - * http://adamwdraper.github.com/Numeral-js/ - */ -!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.2",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,c=c.replace(/\+/g,"")),b._.includes(c,"a")&&(e=c.match(/a(k|m|b|t)?/),e=!!e&&e[1],b._.includes(c," a")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):g=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):g=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(g=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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 a.indexOf(b)!==-1},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(;f=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;fd?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*g)/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(),b):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(a){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))&&(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))&&(i=new RegExp(e+"{2}"),!a.match(/[^\d.,]/g)&&(g=a.split(d),!(g.length>2)&&(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:"$"}}),b}),/*! @preserve - * numeral.js - * formats: 2.0.2 - * 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(){var b={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"]};a.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+b.suffixes.concat(c.suffixes).join("|")+")")},format:function(d,e,f){var g,h,i,j,k=a._.includes(e,"ib")?c:b,l=a._.includes(e," b")||a._.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&&d0&&(d/=i);break}return g=a._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=a._.stringToNumber(d);if(g){for(e=b.suffixes.length-1;e>=0;e--){if(a._.includes(d,b.suffixes[e])){f=Math.pow(b.base,e);break}if(a._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){a.register("format","currency",{regexps:{format:/(\$)/},format:function(b,c,d){var e,f,g=a.locales[a.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=a._.includes(c," $")||a._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=a._.numberToFormat(b,c,d),h<=1?a._.includes(f,"(")||a._.includes(f,"-")?(f=f.split(""),e=h Date: Fri, 16 Dec 2016 22:25:11 -0800 Subject: [PATCH 121/150] test using compiled files --- Gruntfile.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 70301511..56a2700c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -55,9 +55,8 @@ module.exports = function(grunt) { karma: { options: { files: [ - 'src/numeral.js', - 'src/formats/*.js', - 'src/locales/*.js', + 'numeral.js', + 'dist/locales/*.js', 'tests/numeral.js', 'tests/formats/*.js', 'tests/locales/*.js' From 783e1f1b6289676165b142a892b9e240315bdd35 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Fri, 16 Dec 2016 22:28:20 -0800 Subject: [PATCH 122/150] update change log --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index dc0dc2ef..f757d75b 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,12 @@ See [the english unit tests](https://github.com/adamwdraper/Numeral-js/blob/mast # Changelog +### 2.0.2 + +Repo change: Built files are now in the `dist` directory + +Bug fix: Updated module definitions + ### 2.0.1 Bug fix: Fixed regression for webpack/browserify/rollup From 0a7d91fcdd54b5d1a3ce56ab0ff033a3b1774451 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Fri, 16 Dec 2016 22:41:48 -0800 Subject: [PATCH 123/150] move locales out of dist dir --- Gruntfile.js | 2 +- README.md | 9 +++++++-- dist/locales.js => locales.js | 2 +- templates/types.js | 2 +- tests/locales/be-nl.js | 2 +- tests/locales/bg.js | 2 +- tests/locales/chs.js | 2 +- tests/locales/cs.js | 2 +- tests/locales/da-dk.js | 2 +- tests/locales/de-ch.js | 2 +- tests/locales/de.js | 2 +- tests/locales/en-au.js | 2 +- tests/locales/en-gb.js | 2 +- tests/locales/en-za.js | 2 +- tests/locales/es-es.js | 2 +- tests/locales/es.js | 2 +- tests/locales/et.js | 2 +- tests/locales/fi.js | 2 +- tests/locales/fr-ca.js | 2 +- tests/locales/fr-ch.js | 2 +- tests/locales/fr.js | 2 +- tests/locales/hu.js | 2 +- tests/locales/it.js | 2 +- tests/locales/ja.js | 2 +- tests/locales/lv.js | 2 +- tests/locales/nl-nl.js | 2 +- tests/locales/no.js | 2 +- tests/locales/pl.js | 2 +- tests/locales/pt-br.js | 2 +- tests/locales/pt-pt.js | 2 +- tests/locales/ru-ua.js | 2 +- tests/locales/ru.js | 2 +- tests/locales/sk.js | 2 +- tests/locales/sl.js | 2 +- tests/locales/th.js | 2 +- tests/locales/tr.js | 2 +- tests/locales/uk-ua.js | 2 +- 37 files changed, 43 insertions(+), 38 deletions(-) rename dist/locales.js => locales.js (99%) diff --git a/Gruntfile.js b/Gruntfile.js index 56a2700c..ecb547a9 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -25,7 +25,7 @@ module.exports = function(grunt) { grunt.file.write('temp/' + type + '.js', content); if (type === 'locales') { - grunt.file.write('dist/' + type + '.js', grunt.template.process(template, { + grunt.file.write('locales.js', grunt.template.process(template, { data: { type: type, content: content diff --git a/README.md b/README.md index f757d75b..d1967480 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Develop [![Build Status](https://travis-ci.org/adamwdraper/Numeral-js.svg?branch # Contributing -#### Important: Please create your branch from and submit 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 @@ -35,11 +35,16 @@ Develop [![Build Status](https://travis-ci.org/adamwdraper/Numeral-js.svg?branch 6. To test your tests, run `grunt` -7. When all your tests are passing, run `grunt build` to minify all files +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. +### Formats + +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. + + ### Locales 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. diff --git a/dist/locales.js b/locales.js similarity index 99% rename from dist/locales.js rename to locales.js index dec1794b..b8e9b29c 100644 --- a/dist/locales.js +++ b/locales.js @@ -9,7 +9,7 @@ if (typeof define === 'function' && define.amd) { define(['numeral'], factory); } else if (typeof module === 'object' && module.exports) { - factory(require('../numeral')); + factory(require('./numeral')); } else { factory(global.numeral); } diff --git a/templates/types.js b/templates/types.js index 6badbb83..417aa1ad 100644 --- a/templates/types.js +++ b/templates/types.js @@ -9,7 +9,7 @@ if (typeof define === 'function' && define.amd) { define(['numeral'], factory); } else if (typeof module === 'object' && module.exports) { - factory(require('../numeral')); + factory(require('./numeral')); } else { factory(global.numeral); } diff --git a/tests/locales/be-nl.js b/tests/locales/be-nl.js index 8b3caf6d..8744f7db 100644 --- a/tests/locales/be-nl.js +++ b/tests/locales/be-nl.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/bg.js b/tests/locales/bg.js index dc7d3b90..04ccc261 100644 --- a/tests/locales/bg.js +++ b/tests/locales/bg.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/chs.js b/tests/locales/chs.js index 72e8f5ac..f476e152 100644 --- a/tests/locales/chs.js +++ b/tests/locales/chs.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/cs.js b/tests/locales/cs.js index f7c387ef..21b9cb9e 100644 --- a/tests/locales/cs.js +++ b/tests/locales/cs.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/da-dk.js b/tests/locales/da-dk.js index de8ff21a..800612b1 100644 --- a/tests/locales/da-dk.js +++ b/tests/locales/da-dk.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/de-ch.js b/tests/locales/de-ch.js index d8d8c1b0..8203e1a4 100644 --- a/tests/locales/de-ch.js +++ b/tests/locales/de-ch.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/de.js b/tests/locales/de.js index dfd1f23b..cf1d652d 100644 --- a/tests/locales/de.js +++ b/tests/locales/de.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/en-au.js b/tests/locales/en-au.js index f9ce11b8..97d6a094 100644 --- a/tests/locales/en-au.js +++ b/tests/locales/en-au.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/en-gb.js b/tests/locales/en-gb.js index bf5b3f6b..8c35e743 100644 --- a/tests/locales/en-gb.js +++ b/tests/locales/en-gb.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/en-za.js b/tests/locales/en-za.js index f0138aae..ed6cdc10 100644 --- a/tests/locales/en-za.js +++ b/tests/locales/en-za.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/es-es.js b/tests/locales/es-es.js index b9a78577..a2830809 100644 --- a/tests/locales/es-es.js +++ b/tests/locales/es-es.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/es.js b/tests/locales/es.js index ee97499d..7cc7704d 100644 --- a/tests/locales/es.js +++ b/tests/locales/es.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/et.js b/tests/locales/et.js index dfc12ace..87437737 100644 --- a/tests/locales/et.js +++ b/tests/locales/et.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/fi.js b/tests/locales/fi.js index b6d1759a..711238e6 100644 --- a/tests/locales/fi.js +++ b/tests/locales/fi.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/fr-ca.js b/tests/locales/fr-ca.js index 412c1570..1b386566 100644 --- a/tests/locales/fr-ca.js +++ b/tests/locales/fr-ca.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/fr-ch.js b/tests/locales/fr-ch.js index 200d093b..ddb17b65 100644 --- a/tests/locales/fr-ch.js +++ b/tests/locales/fr-ch.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/fr.js b/tests/locales/fr.js index 3035e82e..515e5100 100644 --- a/tests/locales/fr.js +++ b/tests/locales/fr.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/hu.js b/tests/locales/hu.js index 6f75cae4..b86d8598 100644 --- a/tests/locales/hu.js +++ b/tests/locales/hu.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/it.js b/tests/locales/it.js index bab5ad7e..af51fc14 100644 --- a/tests/locales/it.js +++ b/tests/locales/it.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/ja.js b/tests/locales/ja.js index 69be8696..762484b6 100644 --- a/tests/locales/ja.js +++ b/tests/locales/ja.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/lv.js b/tests/locales/lv.js index b041abd8..227fc5c0 100644 --- a/tests/locales/lv.js +++ b/tests/locales/lv.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/nl-nl.js b/tests/locales/nl-nl.js index 2129ae18..be59b4c4 100644 --- a/tests/locales/nl-nl.js +++ b/tests/locales/nl-nl.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/no.js b/tests/locales/no.js index 579cab10..64ad12ea 100644 --- a/tests/locales/no.js +++ b/tests/locales/no.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/pl.js b/tests/locales/pl.js index e187d9aa..c8056681 100644 --- a/tests/locales/pl.js +++ b/tests/locales/pl.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/pt-br.js b/tests/locales/pt-br.js index 6ca4739c..87915554 100644 --- a/tests/locales/pt-br.js +++ b/tests/locales/pt-br.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/pt-pt.js b/tests/locales/pt-pt.js index 53d84b81..54073397 100644 --- a/tests/locales/pt-pt.js +++ b/tests/locales/pt-pt.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/ru-ua.js b/tests/locales/ru-ua.js index b6265005..aa65fcb9 100644 --- a/tests/locales/ru-ua.js +++ b/tests/locales/ru-ua.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/ru.js b/tests/locales/ru.js index efd6a0bb..47e2153a 100644 --- a/tests/locales/ru.js +++ b/tests/locales/ru.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/sk.js b/tests/locales/sk.js index d21cbf97..8db57e42 100644 --- a/tests/locales/sk.js +++ b/tests/locales/sk.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/sl.js b/tests/locales/sl.js index 642de08c..5dfb9693 100644 --- a/tests/locales/sl.js +++ b/tests/locales/sl.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/th.js b/tests/locales/th.js index a60dec8b..7743066b 100644 --- a/tests/locales/th.js +++ b/tests/locales/th.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/tr.js b/tests/locales/tr.js index dd867c32..f1996754 100644 --- a/tests/locales/tr.js +++ b/tests/locales/tr.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } diff --git a/tests/locales/uk-ua.js b/tests/locales/uk-ua.js index be831f7c..9155f81a 100644 --- a/tests/locales/uk-ua.js +++ b/tests/locales/uk-ua.js @@ -1,7 +1,7 @@ // Node if (typeof module !== 'undefined' && module.exports) { var numeral = require('../../numeral'); - var locales = require('../../dist/locales'); + var locales = require('../../locales'); var expect = require('chai').expect; } From c6b4e87092a1403cbad5e059619d7b75be8f4934 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Fri, 16 Dec 2016 22:58:42 -0800 Subject: [PATCH 124/150] move back to min for backwards compatibility and use locales for testing --- Gruntfile.js | 16 ++++------------ README.md | 2 -- dist/locales.min.js | 7 ------- min/locales.min.js | 7 +++++++ {dist => min}/locales/be-nl.min.js | 0 {dist => min}/locales/bg.min.js | 0 {dist => min}/locales/chs.min.js | 0 {dist => min}/locales/cs.min.js | 0 {dist => min}/locales/da-dk.min.js | 0 {dist => min}/locales/de-ch.min.js | 0 {dist => min}/locales/de.min.js | 0 {dist => min}/locales/en-au.min.js | 0 {dist => min}/locales/en-gb.min.js | 0 {dist => min}/locales/en-za.min.js | 0 {dist => min}/locales/es-es.min.js | 0 {dist => min}/locales/es.min.js | 0 {dist => min}/locales/et.min.js | 0 {dist => min}/locales/fi.min.js | 0 {dist => min}/locales/fr-ca.min.js | 0 {dist => min}/locales/fr-ch.min.js | 0 {dist => min}/locales/fr.min.js | 0 {dist => min}/locales/hu.min.js | 0 {dist => min}/locales/it.min.js | 0 {dist => min}/locales/ja.min.js | 0 {dist => min}/locales/lv.min.js | 0 {dist => min}/locales/nl-nl.min.js | 0 {dist => min}/locales/no.min.js | 0 {dist => min}/locales/pl.min.js | 0 {dist => min}/locales/pt-br.min.js | 0 {dist => min}/locales/pt-pt.min.js | 0 {dist => min}/locales/ru-ua.min.js | 0 {dist => min}/locales/ru.min.js | 0 {dist => min}/locales/sk.min.js | 0 {dist => min}/locales/sl.min.js | 0 {dist => min}/locales/th.min.js | 0 {dist => min}/locales/tr.min.js | 0 {dist => min}/locales/uk-ua.min.js | 0 {dist => min}/numeral.min.js | 0 38 files changed, 11 insertions(+), 21 deletions(-) delete mode 100644 dist/locales.min.js create mode 100644 min/locales.min.js rename {dist => min}/locales/be-nl.min.js (100%) rename {dist => min}/locales/bg.min.js (100%) rename {dist => min}/locales/chs.min.js (100%) rename {dist => min}/locales/cs.min.js (100%) rename {dist => min}/locales/da-dk.min.js (100%) rename {dist => min}/locales/de-ch.min.js (100%) rename {dist => min}/locales/de.min.js (100%) rename {dist => min}/locales/en-au.min.js (100%) rename {dist => min}/locales/en-gb.min.js (100%) rename {dist => min}/locales/en-za.min.js (100%) rename {dist => min}/locales/es-es.min.js (100%) rename {dist => min}/locales/es.min.js (100%) rename {dist => min}/locales/et.min.js (100%) rename {dist => min}/locales/fi.min.js (100%) rename {dist => min}/locales/fr-ca.min.js (100%) rename {dist => min}/locales/fr-ch.min.js (100%) rename {dist => min}/locales/fr.min.js (100%) rename {dist => min}/locales/hu.min.js (100%) rename {dist => min}/locales/it.min.js (100%) rename {dist => min}/locales/ja.min.js (100%) rename {dist => min}/locales/lv.min.js (100%) rename {dist => min}/locales/nl-nl.min.js (100%) rename {dist => min}/locales/no.min.js (100%) rename {dist => min}/locales/pl.min.js (100%) rename {dist => min}/locales/pt-br.min.js (100%) rename {dist => min}/locales/pt-pt.min.js (100%) rename {dist => min}/locales/ru-ua.min.js (100%) rename {dist => min}/locales/ru.min.js (100%) rename {dist => min}/locales/sk.min.js (100%) rename {dist => min}/locales/sl.min.js (100%) rename {dist => min}/locales/th.min.js (100%) rename {dist => min}/locales/tr.min.js (100%) rename {dist => min}/locales/uk-ua.min.js (100%) rename {dist => min}/numeral.min.js (100%) diff --git a/Gruntfile.js b/Gruntfile.js index ecb547a9..bfd187e3 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -56,7 +56,7 @@ module.exports = function(grunt) { options: { files: [ 'numeral.js', - 'dist/locales/*.js', + 'locales.js', 'tests/numeral.js', 'tests/formats/*.js', 'tests/locales/*.js' @@ -95,24 +95,16 @@ module.exports = function(grunt) { src: [ 'locales/*.js' ], - dest: 'dist/', + dest: 'min/', ext: '.min.js' }, { expand: true, - cwd: 'dist/', src: [ + 'numeral.js', 'locales.js' ], - dest: 'dist/', - ext: '.min.js' - }, - { - expand: true, - src: [ - 'numeral.js' - ], - dest: 'dist/', + dest: 'min/', ext: '.min.js' } ] diff --git a/README.md b/README.md index d1967480..02089c17 100644 --- a/README.md +++ b/README.md @@ -58,8 +58,6 @@ See [the english unit tests](https://github.com/adamwdraper/Numeral-js/blob/mast ### 2.0.2 -Repo change: Built files are now in the `dist` directory - Bug fix: Updated module definitions ### 2.0.1 diff --git a/dist/locales.min.js b/dist/locales.min.js deleted file mode 100644 index 99a74b47..00000000 --- a/dist/locales.min.js +++ /dev/null @@ -1,7 +0,0 @@ -/*! @preserve - * numeral.js - * locales: 2.0.2 - * 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","be-nl",{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","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-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:"₴"}})}()}); \ No newline at end of file diff --git a/min/locales.min.js b/min/locales.min.js new file mode 100644 index 00000000..a7935501 --- /dev/null +++ b/min/locales.min.js @@ -0,0 +1,7 @@ +/*! @preserve + * numeral.js + * locales: 2.0.2 + * 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","be-nl",{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","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-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:"₴"}})}()}); \ No newline at end of file diff --git a/dist/locales/be-nl.min.js b/min/locales/be-nl.min.js similarity index 100% rename from dist/locales/be-nl.min.js rename to min/locales/be-nl.min.js diff --git a/dist/locales/bg.min.js b/min/locales/bg.min.js similarity index 100% rename from dist/locales/bg.min.js rename to min/locales/bg.min.js diff --git a/dist/locales/chs.min.js b/min/locales/chs.min.js similarity index 100% rename from dist/locales/chs.min.js rename to min/locales/chs.min.js diff --git a/dist/locales/cs.min.js b/min/locales/cs.min.js similarity index 100% rename from dist/locales/cs.min.js rename to min/locales/cs.min.js diff --git a/dist/locales/da-dk.min.js b/min/locales/da-dk.min.js similarity index 100% rename from dist/locales/da-dk.min.js rename to min/locales/da-dk.min.js diff --git a/dist/locales/de-ch.min.js b/min/locales/de-ch.min.js similarity index 100% rename from dist/locales/de-ch.min.js rename to min/locales/de-ch.min.js diff --git a/dist/locales/de.min.js b/min/locales/de.min.js similarity index 100% rename from dist/locales/de.min.js rename to min/locales/de.min.js diff --git a/dist/locales/en-au.min.js b/min/locales/en-au.min.js similarity index 100% rename from dist/locales/en-au.min.js rename to min/locales/en-au.min.js diff --git a/dist/locales/en-gb.min.js b/min/locales/en-gb.min.js similarity index 100% rename from dist/locales/en-gb.min.js rename to min/locales/en-gb.min.js diff --git a/dist/locales/en-za.min.js b/min/locales/en-za.min.js similarity index 100% rename from dist/locales/en-za.min.js rename to min/locales/en-za.min.js diff --git a/dist/locales/es-es.min.js b/min/locales/es-es.min.js similarity index 100% rename from dist/locales/es-es.min.js rename to min/locales/es-es.min.js diff --git a/dist/locales/es.min.js b/min/locales/es.min.js similarity index 100% rename from dist/locales/es.min.js rename to min/locales/es.min.js diff --git a/dist/locales/et.min.js b/min/locales/et.min.js similarity index 100% rename from dist/locales/et.min.js rename to min/locales/et.min.js diff --git a/dist/locales/fi.min.js b/min/locales/fi.min.js similarity index 100% rename from dist/locales/fi.min.js rename to min/locales/fi.min.js diff --git a/dist/locales/fr-ca.min.js b/min/locales/fr-ca.min.js similarity index 100% rename from dist/locales/fr-ca.min.js rename to min/locales/fr-ca.min.js diff --git a/dist/locales/fr-ch.min.js b/min/locales/fr-ch.min.js similarity index 100% rename from dist/locales/fr-ch.min.js rename to min/locales/fr-ch.min.js diff --git a/dist/locales/fr.min.js b/min/locales/fr.min.js similarity index 100% rename from dist/locales/fr.min.js rename to min/locales/fr.min.js diff --git a/dist/locales/hu.min.js b/min/locales/hu.min.js similarity index 100% rename from dist/locales/hu.min.js rename to min/locales/hu.min.js diff --git a/dist/locales/it.min.js b/min/locales/it.min.js similarity index 100% rename from dist/locales/it.min.js rename to min/locales/it.min.js diff --git a/dist/locales/ja.min.js b/min/locales/ja.min.js similarity index 100% rename from dist/locales/ja.min.js rename to min/locales/ja.min.js diff --git a/dist/locales/lv.min.js b/min/locales/lv.min.js similarity index 100% rename from dist/locales/lv.min.js rename to min/locales/lv.min.js diff --git a/dist/locales/nl-nl.min.js b/min/locales/nl-nl.min.js similarity index 100% rename from dist/locales/nl-nl.min.js rename to min/locales/nl-nl.min.js diff --git a/dist/locales/no.min.js b/min/locales/no.min.js similarity index 100% rename from dist/locales/no.min.js rename to min/locales/no.min.js diff --git a/dist/locales/pl.min.js b/min/locales/pl.min.js similarity index 100% rename from dist/locales/pl.min.js rename to min/locales/pl.min.js diff --git a/dist/locales/pt-br.min.js b/min/locales/pt-br.min.js similarity index 100% rename from dist/locales/pt-br.min.js rename to min/locales/pt-br.min.js diff --git a/dist/locales/pt-pt.min.js b/min/locales/pt-pt.min.js similarity index 100% rename from dist/locales/pt-pt.min.js rename to min/locales/pt-pt.min.js diff --git a/dist/locales/ru-ua.min.js b/min/locales/ru-ua.min.js similarity index 100% rename from dist/locales/ru-ua.min.js rename to min/locales/ru-ua.min.js diff --git a/dist/locales/ru.min.js b/min/locales/ru.min.js similarity index 100% rename from dist/locales/ru.min.js rename to min/locales/ru.min.js diff --git a/dist/locales/sk.min.js b/min/locales/sk.min.js similarity index 100% rename from dist/locales/sk.min.js rename to min/locales/sk.min.js diff --git a/dist/locales/sl.min.js b/min/locales/sl.min.js similarity index 100% rename from dist/locales/sl.min.js rename to min/locales/sl.min.js diff --git a/dist/locales/th.min.js b/min/locales/th.min.js similarity index 100% rename from dist/locales/th.min.js rename to min/locales/th.min.js diff --git a/dist/locales/tr.min.js b/min/locales/tr.min.js similarity index 100% rename from dist/locales/tr.min.js rename to min/locales/tr.min.js diff --git a/dist/locales/uk-ua.min.js b/min/locales/uk-ua.min.js similarity index 100% rename from dist/locales/uk-ua.min.js rename to min/locales/uk-ua.min.js diff --git a/dist/numeral.min.js b/min/numeral.min.js similarity index 100% rename from dist/numeral.min.js rename to min/numeral.min.js From 0e500ee2c1ca6aa6a8704901c4d1521a3953fd39 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sat, 17 Dec 2016 08:48:28 -0800 Subject: [PATCH 125/150] add locales dir with unmagnified --- Gruntfile.js | 18 ++++++++++++- locales/be-nl.js | 34 +++++++++++++++++++++++++ locales/bg.js | 40 +++++++++++++++++++++++++++++ locales/chs.js | 32 +++++++++++++++++++++++ locales/cs.js | 32 +++++++++++++++++++++++ locales/da-dk.js | 32 +++++++++++++++++++++++ locales/de-ch.js | 32 +++++++++++++++++++++++ locales/de.js | 32 +++++++++++++++++++++++ locales/en-au.js | 36 ++++++++++++++++++++++++++ locales/en-gb.js | 36 ++++++++++++++++++++++++++ locales/en-za.js | 36 ++++++++++++++++++++++++++ locales/es-es.js | 37 +++++++++++++++++++++++++++ locales/es.js | 37 +++++++++++++++++++++++++++ locales/et.js | 33 ++++++++++++++++++++++++ locales/fi.js | 32 +++++++++++++++++++++++ locales/fr-ca.js | 32 +++++++++++++++++++++++ locales/fr-ch.js | 32 +++++++++++++++++++++++ locales/fr.js | 32 +++++++++++++++++++++++ locales/hu.js | 32 +++++++++++++++++++++++ locales/it.js | 32 +++++++++++++++++++++++ locales/ja.js | 32 +++++++++++++++++++++++ locales/lv.js | 32 +++++++++++++++++++++++ locales/nl-nl.js | 33 ++++++++++++++++++++++++ locales/no.js | 32 +++++++++++++++++++++++ locales/pl.js | 32 +++++++++++++++++++++++ locales/pt-br.js | 32 +++++++++++++++++++++++ locales/pt-pt.js | 32 +++++++++++++++++++++++ locales/ru-ua.js | 35 +++++++++++++++++++++++++ locales/ru.js | 35 +++++++++++++++++++++++++ locales/sk.js | 32 +++++++++++++++++++++++ locales/sl.js | 32 +++++++++++++++++++++++ locales/th.js | 34 +++++++++++++++++++++++++ locales/tr.js | 66 ++++++++++++++++++++++++++++++++++++++++++++++++ locales/uk-ua.js | 35 +++++++++++++++++++++++++ package.json | 1 + 35 files changed, 1153 insertions(+), 1 deletion(-) create mode 100644 locales/be-nl.js create mode 100644 locales/bg.js create mode 100644 locales/chs.js create mode 100644 locales/cs.js create mode 100644 locales/da-dk.js create mode 100644 locales/de-ch.js create mode 100644 locales/de.js create mode 100644 locales/en-au.js create mode 100644 locales/en-gb.js create mode 100644 locales/en-za.js create mode 100644 locales/es-es.js create mode 100644 locales/es.js create mode 100644 locales/et.js create mode 100644 locales/fi.js create mode 100644 locales/fr-ca.js create mode 100644 locales/fr-ch.js create mode 100644 locales/fr.js create mode 100644 locales/hu.js create mode 100644 locales/it.js create mode 100644 locales/ja.js create mode 100644 locales/lv.js create mode 100644 locales/nl-nl.js create mode 100644 locales/no.js create mode 100644 locales/pl.js create mode 100644 locales/pt-br.js create mode 100644 locales/pt-pt.js create mode 100644 locales/ru-ua.js create mode 100644 locales/ru.js create mode 100644 locales/sk.js create mode 100644 locales/sl.js create mode 100644 locales/th.js create mode 100644 locales/tr.js create mode 100644 locales/uk-ua.js diff --git a/Gruntfile.js b/Gruntfile.js index bfd187e3..71133c20 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -78,6 +78,20 @@ module.exports = function(grunt) { configFile: 'karma-ci.conf.js' } }, + copy: { + locales: { + files: [ + { + expand: true, + cwd: 'src/', + src: [ + 'locales/*.js' + ], + dest: './' + } + ] + } + }, compile: { locales: { type: 'locales' @@ -138,6 +152,7 @@ module.exports = function(grunt) { } }); + grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-mocha-test'); @@ -154,7 +169,8 @@ module.exports = function(grunt) { grunt.registerTask('build', [ 'jshint', 'compile', - 'compile:numeral' + 'compile:numeral', + 'copy' ]); grunt.registerTask('test', [ diff --git a/locales/be-nl.js b/locales/be-nl.js new file mode 100644 index 00000000..15d948f5 --- /dev/null +++ b/locales/be-nl.js @@ -0,0 +1,34 @@ +// numeral.js locale configuration +// locale : belgium-dutch (be-nl) +// author : Dieter Luypaert : https://github.com/moeriki + +(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', 'be-nl', { + 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/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/locales/en-gb.js b/locales/en-gb.js new file mode 100644 index 00000000..a51190eb --- /dev/null +++ b/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/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/locales/es-es.js b/locales/es-es.js new file mode 100644 index 00000000..31e7de5b --- /dev/null +++ b/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/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-nl.js b/locales/nl-nl.js new file mode 100644 index 00000000..00f70f7c --- /dev/null +++ b/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/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/locales/uk-ua.js b/locales/uk-ua.js new file mode 100644 index 00000000..34b31037 --- /dev/null +++ b/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/package.json b/package.json index 68291891..0fa11856 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "devDependencies": { "chai": "^3.5.0", "grunt": "latest", + "grunt-contrib-copy": "^1.0.0", "grunt-contrib-jshint": "latest", "grunt-contrib-nodeunit": "1.0.0", "grunt-contrib-uglify": "latest", From 6b26811d136c3db6becca8d0e887d02248588db7 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sat, 17 Dec 2016 09:48:19 -0800 Subject: [PATCH 126/150] update version --- .gitignore | 1 + bower.json | 2 +- component.json | 2 +- locales.js | 2 +- min/locales.min.js | 2 +- min/numeral.min.js | 2 +- numeral.js | 2 +- package.json | 2 +- src/numeral.js | 2 +- templates/types.js | 2 +- 10 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 2b80bbd1..38ecea03 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ Icon node_modules/ .sass-cache temp/ +npm-debug.log diff --git a/bower.json b/bower.json index 8c3f3513..1c452e26 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "numeral", "repo": "adamwdraper/Numeral-js", - "version": "2.0.2", + "version": "2.0.3", "description": "Format and manipulate numbers.", "keywords": [ "numeral", diff --git a/component.json b/component.json index 8c3f3513..1c452e26 100644 --- a/component.json +++ b/component.json @@ -1,7 +1,7 @@ { "name": "numeral", "repo": "adamwdraper/Numeral-js", - "version": "2.0.2", + "version": "2.0.3", "description": "Format and manipulate numbers.", "keywords": [ "numeral", diff --git a/locales.js b/locales.js index b8e9b29c..6f18d729 100644 --- a/locales.js +++ b/locales.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js - * locales: 2.0.2 + * locales: 2.0.3 * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ diff --git a/min/locales.min.js b/min/locales.min.js index a7935501..628fe679 100644 --- a/min/locales.min.js +++ b/min/locales.min.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js - * locales: 2.0.2 + * locales: 2.0.3 * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ diff --git a/min/numeral.min.js b/min/numeral.min.js index 98fe70d4..21e88fdc 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js - * version : 2.0.2 + * version : 2.0.3 * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ diff --git a/numeral.js b/numeral.js index cdf0c9f0..6a1b5304 100644 --- a/numeral.js +++ b/numeral.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js - * version : 2.0.2 + * version : 2.0.3 * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ diff --git a/package.json b/package.json index 0fa11856..760c6524 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "numeral", - "version": "2.0.2", + "version": "2.0.3", "description": "Format and manipulate numbers.", "homepage": "http://numeraljs.com/", "author": { diff --git a/src/numeral.js b/src/numeral.js index 42e42da7..c1757359 100644 --- a/src/numeral.js +++ b/src/numeral.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js - * version : 2.0.2 + * version : 2.0.3 * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ diff --git a/templates/types.js b/templates/types.js index 417aa1ad..6ba9005e 100644 --- a/templates/types.js +++ b/templates/types.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js - * <%= type %>: 2.0.2 + * <%= type %>: 2.0.3 * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ From 7c14397b0c031c7db563ce0900a941f8b4caae23 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sat, 17 Dec 2016 09:50:18 -0800 Subject: [PATCH 127/150] update numeral version --- min/numeral.min.js | 2 +- numeral.js | 2 +- src/numeral.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/min/numeral.min.js b/min/numeral.min.js index 21e88fdc..67f2f9c7 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -!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.2",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,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")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):p>g&&g>=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):q>g&&g>=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(r>g&&g>=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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)},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*g)/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(){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"]};b.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+a.suffixes.concat(c.suffixes).join("|")+")")},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=b.locales[b.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=b._.includes(c," $")||b._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=b._.numberToFormat(a,c,d),1>=h?b._.includes(f,"(")||b._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:b._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),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 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){return.01*b._.stringToNumber(a)}})}(),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 +!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.3",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,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")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):p>g&&g>=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):q>g&&g>=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(r>g&&g>=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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)},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*g)/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(){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"]};b.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+a.suffixes.concat(c.suffixes).join("|")+")")},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=b.locales[b.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=b._.includes(c," $")||b._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=b._.numberToFormat(a,c,d),1>=h?b._.includes(f,"(")||b._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:b._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),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 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){return.01*b._.stringToNumber(a)}})}(),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 6a1b5304..26692cbf 100644 --- a/numeral.js +++ b/numeral.js @@ -21,7 +21,7 @@ var numeral, _, - VERSION = '2.0.2', + VERSION = '2.0.3', formats = {}, locales = {}, defaults = { diff --git a/src/numeral.js b/src/numeral.js index c1757359..fc9a79a4 100644 --- a/src/numeral.js +++ b/src/numeral.js @@ -21,7 +21,7 @@ var numeral, _, - VERSION = '2.0.2', + VERSION = '2.0.3', formats = {}, locales = {}, defaults = { From 44d94d6ba403bc9ac8d3fafeb9e7eef81ab7d284 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sun, 18 Dec 2016 22:21:48 -0700 Subject: [PATCH 128/150] fix number formatting for sign --- numeral.js | 34 ++++++++++++++++++++++++++-------- src/numeral.js | 32 ++++++++++++++++++++++++-------- tests/numeral.js | 17 +++++++++++++++++ 3 files changed, 67 insertions(+), 16 deletions(-) diff --git a/numeral.js b/numeral.js index 26692cbf..8f076d9a 100644 --- a/numeral.js +++ b/numeral.js @@ -102,13 +102,14 @@ numberToFormat: function(value, format, roundingFunction) { var locale = locales[numeral.options.currentLocale], negP = false, - signed = false, optDec = false, abbr = '', trillion = 1000000000000, billion = 1000000000, million = 1000000, thousand = 1000, + decimal = '', + neg = false, abbrForce, // force abbreviation abs, min, @@ -116,23 +117,25 @@ power, int, precision, + signed, thousands, - decimal = '', - neg = false; + output; // make sure we never format a null value value = value || 0; abs = Math.abs(value); + console.log(format, numeral._.includes(format, '(')); + // 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.slice(1, -1); - } else if (numeral._.includes(format, '+')) { - signed = true; - format = format.replace(/\+/g, ''); + format = format.replace(/[\(|\)]/g, ''); + } else if (numeral._.includes(format, '+') || numeral._.includes(format, '-')) { + signed = numeral._.includes(format, '+') ? format.indexOf('+') : format.indexOf('-'); + format = format.replace(/[\+|\-]/g, ''); } // see if abbreviation is wanted @@ -215,7 +218,19 @@ int = ''; } - return (negP && neg ? '(' : '') + (!negP && neg ? '-' : '') + (!neg && signed ? '+' : '') + int + decimal + (abbr ? abbr : '') + (negP && neg ? ')' : ''); + 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) { @@ -269,6 +284,9 @@ 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'); diff --git a/src/numeral.js b/src/numeral.js index fc9a79a4..a84e4aa4 100644 --- a/src/numeral.js +++ b/src/numeral.js @@ -102,13 +102,14 @@ numberToFormat: function(value, format, roundingFunction) { var locale = locales[numeral.options.currentLocale], negP = false, - signed = false, optDec = false, abbr = '', trillion = 1000000000000, billion = 1000000000, million = 1000000, thousand = 1000, + decimal = '', + neg = false, abbrForce, // force abbreviation abs, min, @@ -116,9 +117,9 @@ power, int, precision, + signed, thousands, - decimal = '', - neg = false; + output; // make sure we never format a null value value = value || 0; @@ -129,10 +130,10 @@ // if both are present we default to parentheses if (numeral._.includes(format, '(')) { negP = true; - format = format.slice(1, -1); - } else if (numeral._.includes(format, '+')) { - signed = true; - format = format.replace(/\+/g, ''); + format = format.replace(/[\(|\)]/g, ''); + } else if (numeral._.includes(format, '+') || numeral._.includes(format, '-')) { + signed = numeral._.includes(format, '+') ? format.indexOf('+') : format.indexOf('-'); + format = format.replace(/[\+|\-]/g, ''); } // see if abbreviation is wanted @@ -215,7 +216,19 @@ int = ''; } - return (negP && neg ? '(' : '') + (!negP && neg ? '-' : '') + (!neg && signed ? '+' : '') + int + decimal + (abbr ? abbr : '') + (negP && neg ? ')' : ''); + 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) { @@ -269,6 +282,9 @@ 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'); diff --git a/tests/numeral.js b/tests/numeral.js index b0b9b699..4ba8f09c 100644 --- a/tests/numeral.js +++ b/tests/numeral.js @@ -152,6 +152,7 @@ describe('Numeral', function() { [-10000,'(0,0.0000)','(10,000.0000)'], [-12300,'+0,0.0000','-12,300.0000'], [1230,'+0,0','+1,230'], + [-1230.4,'0,0.0+','1,230.4-'], [100.78, '0', '101'], [100.28, '0', '100'], [1.932,'0.0','1.9'], @@ -438,4 +439,20 @@ describe('Numeral', function() { }); }); }); + + 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]); + } + }); + }); + }); }); From eae7ed48ce4899c13602efeef92d249bac068c2b Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Mon, 19 Dec 2016 23:55:03 -0700 Subject: [PATCH 129/150] fix currency formatting --- numeral.js | 63 +++++++++++++++++++++++---------------- src/formats/currency.js | 59 ++++++++++++++++++++++-------------- src/numeral.js | 2 +- tests/formats/currency.js | 6 ++-- tests/numeral.js | 5 ++++ 5 files changed, 83 insertions(+), 52 deletions(-) diff --git a/numeral.js b/numeral.js index 8f076d9a..f2e1e1e6 100644 --- a/numeral.js +++ b/numeral.js @@ -126,15 +126,13 @@ abs = Math.abs(value); - console.log(format, numeral._.includes(format, '(')); - // 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('+') : format.indexOf('-'); + signed = numeral._.includes(format, '+') ? format.indexOf('+') : value < 0 ? format.indexOf('-') : -1; format = format.replace(/[\+|\-]/g, ''); } @@ -746,12 +744,13 @@ }, format: function(value, format, roundingFunction) { var locale = numeral.locales[numeral.options.currentLocale], - symbolIndex = format.indexOf('$'), - openParenIndex = format.indexOf('('), - minusSignIndex = format.indexOf('-'), - space = numeral._.includes(format, ' $') || numeral._.includes(format, '$ ') ? ' ' : '', - spliceIndex, - output; + symbols = { + before: format.match(/^([\+|\-|\(|\s|\$]*)/)[0], + after: format.match(/([\+|\-|\)|\s|\$]*)$/)[0] + }, + output, + symbol, + i; // strip format of spaces and $ format = format.replace(/\s?\$\s?/, ''); @@ -759,31 +758,43 @@ // format the number output = numeral._.numberToFormat(value, format, roundingFunction); - // position the symbol - if (symbolIndex <= 1) { - if (numeral._.includes(output, '(') || numeral._.includes(output, '-')) { - output = output.split(''); - - spliceIndex = symbolIndex < openParenIndex || symbolIndex < minusSignIndex ? 0 : 1; + // 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; + } - output.splice(spliceIndex, 0, locale.currency.symbol + space); + // loop through each before symbol + for (i = 0; i < symbols.before.length; i++) { + symbol = symbols.before[i]; - output = output.join(''); - } else { - output = locale.currency.symbol + space + output; + switch (symbol) { + case '$': + output = numeral._.insert(output, locale.currency.symbol, i); + break; + case ' ': + output = numeral._.insert(output, ' ', i); + break; } - } else { - if (numeral._.includes(output, ')')) { - output = output.split(''); + } - output.splice(-1, 0, space + locale.currency.symbol); + // loop through each after symbol + for (i = symbols.after.length - 1; i >= 0; i--) { + symbol = symbols.after[i]; - output = output.join(''); - } else { - output = output + space + locale.currency.symbol; + 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))); + break; } } + return output; } }); diff --git a/src/formats/currency.js b/src/formats/currency.js index 938466e4..a4eb8c8a 100644 --- a/src/formats/currency.js +++ b/src/formats/currency.js @@ -17,12 +17,13 @@ }, format: function(value, format, roundingFunction) { var locale = numeral.locales[numeral.options.currentLocale], - symbolIndex = format.indexOf('$'), - openParenIndex = format.indexOf('('), - minusSignIndex = format.indexOf('-'), - space = numeral._.includes(format, ' $') || numeral._.includes(format, '$ ') ? ' ' : '', - spliceIndex, - output; + symbols = { + before: format.match(/^([\+|\-|\(|\s|\$]*)/)[0], + after: format.match(/([\+|\-|\)|\s|\$]*)$/)[0] + }, + output, + symbol, + i; // strip format of spaces and $ format = format.replace(/\s?\$\s?/, ''); @@ -30,31 +31,43 @@ // format the number output = numeral._.numberToFormat(value, format, roundingFunction); - // position the symbol - if (symbolIndex <= 1) { - if (numeral._.includes(output, '(') || numeral._.includes(output, '-')) { - output = output.split(''); - - spliceIndex = symbolIndex < openParenIndex || symbolIndex < minusSignIndex ? 0 : 1; + // 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; + } - output.splice(spliceIndex, 0, locale.currency.symbol + space); + // loop through each before symbol + for (i = 0; i < symbols.before.length; i++) { + symbol = symbols.before[i]; - output = output.join(''); - } else { - output = locale.currency.symbol + space + output; + switch (symbol) { + case '$': + output = numeral._.insert(output, locale.currency.symbol, i); + break; + case ' ': + output = numeral._.insert(output, ' ', i); + break; } - } else { - if (numeral._.includes(output, ')')) { - output = output.split(''); + } - output.splice(-1, 0, space + locale.currency.symbol); + // loop through each after symbol + for (i = symbols.after.length - 1; i >= 0; i--) { + symbol = symbols.after[i]; - output = output.join(''); - } else { - output = output + space + locale.currency.symbol; + 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))); + break; } } + return output; } }); diff --git a/src/numeral.js b/src/numeral.js index a84e4aa4..6500b464 100644 --- a/src/numeral.js +++ b/src/numeral.js @@ -132,7 +132,7 @@ negP = true; format = format.replace(/[\(|\)]/g, ''); } else if (numeral._.includes(format, '+') || numeral._.includes(format, '-')) { - signed = numeral._.includes(format, '+') ? format.indexOf('+') : format.indexOf('-'); + signed = numeral._.includes(format, '+') ? format.indexOf('+') : value < 0 ? format.indexOf('-') : -1; format = format.replace(/[\+|\-]/g, ''); } diff --git a/tests/formats/currency.js b/tests/formats/currency.js index 0156d421..24bbef87 100644 --- a/tests/formats/currency.js +++ b/tests/formats/currency.js @@ -18,11 +18,13 @@ describe('Currency', function() { [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'], - // 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)'], @@ -35,7 +37,7 @@ describe('Currency', function() { [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'] ], i; diff --git a/tests/numeral.js b/tests/numeral.js index 4ba8f09c..3e2a566f 100644 --- a/tests/numeral.js +++ b/tests/numeral.js @@ -149,10 +149,15 @@ describe('Numeral', function() { [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'], From 807927c11e40db2b936702ff150ff105ef427c87 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Mon, 19 Dec 2016 23:56:12 -0700 Subject: [PATCH 130/150] update readme with change --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 02089c17..eac56b78 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,10 @@ See [the english unit tests](https://github.com/adamwdraper/Numeral-js/blob/mast # Changelog +### 2.1.0 + +Bug fix: Signed currency is inconsistent + ### 2.0.2 Bug fix: Updated module definitions From 14d0cd392d796a1fde8487617fe3455dad85b17e Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Tue, 20 Dec 2016 22:33:27 -0700 Subject: [PATCH 131/150] fix rounding --- min/numeral.min.js | 2 +- numeral.js | 21 ++++++++++++++++++++- src/numeral.js | 21 ++++++++++++++++++++- tests/numeral.js | 2 ++ 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/min/numeral.min.js b/min/numeral.min.js index 67f2f9c7..efcfbb45 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -!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.3",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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=f[b.options.currentLocale],l=!1,m=!1,n=!1,o="",p=1e12,q=1e9,r=1e6,s=1e3,t="",u=!1;return a=a||0,g=Math.abs(a),b._.includes(c,"(")?(l=!0,c=c.slice(1,-1)):b._.includes(c,"+")&&(m=!0,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")&&(o=" "),c=c.replace(new RegExp(o+"a[kmbt]?"),""),g>=p&&!e||"t"===e?(o+=k.abbreviations.trillion,a/=p):p>g&&g>=q&&!e||"b"===e?(o+=k.abbreviations.billion,a/=q):q>g&&g>=r&&!e||"m"===e?(o+=k.abbreviations.million,a/=r):(r>g&&g>=s&&!e||"k"===e)&&(o+=k.abbreviations.thousand,a/=s)),b._.includes(c,"[.]")&&(n=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),t=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):t=b._.toFixed(a,i.length,d),h=t.split(".")[0],t=b._.includes(t,".")?k.delimiters.decimal+t.split(".")[1]:"",n&&0===Number(t.slice(1))&&(t="")):h=b._.toFixed(a,null,d),b._.includes(h,"-")&&(h=h.slice(1),u=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k.delimiters.thousands)),0===c.indexOf(".")&&(h=""),(l&&u?"(":"")+(!l&&u?"-":"")+(!u&&m?"+":"")+h+t+(o?o:"")+(l&&u?")":"")},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)},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*g)/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(){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"]};b.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+a.suffixes.concat(c.suffixes).join("|")+")")},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=b.locales[b.options.currentLocale],h=c.indexOf("$"),i=c.indexOf("("),j=c.indexOf("-"),k=b._.includes(c," $")||b._.includes(c,"$ ")?" ":"";return c=c.replace(/\s?\$\s?/,""),f=b._.numberToFormat(a,c,d),1>=h?b._.includes(f,"(")||b._.includes(f,"-")?(f=f.split(""),e=i>h||j>h?0:1,f.splice(e,0,g.currency.symbol+k),f=f.join("")):f=g.currency.symbol+k+f:b._.includes(f,")")?(f=f.split(""),f.splice(-1,0,k+g.currency.symbol),f=f.join("")):f=f+k+g.currency.symbol,f}})}(),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 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){return.01*b._.stringToNumber(a)}})}(),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 +!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.3",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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="",q=1e12,r=1e9,s=1e6,t=1e3,u="",v=!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")&&(p=" "),c=c.replace(new RegExp(p+"a[kmbt]?"),""),g>=q&&!e||"t"===e?(p+=m.abbreviations.trillion,a/=q):q>g&&g>=r&&!e||"b"===e?(p+=m.abbreviations.billion,a/=r):r>g&&g>=s&&!e||"m"===e?(p+=m.abbreviations.million,a/=s):(s>g&&g>=t&&!e||"k"===e)&&(p+=m.abbreviations.thousand,a/=t)),b._.includes(c,"[.]")&&(o=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],k=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),u=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):u=b._.toFixed(a,i.length,d),h=u.split(".")[0],u=b._.includes(u,".")?m.delimiters.decimal+u.split(".")[1]:"",o&&0===Number(u.slice(1))&&(u="")):h=b._.toFixed(a,null,d),p&&!e&&Number(h)>=1e3&&p!==m.abbreviations.trillion)switch(h=String(Number(h)/1e3),p){case m.abbreviations.thousand:p=m.abbreviations.million;break;case m.abbreviations.million:p=m.abbreviations.billion;break;case m.abbreviations.billion:p=m.abbreviations.trillion}return b._.includes(h,"-")&&(h=h.slice(1),v=!0),k>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+m.delimiters.thousands)),0===c.indexOf(".")&&(h=""),l=h+u+(p?p:""),n?l=(n&&v?"(":"")+l+(n&&v?")":""):j>=0?l=0===j?(v?"-":"+")+l:l+(v?"-":"+"):v&&(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*g)/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(){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"]};b.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+a.suffixes.concat(c.suffixes).join("|")+")")},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)))}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 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){return.01*b._.stringToNumber(a)}})}(),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 f2e1e1e6..7199afc3 100644 --- a/numeral.js +++ b/numeral.js @@ -168,12 +168,13 @@ } } - + // 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(','); @@ -202,6 +203,24 @@ int = numeral._.toFixed(value, null, 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); diff --git a/src/numeral.js b/src/numeral.js index 6500b464..b6a50007 100644 --- a/src/numeral.js +++ b/src/numeral.js @@ -168,12 +168,13 @@ } } - + // 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(','); @@ -202,6 +203,24 @@ int = numeral._.toFixed(value, null, 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); diff --git a/tests/numeral.js b/tests/numeral.js index 3e2a566f..8436e163 100644 --- a/tests/numeral.js +++ b/tests/numeral.js @@ -175,6 +175,8 @@ describe('Numeral', function() { [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'], From 2a69b1886b599133997f6ec328bed0c5098285e6 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Wed, 21 Dec 2016 10:57:05 -0700 Subject: [PATCH 132/150] task for versioning of son files --- Gruntfile.js | 34 ++++++++++++++++++++++++++++------ bower.json | 2 +- component.json | 2 +- package.json | 4 +++- 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 71133c20..9ebcff97 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -44,6 +44,8 @@ module.exports = function(grunt) { grunt.file.write('numeral.js', numeral); }; + require('load-grunt-tasks')(grunt); + grunt.initConfig({ mochaTest : { all: [ @@ -152,12 +154,6 @@ module.exports = function(grunt) { } }); - grunt.loadNpmTasks('grunt-contrib-copy'); - grunt.loadNpmTasks('grunt-contrib-uglify'); - grunt.loadNpmTasks('grunt-contrib-jshint'); - grunt.loadNpmTasks('grunt-mocha-test'); - grunt.loadNpmTasks('grunt-karma'); - grunt.registerTask('default', [ 'test' ]); @@ -194,6 +190,32 @@ module.exports = function(grunt) { '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.task.run([ + 'string-replace:json' + ]); + }); + // Travis CI task. grunt.registerTask('travis', [ 'build', diff --git a/bower.json b/bower.json index 1c452e26..a1c69051 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "numeral", "repo": "adamwdraper/Numeral-js", - "version": "2.0.3", + "version": "2.0.4", "description": "Format and manipulate numbers.", "keywords": [ "numeral", diff --git a/component.json b/component.json index 1c452e26..a1c69051 100644 --- a/component.json +++ b/component.json @@ -1,7 +1,7 @@ { "name": "numeral", "repo": "adamwdraper/Numeral-js", - "version": "2.0.3", + "version": "2.0.4", "description": "Format and manipulate numbers.", "keywords": [ "numeral", diff --git a/package.json b/package.json index 760c6524..804cd7b6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "numeral", - "version": "2.0.3", + "version": "2.0.4", "description": "Format and manipulate numbers.", "homepage": "http://numeraljs.com/", "author": { @@ -38,6 +38,7 @@ "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", @@ -45,6 +46,7 @@ "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" }, From 4ca9ac16134a8d18c70ebad295514f8fef29ac23 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Wed, 21 Dec 2016 11:01:59 -0700 Subject: [PATCH 133/150] update numeral version --- Gruntfile.js | 21 ++++++++++++++++++++- src/numeral.js | 4 ++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 9ebcff97..dae287cf 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -211,8 +211,27 @@ module.exports = function(grunt) { } }); + 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.task.run([ - 'string-replace:json' + 'string-replace:json', + 'string-replace:numeral' ]); }); diff --git a/src/numeral.js b/src/numeral.js index b6a50007..4b024c28 100644 --- a/src/numeral.js +++ b/src/numeral.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js - * version : 2.0.3 + * version : 2.0.4 * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ @@ -21,7 +21,7 @@ var numeral, _, - VERSION = '2.0.3', + VERSION = '2.0.4', formats = {}, locales = {}, defaults = { From be2205a3e1a41fbf05ab2b50b28a3477eb90434f Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Wed, 21 Dec 2016 11:19:47 -0700 Subject: [PATCH 134/150] update template --- Gruntfile.js | 15 +++++++++++++++ templates/types.js | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index dae287cf..a1da9e49 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -229,8 +229,23 @@ module.exports = function(grunt) { } }); + 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' ]); }); diff --git a/templates/types.js b/templates/types.js index 6ba9005e..a09d14d5 100644 --- a/templates/types.js +++ b/templates/types.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js - * <%= type %>: 2.0.3 + * <%= type %> : 2.0.4 * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ From 41d586ccbddfa4a06b6bf2df6499ed3059cd5cf2 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Wed, 21 Dec 2016 11:20:30 -0700 Subject: [PATCH 135/150] build files --- locales.js | 2 +- min/locales.min.js | 2 +- min/numeral.min.js | 4 ++-- numeral.js | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/locales.js b/locales.js index 6f18d729..e4df734f 100644 --- a/locales.js +++ b/locales.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js - * locales: 2.0.3 + * locales : 2.0.4 * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ diff --git a/min/locales.min.js b/min/locales.min.js index 628fe679..a301ea6c 100644 --- a/min/locales.min.js +++ b/min/locales.min.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js - * locales: 2.0.3 + * locales : 2.0.4 * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ diff --git a/min/numeral.min.js b/min/numeral.min.js index efcfbb45..4e3e7c8b 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -1,8 +1,8 @@ /*! @preserve * numeral.js - * version : 2.0.3 + * version : 2.0.4 * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -!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.3",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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="",q=1e12,r=1e9,s=1e6,t=1e3,u="",v=!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")&&(p=" "),c=c.replace(new RegExp(p+"a[kmbt]?"),""),g>=q&&!e||"t"===e?(p+=m.abbreviations.trillion,a/=q):q>g&&g>=r&&!e||"b"===e?(p+=m.abbreviations.billion,a/=r):r>g&&g>=s&&!e||"m"===e?(p+=m.abbreviations.million,a/=s):(s>g&&g>=t&&!e||"k"===e)&&(p+=m.abbreviations.thousand,a/=t)),b._.includes(c,"[.]")&&(o=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],k=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),u=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):u=b._.toFixed(a,i.length,d),h=u.split(".")[0],u=b._.includes(u,".")?m.delimiters.decimal+u.split(".")[1]:"",o&&0===Number(u.slice(1))&&(u="")):h=b._.toFixed(a,null,d),p&&!e&&Number(h)>=1e3&&p!==m.abbreviations.trillion)switch(h=String(Number(h)/1e3),p){case m.abbreviations.thousand:p=m.abbreviations.million;break;case m.abbreviations.million:p=m.abbreviations.billion;break;case m.abbreviations.billion:p=m.abbreviations.trillion}return b._.includes(h,"-")&&(h=h.slice(1),v=!0),k>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+m.delimiters.thousands)),0===c.indexOf(".")&&(h=""),l=h+u+(p?p:""),n?l=(n&&v?"(":"")+l+(n&&v?")":""):j>=0?l=0===j?(v?"-":"+")+l:l+(v?"-":"+"):v&&(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*g)/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(){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"]};b.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+a.suffixes.concat(c.suffixes).join("|")+")")},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)))}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 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){return.01*b._.stringToNumber(a)}})}(),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 +!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.4",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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="",q=1e12,r=1e9,s=1e6,t=1e3,u="",v=!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")&&(p=" "),c=c.replace(new RegExp(p+"a[kmbt]?"),""),g>=q&&!e||"t"===e?(p+=m.abbreviations.trillion,a/=q):q>g&&g>=r&&!e||"b"===e?(p+=m.abbreviations.billion,a/=r):r>g&&g>=s&&!e||"m"===e?(p+=m.abbreviations.million,a/=s):(s>g&&g>=t&&!e||"k"===e)&&(p+=m.abbreviations.thousand,a/=t)),b._.includes(c,"[.]")&&(o=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],k=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),u=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):u=b._.toFixed(a,i.length,d),h=u.split(".")[0],u=b._.includes(u,".")?m.delimiters.decimal+u.split(".")[1]:"",o&&0===Number(u.slice(1))&&(u="")):h=b._.toFixed(a,null,d),p&&!e&&Number(h)>=1e3&&p!==m.abbreviations.trillion)switch(h=String(Number(h)/1e3),p){case m.abbreviations.thousand:p=m.abbreviations.million;break;case m.abbreviations.million:p=m.abbreviations.billion;break;case m.abbreviations.billion:p=m.abbreviations.trillion}return b._.includes(h,"-")&&(h=h.slice(1),v=!0),k>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+m.delimiters.thousands)),0===c.indexOf(".")&&(h=""),l=h+u+(p?p:""),n?l=(n&&v?"(":"")+l+(n&&v?")":""):j>=0?l=0===j?(v?"-":"+")+l:l+(v?"-":"+"):v&&(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*g)/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(){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"]};b.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+a.suffixes.concat(c.suffixes).join("|")+")")},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)))}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 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){return.01*b._.stringToNumber(a)}})}(),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 7199afc3..83ff379a 100644 --- a/numeral.js +++ b/numeral.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js - * version : 2.0.3 + * version : 2.0.4 * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ @@ -21,7 +21,7 @@ var numeral, _, - VERSION = '2.0.3', + VERSION = '2.0.4', formats = {}, locales = {}, defaults = { From f4041277d127df04b1078a60b29d541eba82088f Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Wed, 21 Dec 2016 11:37:51 -0700 Subject: [PATCH 136/150] update change log --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index eac56b78..4c20f55d 100644 --- a/README.md +++ b/README.md @@ -56,9 +56,11 @@ See [the english unit tests](https://github.com/adamwdraper/Numeral-js/blob/mast # Changelog -### 2.1.0 +### 2.0.4 -Bug fix: Signed currency is inconsistent +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 From aaea8a7c142e68226773e01dfc4e7a7ff196bd68 Mon Sep 17 00:00:00 2001 From: MrCsabaToth Date: Sat, 21 Jan 2017 17:53:44 -0800 Subject: [PATCH 137/150] Adding scalePercentBy100 option --- numeral.js | 1920 +++++++++++++++++++------------------ src/formats/percentage.js | 10 +- src/numeral.js | 6 +- 3 files changed, 979 insertions(+), 957 deletions(-) diff --git a/numeral.js b/numeral.js index 83ff379a..909a8924 100644 --- a/numeral.js +++ b/numeral.js @@ -1,955 +1,969 @@ -/*! @preserve - * numeral.js - * version : 2.0.4 - * 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.4', - formats = {}, - locales = {}, - defaults = { - currentLocale: 'en', - zeroFormat: null, - nullFormat: null, - defaultFormat: '0,0' - }, - options = { - currentLocale: defaults.currentLocale, - zeroFormat: defaults.zeroFormat, - nullFormat: defaults.nullFormat, - defaultFormat: defaults.defaultFormat - }; - - - /************************************ - 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, - 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(','); - - 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, null, 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 (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); - - //roundingFunction = (roundingFunction !== undefined ? roundingFunction : Math.round); - // Multiply up by precision, round accurately, then divide and use native toFixed(): - output = (roundingFunction(value * power) / 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: '$' - } - }); - +/*! @preserve + * numeral.js + * version : 2.0.4 + * 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.4', + 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, + 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(','); + + 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, null, 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 (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); + + //roundingFunction = (roundingFunction !== undefined ? roundingFunction : Math.round); + // Multiply up by precision, round accurately, then divide and use native toFixed(): + output = (roundingFunction(value * power) / 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: '$' + } + }); + -(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'] - }; - - numeral.register('format', 'bytes', { - regexps: { - format: /([0\s]i?b)/, - unformat: new RegExp('(' + decimal.suffixes.concat(binary.suffixes).join('|') + ')') - }, - 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; - } - }); -})(); - - -(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]; - - switch (symbol) { - case '$': - output = numeral._.insert(output, locale.currency.symbol, i); - break; - case ' ': - output = numeral._.insert(output, ' ', i); - 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))); - 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'); - - 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); - } - }); -})(); - - -(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') ? ' ' : ''; - - // 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; - - 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) { - return numeral._.stringToNumber(string) * 0.01; - } - }); -})(); - - -(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)); - - 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); - } - }); -})(); - -return numeral; -})); +(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'] + }; + + numeral.register('format', 'bytes', { + regexps: { + format: /([0\s]i?b)/, + unformat: new RegExp('(' + decimal.suffixes.concat(binary.suffixes).join('|') + ')') + }, + 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; + } + }); +})(); + + +(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]; + + switch (symbol) { + case '$': + output = numeral._.insert(output, locale.currency.symbol, i); + break; + case ' ': + output = numeral._.insert(output, ' ', i); + 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))); + 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'); + + 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); + } + }); +})(); + + +(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') ? ' ' : ''; + + // 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; + + 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; + } + }); +})(); + + +(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)); + + 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); + } + }); +})(); + +return numeral; +})); diff --git a/src/formats/percentage.js b/src/formats/percentage.js index bd4068fd..2c1c3647 100644 --- a/src/formats/percentage.js +++ b/src/formats/percentage.js @@ -20,7 +20,9 @@ var space = numeral._.includes(format, ' %') ? ' ' : '', output; - value = value * 100; + if (numeral.options.scalePercentBy100) { + value = value * 100; + } // check for space before % format = format.replace(/\s?\%/, ''); @@ -40,7 +42,11 @@ return output; }, unformat: function(string) { - return numeral._.stringToNumber(string) * 0.01; + var number = numeral._.stringToNumber(string); + if (numeral.options.scalePercentBy100) { + return number * 0.01; + } + return number; } }); })); diff --git a/src/numeral.js b/src/numeral.js index 4b024c28..b709f0be 100644 --- a/src/numeral.js +++ b/src/numeral.js @@ -28,13 +28,15 @@ currentLocale: 'en', zeroFormat: null, nullFormat: null, - defaultFormat: '0,0' + defaultFormat: '0,0', + scalePercentBy100: true }, options = { currentLocale: defaults.currentLocale, zeroFormat: defaults.zeroFormat, nullFormat: defaults.nullFormat, - defaultFormat: defaults.defaultFormat + defaultFormat: defaults.defaultFormat, + scalePercentBy100: defaults.scalePercentBy100 }; From 2e63ea4b26231791886c9fdf6cc8bfeeb20edd7b Mon Sep 17 00:00:00 2001 From: MrCsabaToth Date: Sat, 21 Jan 2017 17:54:06 -0800 Subject: [PATCH 138/150] Tests for the new option: default, enforced true, an enforced false --- tests/formats/percentage.js | 70 +++++++++++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 2 deletions(-) diff --git a/tests/formats/percentage.js b/tests/formats/percentage.js index cab86d6e..1eb61ee9 100644 --- a/tests/formats/percentage.js +++ b/tests/formats/percentage.js @@ -10,7 +10,7 @@ describe('Percentage', function() { numeral.reset(); }); - it('should format to percentages', function() { + it('should format to percentages with 100 upscale default', function() { var tests = [ [0,'0%','0%'], [null,'0 %','0 %'], @@ -26,7 +26,7 @@ describe('Percentage', function() { } }); - it('should unformat to percentages', function() { + it('should unformat to percentages with 100 downscale default', function() { var tests = [ ['0%', 0], ['100%', 1], @@ -40,4 +40,70 @@ describe('Percentage', function() { 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]); + } + }); }); From 0e1f905c18bf89b8ca2a0aeb3a3b255f8ad5e9d0 Mon Sep 17 00:00:00 2001 From: MrCsabaToth Date: Sat, 21 Jan 2017 17:54:45 -0800 Subject: [PATCH 139/150] build (dunno why locales.js has new lines). Doesn't hurt though --- locales.js | 1678 +++++++++++++++++++------------------- min/locales.min.js | 2 +- min/locales/be-nl.min.js | 2 +- min/locales/nl-nl.min.js | 2 +- min/numeral.min.js | 2 +- 5 files changed, 859 insertions(+), 827 deletions(-) diff --git a/locales.js b/locales.js index e4df734f..ea89fd6a 100644 --- a/locales.js +++ b/locales.js @@ -1,823 +1,855 @@ -/*! @preserve - * numeral.js - * locales : 2.0.4 - * 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', 'be-nl', { - 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', '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-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' - } - }); -})(); - - -})); +/*! @preserve + * numeral.js + * locales : 2.0.4 + * 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', 'be-nl', { + 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', '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-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' + } + }); +})(); + + +})); diff --git a/min/locales.min.js b/min/locales.min.js index a301ea6c..f50b910e 100644 --- a/min/locales.min.js +++ b/min/locales.min.js @@ -4,4 +4,4 @@ * 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","be-nl",{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","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-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:"₴"}})}()}); \ No newline at end of file +!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","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:"€ "}})}(),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-nl",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mln",billion:"mrd",trillion:"bln"},ordinal:function(a){var b=a%100;return 0!==a&&b<=1||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:"₴"}})}()}); \ No newline at end of file diff --git a/min/locales/be-nl.min.js b/min/locales/be-nl.min.js index 9ede6827..7c98f24b 100644 --- a/min/locales/be-nl.min.js +++ b/min/locales/be-nl.min.js @@ -1 +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&&1>=b||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}); \ No newline at end of file +!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/nl-nl.min.js b/min/locales/nl-nl.min.js index 1e50e799..17914720 100644 --- a/min/locales/nl-nl.min.js +++ b/min/locales/nl-nl.min.js @@ -1 +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 +!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&&b<=1||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}); \ No newline at end of file diff --git a/min/numeral.min.js b/min/numeral.min.js index 4e3e7c8b..d06d5378 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -!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.4",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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="",q=1e12,r=1e9,s=1e6,t=1e3,u="",v=!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")&&(p=" "),c=c.replace(new RegExp(p+"a[kmbt]?"),""),g>=q&&!e||"t"===e?(p+=m.abbreviations.trillion,a/=q):q>g&&g>=r&&!e||"b"===e?(p+=m.abbreviations.billion,a/=r):r>g&&g>=s&&!e||"m"===e?(p+=m.abbreviations.million,a/=s):(s>g&&g>=t&&!e||"k"===e)&&(p+=m.abbreviations.thousand,a/=t)),b._.includes(c,"[.]")&&(o=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],k=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),u=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):u=b._.toFixed(a,i.length,d),h=u.split(".")[0],u=b._.includes(u,".")?m.delimiters.decimal+u.split(".")[1]:"",o&&0===Number(u.slice(1))&&(u="")):h=b._.toFixed(a,null,d),p&&!e&&Number(h)>=1e3&&p!==m.abbreviations.trillion)switch(h=String(Number(h)/1e3),p){case m.abbreviations.thousand:p=m.abbreviations.million;break;case m.abbreviations.million:p=m.abbreviations.billion;break;case m.abbreviations.billion:p=m.abbreviations.trillion}return b._.includes(h,"-")&&(h=h.slice(1),v=!0),k>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+m.delimiters.thousands)),0===c.indexOf(".")&&(h=""),l=h+u+(p?p:""),n?l=(n&&v?"(":"")+l+(n&&v?")":""):j>=0?l=0===j?(v?"-":"+")+l:l+(v?"-":"+"):v&&(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*g)/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(){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"]};b.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+a.suffixes.concat(c.suffixes).join("|")+")")},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)))}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 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){return.01*b._.stringToNumber(a)}})}(),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 +!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.4",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="",q=1e12,r=1e9,s=1e6,t=1e3,u="",v=!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("+"):a<0?c.indexOf("-"):-1,c=c.replace(/[\+|\-]/g,"")),b._.includes(c,"a")&&(e=c.match(/a(k|m|b|t)?/),e=!!e&&e[1],b._.includes(c," a")&&(p=" "),c=c.replace(new RegExp(p+"a[kmbt]?"),""),g>=q&&!e||"t"===e?(p+=m.abbreviations.trillion,a/=q):g=r&&!e||"b"===e?(p+=m.abbreviations.billion,a/=r):g=s&&!e||"m"===e?(p+=m.abbreviations.million,a/=s):(g=t&&!e||"k"===e)&&(p+=m.abbreviations.thousand,a/=t)),b._.includes(c,"[.]")&&(o=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],k=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),u=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):u=b._.toFixed(a,i.length,d),h=u.split(".")[0],u=b._.includes(u,".")?m.delimiters.decimal+u.split(".")[1]:"",o&&0===Number(u.slice(1))&&(u="")):h=b._.toFixed(a,null,d),p&&!e&&Number(h)>=1e3&&p!==m.abbreviations.trillion)switch(h=String(Number(h)/1e3),p){case m.abbreviations.thousand:p=m.abbreviations.million;break;case m.abbreviations.million:p=m.abbreviations.billion;break;case m.abbreviations.billion:p=m.abbreviations.trillion}return b._.includes(h,"-")&&(h=h.slice(1),v=!0),k>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+m.delimiters.thousands)),0===c.indexOf(".")&&(h=""),l=h+u+(p?p:""),n?l=(n&&v?"(":"")+l+(n&&v?")":""):j>=0?l=0===j?(v?"-":"+")+l:l+(v?"-":"+"):v&&(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 a.indexOf(b)!==-1},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(;f=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;fd?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*g)/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(a){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))&&(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))&&(i=new RegExp(e+"{2}"),!a.match(/[^\d.,]/g)&&(g=a.split(d),!(g.length>2)&&(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(){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"]};b.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+a.suffixes.concat(c.suffixes).join("|")+")")},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&&d0&&(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(/[\-\)]/,"")):a<0&&!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)))}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),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+":"+(e<10?"0"+e:e)+":"+(f<10?"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 From baa4c48890eb700c473b301e7a09e2949060d163 Mon Sep 17 00:00:00 2001 From: Raymond Ha Date: Mon, 13 Feb 2017 15:54:49 -0800 Subject: [PATCH 140/150] Fix decimal rounding issue --- min/locales.min.js | 2 +- min/locales/be-nl.min.js | 2 +- min/locales/nl-nl.min.js | 2 +- min/numeral.min.js | 2 +- numeral.js | 5 ++--- src/numeral.js | 5 ++--- tests/numeral.js | 1 + 7 files changed, 9 insertions(+), 10 deletions(-) diff --git a/min/locales.min.js b/min/locales.min.js index a301ea6c..f50b910e 100644 --- a/min/locales.min.js +++ b/min/locales.min.js @@ -4,4 +4,4 @@ * 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","be-nl",{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","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-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:"₴"}})}()}); \ No newline at end of file +!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","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:"€ "}})}(),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-nl",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mln",billion:"mrd",trillion:"bln"},ordinal:function(a){var b=a%100;return 0!==a&&b<=1||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:"₴"}})}()}); \ No newline at end of file diff --git a/min/locales/be-nl.min.js b/min/locales/be-nl.min.js index 9ede6827..7c98f24b 100644 --- a/min/locales/be-nl.min.js +++ b/min/locales/be-nl.min.js @@ -1 +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&&1>=b||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}); \ No newline at end of file +!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/nl-nl.min.js b/min/locales/nl-nl.min.js index 1e50e799..17914720 100644 --- a/min/locales/nl-nl.min.js +++ b/min/locales/nl-nl.min.js @@ -1 +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 +!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&&b<=1||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}); \ No newline at end of file diff --git a/min/numeral.min.js b/min/numeral.min.js index 4e3e7c8b..b5164d12 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -!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.4",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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="",q=1e12,r=1e9,s=1e6,t=1e3,u="",v=!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")&&(p=" "),c=c.replace(new RegExp(p+"a[kmbt]?"),""),g>=q&&!e||"t"===e?(p+=m.abbreviations.trillion,a/=q):q>g&&g>=r&&!e||"b"===e?(p+=m.abbreviations.billion,a/=r):r>g&&g>=s&&!e||"m"===e?(p+=m.abbreviations.million,a/=s):(s>g&&g>=t&&!e||"k"===e)&&(p+=m.abbreviations.thousand,a/=t)),b._.includes(c,"[.]")&&(o=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],k=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),u=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):u=b._.toFixed(a,i.length,d),h=u.split(".")[0],u=b._.includes(u,".")?m.delimiters.decimal+u.split(".")[1]:"",o&&0===Number(u.slice(1))&&(u="")):h=b._.toFixed(a,null,d),p&&!e&&Number(h)>=1e3&&p!==m.abbreviations.trillion)switch(h=String(Number(h)/1e3),p){case m.abbreviations.thousand:p=m.abbreviations.million;break;case m.abbreviations.million:p=m.abbreviations.billion;break;case m.abbreviations.billion:p=m.abbreviations.trillion}return b._.includes(h,"-")&&(h=h.slice(1),v=!0),k>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+m.delimiters.thousands)),0===c.indexOf(".")&&(h=""),l=h+u+(p?p:""),n?l=(n&&v?"(":"")+l+(n&&v?")":""):j>=0?l=0===j?(v?"-":"+")+l:l+(v?"-":"+"):v&&(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*g)/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(){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"]};b.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+a.suffixes.concat(c.suffixes).join("|")+")")},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)))}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 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){return.01*b._.stringToNumber(a)}})}(),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 +!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.4",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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="",q=1e12,r=1e9,s=1e6,t=1e3,u="",v=!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("+"):a<0?c.indexOf("-"):-1,c=c.replace(/[\+|\-]/g,"")),b._.includes(c,"a")&&(e=c.match(/a(k|m|b|t)?/),e=!!e&&e[1],b._.includes(c," a")&&(p=" "),c=c.replace(new RegExp(p+"a[kmbt]?"),""),g>=q&&!e||"t"===e?(p+=m.abbreviations.trillion,a/=q):g=r&&!e||"b"===e?(p+=m.abbreviations.billion,a/=r):g=s&&!e||"m"===e?(p+=m.abbreviations.million,a/=s):(g=t&&!e||"k"===e)&&(p+=m.abbreviations.thousand,a/=t)),b._.includes(c,"[.]")&&(o=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],k=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),u=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):u=b._.toFixed(a,i.length,d),h=u.split(".")[0],u=b._.includes(u,".")?m.delimiters.decimal+u.split(".")[1]:"",o&&0===Number(u.slice(1))&&(u="")):h=b._.toFixed(a,0,d),p&&!e&&Number(h)>=1e3&&p!==m.abbreviations.trillion)switch(h=String(Number(h)/1e3),p){case m.abbreviations.thousand:p=m.abbreviations.million;break;case m.abbreviations.million:p=m.abbreviations.billion;break;case m.abbreviations.billion:p=m.abbreviations.trillion}return b._.includes(h,"-")&&(h=h.slice(1),v=!0),k>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+m.delimiters.thousands)),0===c.indexOf(".")&&(h=""),l=h+u+(p?p:""),n?l=(n&&v?"(":"")+l+(n&&v?")":""):j>=0?l=0===j?(v?"-":"+")+l:l+(v?"-":"+"):v&&(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 a.indexOf(b)!==-1},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(;f=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;fd?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(a){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))&&(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))&&(i=new RegExp(e+"{2}"),!a.match(/[^\d.,]/g)&&(g=a.split(d),!(g.length>2)&&(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(){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"]};b.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+a.suffixes.concat(c.suffixes).join("|")+")")},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&&d0&&(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(/[\-\)]/,"")):a<0&&!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)))}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 a*=100,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){return.01*b._.stringToNumber(a)}})}(),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+":"+(e<10?"0"+e:e)+":"+(f<10?"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 83ff379a..ec25d837 100644 --- a/numeral.js +++ b/numeral.js @@ -200,7 +200,7 @@ decimal = ''; } } else { - int = numeral._.toFixed(value, null, roundingFunction); + int = numeral._.toFixed(value, 0, roundingFunction); } // check abbreviation again after rounding @@ -384,9 +384,8 @@ power = Math.pow(10, boundedPrecision); - //roundingFunction = (roundingFunction !== undefined ? roundingFunction : Math.round); // Multiply up by precision, round accurately, then divide and use native toFixed(): - output = (roundingFunction(value * power) / power).toFixed(boundedPrecision); + output = (roundingFunction(value + 'e+' + boundedPrecision) / power).toFixed(boundedPrecision); if (optionals > maxDecimals - boundedPrecision) { optionalsRegExp = new RegExp('\\.?0{1,' + (optionals - (maxDecimals - boundedPrecision)) + '}$'); diff --git a/src/numeral.js b/src/numeral.js index 4b024c28..1fc66b9a 100644 --- a/src/numeral.js +++ b/src/numeral.js @@ -200,7 +200,7 @@ decimal = ''; } } else { - int = numeral._.toFixed(value, null, roundingFunction); + int = numeral._.toFixed(value, 0, roundingFunction); } // check abbreviation again after rounding @@ -384,9 +384,8 @@ power = Math.pow(10, boundedPrecision); - //roundingFunction = (roundingFunction !== undefined ? roundingFunction : Math.round); // Multiply up by precision, round accurately, then divide and use native toFixed(): - output = (roundingFunction(value * power) / power).toFixed(boundedPrecision); + output = (roundingFunction(value + 'e+' + boundedPrecision) / power).toFixed(boundedPrecision); if (optionals > maxDecimals - boundedPrecision) { optionalsRegExp = new RegExp('\\.?0{1,' + (optionals - (maxDecimals - boundedPrecision)) + '}$'); diff --git a/tests/numeral.js b/tests/numeral.js index 8436e163..adfe3f6d 100644 --- a/tests/numeral.js +++ b/tests/numeral.js @@ -170,6 +170,7 @@ describe('Numeral', function() { [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'], // abbreviations [2000000000,'0.0a','2.0b'], [1230974,'0.0a','1.2m'], From 5ea00a05f156f11bb51d2e0dd752d1943d80db10 Mon Sep 17 00:00:00 2001 From: Ammar Hasan Date: Tue, 28 Feb 2017 16:49:03 +0500 Subject: [PATCH 141/150] Fix issue #461 Solve issue with multi letter currency symbols and spacing --- min/numeral.min.js | 2 +- numeral.js | 4 ++-- src/formats/currency.js | 4 ++-- tests/locales/no.js | 3 ++- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/min/numeral.min.js b/min/numeral.min.js index b5164d12..3632f814 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -5,4 +5,4 @@ * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -!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.4",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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="",q=1e12,r=1e9,s=1e6,t=1e3,u="",v=!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("+"):a<0?c.indexOf("-"):-1,c=c.replace(/[\+|\-]/g,"")),b._.includes(c,"a")&&(e=c.match(/a(k|m|b|t)?/),e=!!e&&e[1],b._.includes(c," a")&&(p=" "),c=c.replace(new RegExp(p+"a[kmbt]?"),""),g>=q&&!e||"t"===e?(p+=m.abbreviations.trillion,a/=q):g=r&&!e||"b"===e?(p+=m.abbreviations.billion,a/=r):g=s&&!e||"m"===e?(p+=m.abbreviations.million,a/=s):(g=t&&!e||"k"===e)&&(p+=m.abbreviations.thousand,a/=t)),b._.includes(c,"[.]")&&(o=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],k=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),u=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):u=b._.toFixed(a,i.length,d),h=u.split(".")[0],u=b._.includes(u,".")?m.delimiters.decimal+u.split(".")[1]:"",o&&0===Number(u.slice(1))&&(u="")):h=b._.toFixed(a,0,d),p&&!e&&Number(h)>=1e3&&p!==m.abbreviations.trillion)switch(h=String(Number(h)/1e3),p){case m.abbreviations.thousand:p=m.abbreviations.million;break;case m.abbreviations.million:p=m.abbreviations.billion;break;case m.abbreviations.billion:p=m.abbreviations.trillion}return b._.includes(h,"-")&&(h=h.slice(1),v=!0),k>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+m.delimiters.thousands)),0===c.indexOf(".")&&(h=""),l=h+u+(p?p:""),n?l=(n&&v?"(":"")+l+(n&&v?")":""):j>=0?l=0===j?(v?"-":"+")+l:l+(v?"-":"+"):v&&(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 a.indexOf(b)!==-1},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(;f=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;fd?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(a){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))&&(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))&&(i=new RegExp(e+"{2}"),!a.match(/[^\d.,]/g)&&(g=a.split(d),!(g.length>2)&&(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(){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"]};b.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+a.suffixes.concat(c.suffixes).join("|")+")")},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&&d0&&(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(/[\-\)]/,"")):a<0&&!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)))}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 a*=100,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){return.01*b._.stringToNumber(a)}})}(),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+":"+(e<10?"0"+e:e)+":"+(f<10?"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 +!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.4",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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="",q=1e12,r=1e9,s=1e6,t=1e3,u="",v=!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("+"):a<0?c.indexOf("-"):-1,c=c.replace(/[\+|\-]/g,"")),b._.includes(c,"a")&&(e=c.match(/a(k|m|b|t)?/),e=!!e&&e[1],b._.includes(c," a")&&(p=" "),c=c.replace(new RegExp(p+"a[kmbt]?"),""),g>=q&&!e||"t"===e?(p+=m.abbreviations.trillion,a/=q):g=r&&!e||"b"===e?(p+=m.abbreviations.billion,a/=r):g=s&&!e||"m"===e?(p+=m.abbreviations.million,a/=s):(g=t&&!e||"k"===e)&&(p+=m.abbreviations.thousand,a/=t)),b._.includes(c,"[.]")&&(o=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],k=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),u=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):u=b._.toFixed(a,i.length,d),h=u.split(".")[0],u=b._.includes(u,".")?m.delimiters.decimal+u.split(".")[1]:"",o&&0===Number(u.slice(1))&&(u="")):h=b._.toFixed(a,0,d),p&&!e&&Number(h)>=1e3&&p!==m.abbreviations.trillion)switch(h=String(Number(h)/1e3),p){case m.abbreviations.thousand:p=m.abbreviations.million;break;case m.abbreviations.million:p=m.abbreviations.billion;break;case m.abbreviations.billion:p=m.abbreviations.trillion}return b._.includes(h,"-")&&(h=h.slice(1),v=!0),k>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+m.delimiters.thousands)),0===c.indexOf(".")&&(h=""),l=h+u+(p?p:""),n?l=(n&&v?"(":"")+l+(n&&v?")":""):j>=0?l=0===j?(v?"-":"+")+l:l+(v?"-":"+"):v&&(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 a.indexOf(b)!==-1},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(;f=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;fd?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(a){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))&&(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))&&(i=new RegExp(e+"{2}"),!a.match(/[^\d.,]/g)&&(g=a.split(d),!(g.length>2)&&(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(){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"]};b.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+a.suffixes.concat(c.suffixes).join("|")+")")},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&&d0&&(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(/[\-\)]/,"")):a<0&&!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 a*=100,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){return.01*b._.stringToNumber(a)}})}(),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+":"+(e<10?"0"+e:e)+":"+(f<10?"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 ec25d837..15215201 100644 --- a/numeral.js +++ b/numeral.js @@ -793,7 +793,7 @@ output = numeral._.insert(output, locale.currency.symbol, i); break; case ' ': - output = numeral._.insert(output, ' ', i); + output = numeral._.insert(output, ' ', i + locale.currency.symbol.length - 1); break; } } @@ -807,7 +807,7 @@ 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))); + output = i === symbols.after.length - 1 ? output + ' ' : numeral._.insert(output, ' ', -(symbols.after.length - (1 + i) + locale.currency.symbol.length - 1)); break; } } diff --git a/src/formats/currency.js b/src/formats/currency.js index a4eb8c8a..5a7c4eaa 100644 --- a/src/formats/currency.js +++ b/src/formats/currency.js @@ -48,7 +48,7 @@ output = numeral._.insert(output, locale.currency.symbol, i); break; case ' ': - output = numeral._.insert(output, ' ', i); + output = numeral._.insert(output, ' ', i + locale.currency.symbol.length - 1); break; } } @@ -62,7 +62,7 @@ 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))); + output = i === symbols.after.length - 1 ? output + ' ' : numeral._.insert(output, ' ', -(symbols.after.length - (1 + i) + locale.currency.symbol.length - 1)); break; } } diff --git a/tests/locales/no.js b/tests/locales/no.js index 64ad12ea..e5be2afd 100644 --- a/tests/locales/no.js +++ b/tests/locales/no.js @@ -48,7 +48,8 @@ describe('Locale: no', function() { [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'] + [1230974,'($0.00a)','kr1,23m'], + [521.67,'0,0[.]00 $','521,67 kr'] ]; for (var i = 0; i < tests.length; i++) { From 04885051a232f8fab8b8f927bbd45ae75045689d Mon Sep 17 00:00:00 2001 From: Olivier Godefroy Date: Wed, 1 Mar 2017 09:24:09 +0100 Subject: [PATCH 142/150] #465 : Fix dutch belgium to be nl-be --- locales.js | 1678 +++++++++++----------- locales/{be-nl.js => nl-be.js} | 5 +- min/locales.min.js | 2 +- min/locales/nl-be.min.js | 1 + numeral.js | 1910 +++++++++++++------------- src/locales/{be-nl.js => nl-be.js} | 5 +- tests/locales/{be-nl.js => nl-be.js} | 4 +- 7 files changed, 1823 insertions(+), 1782 deletions(-) rename locales/{be-nl.js => nl-be.js} (86%) create mode 100644 min/locales/nl-be.min.js rename src/locales/{be-nl.js => nl-be.js} (86%) rename tests/locales/{be-nl.js => nl-be.js} (97%) diff --git a/locales.js b/locales.js index e4df734f..622acd92 100644 --- a/locales.js +++ b/locales.js @@ -1,823 +1,855 @@ -/*! @preserve - * numeral.js - * locales : 2.0.4 - * 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', 'be-nl', { - 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', '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-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' - } - }); -})(); - - -})); +/*! @preserve + * numeral.js + * locales : 2.0.4 + * 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' + } + }); +})(); + + +})); diff --git a/locales/be-nl.js b/locales/nl-be.js similarity index 86% rename from locales/be-nl.js rename to locales/nl-be.js index 15d948f5..6b561904 100644 --- a/locales/be-nl.js +++ b/locales/nl-be.js @@ -1,6 +1,7 @@ // numeral.js locale configuration -// locale : belgium-dutch (be-nl) +// 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) { @@ -11,7 +12,7 @@ factory(global.numeral); } }(this, function (numeral) { - numeral.register('locale', 'be-nl', { + numeral.register('locale', 'nl-be', { delimiters: { thousands: ' ', decimal : ',' diff --git a/min/locales.min.js b/min/locales.min.js index f50b910e..bb2ad924 100644 --- a/min/locales.min.js +++ b/min/locales.min.js @@ -4,4 +4,4 @@ * 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","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:"€ "}})}(),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-nl",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mln",billion:"mrd",trillion:"bln"},ordinal:function(a){var b=a%100;return 0!==a&&b<=1||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:"₴"}})}()}); \ No newline at end of file +!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&&b<=1||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&&b<=1||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:"₴"}})}()}); \ 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..764b3ac2 --- /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&&b<=1||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}); \ No newline at end of file diff --git a/numeral.js b/numeral.js index ec25d837..231db047 100644 --- a/numeral.js +++ b/numeral.js @@ -1,954 +1,960 @@ -/*! @preserve - * numeral.js - * version : 2.0.4 - * 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.4', - formats = {}, - locales = {}, - defaults = { - currentLocale: 'en', - zeroFormat: null, - nullFormat: null, - defaultFormat: '0,0' - }, - options = { - currentLocale: defaults.currentLocale, - zeroFormat: defaults.zeroFormat, - nullFormat: defaults.nullFormat, - defaultFormat: defaults.defaultFormat - }; - - - /************************************ - 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, - 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(','); - - 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 (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: '$' - } - }); - +/*! @preserve + * numeral.js + * version : 2.0.4 + * 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.4', + formats = {}, + locales = {}, + defaults = { + currentLocale: 'en', + zeroFormat: null, + nullFormat: null, + defaultFormat: '0,0' + }, + options = { + currentLocale: defaults.currentLocale, + zeroFormat: defaults.zeroFormat, + nullFormat: defaults.nullFormat, + defaultFormat: defaults.defaultFormat + }; + + + /************************************ + 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, + 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(','); + + 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 (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: '$' + } + }); + -(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'] - }; - - numeral.register('format', 'bytes', { - regexps: { - format: /([0\s]i?b)/, - unformat: new RegExp('(' + decimal.suffixes.concat(binary.suffixes).join('|') + ')') - }, - 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; - } - }); -})(); - - -(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]; - - switch (symbol) { - case '$': - output = numeral._.insert(output, locale.currency.symbol, i); - break; - case ' ': - output = numeral._.insert(output, ' ', i); - 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))); - 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'); - - 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); - } - }); -})(); - - -(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') ? ' ' : ''; - - // 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; - - 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) { - return numeral._.stringToNumber(string) * 0.01; - } - }); -})(); - - -(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)); - - 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); - } - }); -})(); - -return numeral; -})); +(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'] + }; + + numeral.register('format', 'bytes', { + regexps: { + format: /([0\s]i?b)/, + unformat: new RegExp('(' + decimal.suffixes.concat(binary.suffixes).join('|') + ')') + }, + 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; + } + }); +})(); + + +(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]; + + switch (symbol) { + case '$': + output = numeral._.insert(output, locale.currency.symbol, i); + break; + case ' ': + output = numeral._.insert(output, ' ', i); + 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))); + 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'); + + 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); + } + }); +})(); + + +(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') ? ' ' : ''; + + // 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; + + 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) { + return numeral._.stringToNumber(string) * 0.01; + } + }); +})(); + + +(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)); + + 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); + } + }); +})(); + +return numeral; +})); diff --git a/src/locales/be-nl.js b/src/locales/nl-be.js similarity index 86% rename from src/locales/be-nl.js rename to src/locales/nl-be.js index 15d948f5..6b561904 100644 --- a/src/locales/be-nl.js +++ b/src/locales/nl-be.js @@ -1,6 +1,7 @@ // numeral.js locale configuration -// locale : belgium-dutch (be-nl) +// 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) { @@ -11,7 +12,7 @@ factory(global.numeral); } }(this, function (numeral) { - numeral.register('locale', 'be-nl', { + numeral.register('locale', 'nl-be', { delimiters: { thousands: ' ', decimal : ',' diff --git a/tests/locales/be-nl.js b/tests/locales/nl-be.js similarity index 97% rename from tests/locales/be-nl.js rename to tests/locales/nl-be.js index 8744f7db..d7adc329 100644 --- a/tests/locales/be-nl.js +++ b/tests/locales/nl-be.js @@ -5,10 +5,10 @@ if (typeof module !== 'undefined' && module.exports) { var expect = require('chai').expect; } -describe('Locale: be-nl', function() { +describe('Locale: nl-be', function() { before(function() { - numeral.locale('be-nl'); + numeral.locale('nl-be'); }); after(function() { From 5bfe3a48e83f63e2cda384e44ae455debcd43da7 Mon Sep 17 00:00:00 2001 From: Ammar Hasan Date: Fri, 17 Mar 2017 23:14:25 +0500 Subject: [PATCH 143/150] Update numeral.js --- numeral.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numeral.js b/numeral.js index f62733f1..15215201 100644 --- a/numeral.js +++ b/numeral.js @@ -951,4 +951,4 @@ })(); return numeral; -})); \ No newline at end of file +})); From 3a832fbc838f9cb496c20beaf11542e4c0abd0a6 Mon Sep 17 00:00:00 2001 From: Hoa Nguyen Thai Date: Mon, 20 Mar 2017 10:37:20 +0700 Subject: [PATCH 144/150] add Vietnam locale (vi) --- locales.js | 23 +++++++++++ locales/vi.js | 33 +++++++++++++++ src/locales/vi.js | 33 +++++++++++++++ tests/locales/vi.js | 98 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 187 insertions(+) create mode 100644 locales/vi.js create mode 100644 src/locales/vi.js create mode 100644 tests/locales/vi.js diff --git a/locales.js b/locales.js index e4df734f..2a5c4865 100644 --- a/locales.js +++ b/locales.js @@ -820,4 +820,27 @@ })(); +(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/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/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/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]); + } + }); + }); +}); From 3865d14aed50c6fd723391fe6fc7113c8892d413 Mon Sep 17 00:00:00 2001 From: Jack Altiere Date: Wed, 22 Mar 2017 11:05:48 -0400 Subject: [PATCH 145/150] added support for BPS, fixed byte format so BPS numbers were not treated as bytes --- locales.js | 1678 ++++++++++++++++++------------------ numeral.js | 1956 ++++++++++++++++++++++-------------------- src/formats/bps.js | 47 + src/formats/bytes.js | 9 +- tests/formats/bps.js | 42 + 5 files changed, 1955 insertions(+), 1777 deletions(-) create mode 100644 src/formats/bps.js create mode 100644 tests/formats/bps.js diff --git a/locales.js b/locales.js index e4df734f..ea89fd6a 100644 --- a/locales.js +++ b/locales.js @@ -1,823 +1,855 @@ -/*! @preserve - * numeral.js - * locales : 2.0.4 - * 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', 'be-nl', { - 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', '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-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' - } - }); -})(); - - -})); +/*! @preserve + * numeral.js + * locales : 2.0.4 + * 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', 'be-nl', { + 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', '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-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' + } + }); +})(); + + +})); diff --git a/numeral.js b/numeral.js index 83ff379a..30eb00cf 100644 --- a/numeral.js +++ b/numeral.js @@ -1,955 +1,1005 @@ -/*! @preserve - * numeral.js - * version : 2.0.4 - * 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.4', - formats = {}, - locales = {}, - defaults = { - currentLocale: 'en', - zeroFormat: null, - nullFormat: null, - defaultFormat: '0,0' - }, - options = { - currentLocale: defaults.currentLocale, - zeroFormat: defaults.zeroFormat, - nullFormat: defaults.nullFormat, - defaultFormat: defaults.defaultFormat - }; - - - /************************************ - 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, - 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(','); - - 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, null, 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 (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); - - //roundingFunction = (roundingFunction !== undefined ? roundingFunction : Math.round); - // Multiply up by precision, round accurately, then divide and use native toFixed(): - output = (roundingFunction(value * power) / 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: '$' - } - }); - +/*! @preserve + * numeral.js + * version : 2.0.4 + * 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.4', + formats = {}, + locales = {}, + defaults = { + currentLocale: 'en', + zeroFormat: null, + nullFormat: null, + defaultFormat: '0,0' + }, + options = { + currentLocale: defaults.currentLocale, + zeroFormat: defaults.zeroFormat, + nullFormat: defaults.nullFormat, + defaultFormat: defaults.defaultFormat + }; + + + /************************************ + 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, + 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(','); + + 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, null, 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 (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); + + //roundingFunction = (roundingFunction !== undefined ? roundingFunction : Math.round); + // Multiply up by precision, round accurately, then divide and use native toFixed(): + output = (roundingFunction(value * power) / 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: '$' + } + }); + -(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'] - }; - - numeral.register('format', 'bytes', { - regexps: { - format: /([0\s]i?b)/, - unformat: new RegExp('(' + decimal.suffixes.concat(binary.suffixes).join('|') + ')') - }, - 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; - } - }); -})(); - - -(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]; - - switch (symbol) { - case '$': - output = numeral._.insert(output, locale.currency.symbol, i); - break; - case ' ': - output = numeral._.insert(output, ' ', i); - 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))); - 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'); - - 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); - } - }); -})(); - - -(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') ? ' ' : ''; - - // 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; - - 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) { - return numeral._.stringToNumber(string) * 0.01; - } - }); -})(); - - -(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)); - - 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); - } - }); -})(); - -return numeral; -})); +(function() { + + 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); + } + }); +})(); + + +(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; + } + } + + 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; + } + }); +})(); + + +(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]; + + switch (symbol) { + case '$': + output = numeral._.insert(output, locale.currency.symbol, i); + break; + case ' ': + output = numeral._.insert(output, ' ', i); + 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))); + 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'); + + 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); + } + }); +})(); + + +(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') ? ' ' : ''; + + // 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; + + 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) { + return numeral._.stringToNumber(string) * 0.01; + } + }); +})(); + + +(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)); + + 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); + } + }); +})(); + +return 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 index d39a8598..a07a85da 100644 --- a/src/formats/bytes.js +++ b/src/formats/bytes.js @@ -20,10 +20,17 @@ 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('(' + decimal.suffixes.concat(binary.suffixes).join('|') + ')') + unformat: new RegExp(unformatRegex) }, format: function(value, format, roundingFunction) { var output, 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]); + } + }); +}); From 1acd773be5cf88a04c781000bce25e643db47803 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sat, 25 Mar 2017 21:22:24 -0700 Subject: [PATCH 146/150] rebuild for dev --- locales.js | 1678 +++++++++++++++++++++---------------------- numeral.js | 1999 ++++++++++++++++++++++++++-------------------------- 2 files changed, 1819 insertions(+), 1858 deletions(-) diff --git a/locales.js b/locales.js index ea89fd6a..e4df734f 100644 --- a/locales.js +++ b/locales.js @@ -1,855 +1,823 @@ -/*! @preserve - * numeral.js - * locales : 2.0.4 - * 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', 'be-nl', { - 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', '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-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' - } - }); -})(); - - -})); +/*! @preserve + * numeral.js + * locales : 2.0.4 + * 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', 'be-nl', { + 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', '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-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' + } + }); +})(); + + +})); diff --git a/numeral.js b/numeral.js index 30eb00cf..09bfef99 100644 --- a/numeral.js +++ b/numeral.js @@ -1,1005 +1,998 @@ -/*! @preserve - * numeral.js - * version : 2.0.4 - * 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.4', - formats = {}, - locales = {}, - defaults = { - currentLocale: 'en', - zeroFormat: null, - nullFormat: null, - defaultFormat: '0,0' - }, - options = { - currentLocale: defaults.currentLocale, - zeroFormat: defaults.zeroFormat, - nullFormat: defaults.nullFormat, - defaultFormat: defaults.defaultFormat - }; - - - /************************************ - 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, - 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(','); - - 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, null, 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 (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); - - //roundingFunction = (roundingFunction !== undefined ? roundingFunction : Math.round); - // Multiply up by precision, round accurately, then divide and use native toFixed(): - output = (roundingFunction(value * power) / 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: '$' - } - }); - +/*! @preserve + * numeral.js + * version : 2.0.4 + * 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.4', + formats = {}, + locales = {}, + defaults = { + currentLocale: 'en', + zeroFormat: null, + nullFormat: null, + defaultFormat: '0,0' + }, + options = { + currentLocale: defaults.currentLocale, + zeroFormat: defaults.zeroFormat, + nullFormat: defaults.nullFormat, + defaultFormat: defaults.defaultFormat + }; + + + /************************************ + 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, + 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(','); + + 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, null, 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 (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); + + //roundingFunction = (roundingFunction !== undefined ? roundingFunction : Math.round); + // Multiply up by precision, round accurately, then divide and use native toFixed(): + output = (roundingFunction(value * power) / 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: '$' + } + }); + -(function() { - - 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); - } - }); -})(); - - -(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; - } - } - - 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; - } - }); -})(); - - -(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]; - - switch (symbol) { - case '$': - output = numeral._.insert(output, locale.currency.symbol, i); - break; - case ' ': - output = numeral._.insert(output, ' ', i); - 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))); - 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'); - - 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); - } - }); -})(); - - -(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') ? ' ' : ''; - - // 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; - - 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) { - return numeral._.stringToNumber(string) * 0.01; - } - }); -})(); - - -(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)); - - 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); - } - }); -})(); - -return numeral; -})); +(function() { + 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); + } + }); +})(); + + +(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; + } + } + + 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; + } + }); +})(); + + +(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]; + + switch (symbol) { + case '$': + output = numeral._.insert(output, locale.currency.symbol, i); + break; + case ' ': + output = numeral._.insert(output, ' ', i); + 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))); + 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'); + + 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); + } + }); +})(); + + +(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') ? ' ' : ''; + + // 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; + + 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) { + return numeral._.stringToNumber(string) * 0.01; + } + }); +})(); + + +(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)); + + 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); + } + }); +})(); + +return numeral; +})); From 0a87f0f3c2ffe2a4ec33886fab594e6104dbeb9f Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sat, 25 Mar 2017 21:35:20 -0700 Subject: [PATCH 147/150] update readme --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 4c20f55d..17064792 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,12 @@ See [the english unit tests](https://github.com/adamwdraper/Numeral-js/blob/mast # Changelog +### 2.0.5 + +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) From 5ed0eea399a0945e2239eccb1d31bb8828be0ae3 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sat, 25 Mar 2017 22:41:20 -0700 Subject: [PATCH 148/150] add leading zeros --- README.md | 2 ++ numeral.js | 10 +++++++++- src/numeral.js | 10 +++++++++- tests/numeral.js | 9 +++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 17064792..731e0809 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,8 @@ See [the english unit tests](https://github.com/adamwdraper/Numeral-js/blob/mast ### 2.0.5 +Added: Formatting of numbers with leading zeros + New format: Basic Point Option: Added `scalePercentBy100` (default: true) option to turn on/off scaling percentages diff --git a/numeral.js b/numeral.js index d96da39d..6af7f5b9 100644 --- a/numeral.js +++ b/numeral.js @@ -21,7 +21,7 @@ var numeral, _, - VERSION = '2.0.4', + VERSION = '2.0.5', formats = {}, locales = {}, defaults = { @@ -105,6 +105,7 @@ var locale = locales[numeral.options.currentLocale], negP = false, optDec = false, + leadingCount = 0, abbr = '', trillion = 1000000000000, billion = 1000000000, @@ -180,6 +181,7 @@ 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, '[')) { @@ -229,6 +231,12 @@ 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); } diff --git a/src/numeral.js b/src/numeral.js index f7f0c8e1..1a58c87e 100644 --- a/src/numeral.js +++ b/src/numeral.js @@ -21,7 +21,7 @@ var numeral, _, - VERSION = '2.0.4', + VERSION = '2.0.5', formats = {}, locales = {}, defaults = { @@ -105,6 +105,7 @@ var locale = locales[numeral.options.currentLocale], negP = false, optDec = false, + leadingCount = 0, abbr = '', trillion = 1000000000000, billion = 1000000000, @@ -180,6 +181,7 @@ 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, '[')) { @@ -229,6 +231,12 @@ 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); } diff --git a/tests/numeral.js b/tests/numeral.js index adfe3f6d..4c9208af 100644 --- a/tests/numeral.js +++ b/tests/numeral.js @@ -138,6 +138,7 @@ describe('Numeral', function() { [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'], @@ -171,6 +172,14 @@ describe('Numeral', function() { [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'], From 9a05a30d01f1987cb144db5d785eb8d07f6e16f2 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sat, 25 Mar 2017 23:02:24 -0700 Subject: [PATCH 149/150] 2.0.5 --- README.md | 2 ++ bower.json | 2 +- component.json | 2 +- locales.js | 2 +- numeral.js | 2 +- package.json | 2 +- src/numeral.js | 2 +- templates/types.js | 2 +- 8 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 731e0809..86c55057 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,8 @@ See [the english unit tests](https://github.com/adamwdraper/Numeral-js/blob/mast ### 2.0.5 +Bug fix: Multi letter currency symbols and spacing + Added: Formatting of numbers with leading zeros New format: Basic Point diff --git a/bower.json b/bower.json index a1c69051..32df9aa6 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "numeral", "repo": "adamwdraper/Numeral-js", - "version": "2.0.4", + "version": "2.0.5", "description": "Format and manipulate numbers.", "keywords": [ "numeral", diff --git a/component.json b/component.json index a1c69051..32df9aa6 100644 --- a/component.json +++ b/component.json @@ -1,7 +1,7 @@ { "name": "numeral", "repo": "adamwdraper/Numeral-js", - "version": "2.0.4", + "version": "2.0.5", "description": "Format and manipulate numbers.", "keywords": [ "numeral", diff --git a/locales.js b/locales.js index 45554a57..1bafb03d 100644 --- a/locales.js +++ b/locales.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js - * locales : 2.0.4 + * locales : 2.0.5 * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ diff --git a/numeral.js b/numeral.js index 1bfa0361..f9216842 100644 --- a/numeral.js +++ b/numeral.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js - * version : 2.0.4 + * version : 2.0.5 * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ diff --git a/package.json b/package.json index 804cd7b6..87f6521e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "numeral", - "version": "2.0.4", + "version": "2.0.5", "description": "Format and manipulate numbers.", "homepage": "http://numeraljs.com/", "author": { diff --git a/src/numeral.js b/src/numeral.js index 1a58c87e..0c4d17d0 100644 --- a/src/numeral.js +++ b/src/numeral.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js - * version : 2.0.4 + * version : 2.0.5 * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ diff --git a/templates/types.js b/templates/types.js index a09d14d5..87790286 100644 --- a/templates/types.js +++ b/templates/types.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js - * <%= type %> : 2.0.4 + * <%= type %> : 2.0.5 * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ From 30956925463d19d4cf84488dcd8005da40cf9728 Mon Sep 17 00:00:00 2001 From: Adam Draper Date: Sun, 26 Mar 2017 23:41:29 -0700 Subject: [PATCH 150/150] fix list builds --- README.md | 2 +- bower.json | 2 +- component.json | 2 +- locales.js | 2 +- min/locales.min.js | 8 ++------ min/locales/nl-be.min.js | 2 +- min/locales/nl-nl.min.js | 2 +- min/locales/vi.min.js | 1 + min/numeral.min.js | 12 ++---------- numeral.js | 4 ++-- package.json | 2 +- src/numeral.js | 4 ++-- templates/types.js | 2 +- 13 files changed, 17 insertions(+), 28 deletions(-) create mode 100644 min/locales/vi.min.js diff --git a/README.md b/README.md index 86c55057..f1d414d7 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ See [the english unit tests](https://github.com/adamwdraper/Numeral-js/blob/mast # Changelog -### 2.0.5 +### 2.0.6 Bug fix: Multi letter currency symbols and spacing diff --git a/bower.json b/bower.json index 32df9aa6..a1d77150 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "numeral", "repo": "adamwdraper/Numeral-js", - "version": "2.0.5", + "version": "2.0.6", "description": "Format and manipulate numbers.", "keywords": [ "numeral", diff --git a/component.json b/component.json index 32df9aa6..a1d77150 100644 --- a/component.json +++ b/component.json @@ -1,7 +1,7 @@ { "name": "numeral", "repo": "adamwdraper/Numeral-js", - "version": "2.0.5", + "version": "2.0.6", "description": "Format and manipulate numbers.", "keywords": [ "numeral", diff --git a/locales.js b/locales.js index 1bafb03d..1f89d5a2 100644 --- a/locales.js +++ b/locales.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js - * locales : 2.0.5 + * locales : 2.0.6 * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ diff --git a/min/locales.min.js b/min/locales.min.js index c647d80a..39b1736a 100644 --- a/min/locales.min.js +++ b/min/locales.min.js @@ -1,11 +1,7 @@ /*! @preserve * numeral.js - * locales : 2.0.4 + * locales : 2.0.6 * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -<<<<<<< HEAD -!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","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:"€ "}})}(),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-nl",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mln",billion:"mrd",trillion:"bln"},ordinal:function(a){var b=a%100;return 0!==a&&b<=1||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,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&&b<=1||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&&b<=1||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:"₴"}})}()}); ->>>>>>> develop +!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/nl-be.min.js b/min/locales/nl-be.min.js index 764b3ac2..d97a6ff2 100644 --- a/min/locales/nl-be.min.js +++ b/min/locales/nl-be.min.js @@ -1 +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&&b<=1||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}); \ No newline at end of file +!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 index 17914720..1e50e799 100644 --- a/min/locales/nl-nl.min.js +++ b/min/locales/nl-nl.min.js @@ -1 +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&&b<=1||8===b||b>=20?"ste":"de"},currency:{symbol:"€ "}})}); \ No newline at end of file +!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/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 47636306..b721f54a 100644 --- a/min/numeral.min.js +++ b/min/numeral.min.js @@ -1,16 +1,8 @@ /*! @preserve * numeral.js - * version : 2.0.4 + * version : 2.0.6 * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ -<<<<<<< HEAD -!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.4",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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="",q=1e12,r=1e9,s=1e6,t=1e3,u="",v=!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("+"):a<0?c.indexOf("-"):-1,c=c.replace(/[\+|\-]/g,"")),b._.includes(c,"a")&&(e=c.match(/a(k|m|b|t)?/),e=!!e&&e[1],b._.includes(c," a")&&(p=" "),c=c.replace(new RegExp(p+"a[kmbt]?"),""),g>=q&&!e||"t"===e?(p+=m.abbreviations.trillion,a/=q):g=r&&!e||"b"===e?(p+=m.abbreviations.billion,a/=r):g=s&&!e||"m"===e?(p+=m.abbreviations.million,a/=s):(g=t&&!e||"k"===e)&&(p+=m.abbreviations.thousand,a/=t)),b._.includes(c,"[.]")&&(o=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],k=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),u=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):u=b._.toFixed(a,i.length,d),h=u.split(".")[0],u=b._.includes(u,".")?m.delimiters.decimal+u.split(".")[1]:"",o&&0===Number(u.slice(1))&&(u="")):h=b._.toFixed(a,0,d),p&&!e&&Number(h)>=1e3&&p!==m.abbreviations.trillion)switch(h=String(Number(h)/1e3),p){case m.abbreviations.thousand:p=m.abbreviations.million;break;case m.abbreviations.million:p=m.abbreviations.billion;break;case m.abbreviations.billion:p=m.abbreviations.trillion}return b._.includes(h,"-")&&(h=h.slice(1),v=!0),k>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+m.delimiters.thousands)),0===c.indexOf(".")&&(h=""),l=h+u+(p?p:""),n?l=(n&&v?"(":"")+l+(n&&v?")":""):j>=0?l=0===j?(v?"-":"+")+l:l+(v?"-":"+"):v&&(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 a.indexOf(b)!==-1},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(;f=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;fd?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(a){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))&&(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))&&(i=new RegExp(e+"{2}"),!a.match(/[^\d.,]/g)&&(g=a.split(d),!(g.length>2)&&(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(){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"]};b.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+a.suffixes.concat(c.suffixes).join("|")+")")},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&&d0&&(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(/[\-\)]/,"")):a<0&&!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 a*=100,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){return.01*b._.stringToNumber(a)}})}(),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+":"+(e<10?"0"+e:e)+":"+(f<10?"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}); -======= -<<<<<<< HEAD -!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.4",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="",q=1e12,r=1e9,s=1e6,t=1e3,u="",v=!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("+"):a<0?c.indexOf("-"):-1,c=c.replace(/[\+|\-]/g,"")),b._.includes(c,"a")&&(e=c.match(/a(k|m|b|t)?/),e=!!e&&e[1],b._.includes(c," a")&&(p=" "),c=c.replace(new RegExp(p+"a[kmbt]?"),""),g>=q&&!e||"t"===e?(p+=m.abbreviations.trillion,a/=q):g=r&&!e||"b"===e?(p+=m.abbreviations.billion,a/=r):g=s&&!e||"m"===e?(p+=m.abbreviations.million,a/=s):(g=t&&!e||"k"===e)&&(p+=m.abbreviations.thousand,a/=t)),b._.includes(c,"[.]")&&(o=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],k=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),u=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):u=b._.toFixed(a,i.length,d),h=u.split(".")[0],u=b._.includes(u,".")?m.delimiters.decimal+u.split(".")[1]:"",o&&0===Number(u.slice(1))&&(u="")):h=b._.toFixed(a,null,d),p&&!e&&Number(h)>=1e3&&p!==m.abbreviations.trillion)switch(h=String(Number(h)/1e3),p){case m.abbreviations.thousand:p=m.abbreviations.million;break;case m.abbreviations.million:p=m.abbreviations.billion;break;case m.abbreviations.billion:p=m.abbreviations.trillion}return b._.includes(h,"-")&&(h=h.slice(1),v=!0),k>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+m.delimiters.thousands)),0===c.indexOf(".")&&(h=""),l=h+u+(p?p:""),n?l=(n&&v?"(":"")+l+(n&&v?")":""):j>=0?l=0===j?(v?"-":"+")+l:l+(v?"-":"+"):v&&(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 a.indexOf(b)!==-1},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(;f=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;fd?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*g)/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(a){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))&&(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))&&(i=new RegExp(e+"{2}"),!a.match(/[^\d.,]/g)&&(g=a.split(d),!(g.length>2)&&(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(){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"]};b.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+a.suffixes.concat(c.suffixes).join("|")+")")},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&&d0&&(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(/[\-\)]/,"")):a<0&&!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)))}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),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+":"+(e<10?"0"+e:e)+":"+(f<10?"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}); -======= -!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.4",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat};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="",q=1e12,r=1e9,s=1e6,t=1e3,u="",v=!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("+"):a<0?c.indexOf("-"):-1,c=c.replace(/[\+|\-]/g,"")),b._.includes(c,"a")&&(e=c.match(/a(k|m|b|t)?/),e=!!e&&e[1],b._.includes(c," a")&&(p=" "),c=c.replace(new RegExp(p+"a[kmbt]?"),""),g>=q&&!e||"t"===e?(p+=m.abbreviations.trillion,a/=q):g=r&&!e||"b"===e?(p+=m.abbreviations.billion,a/=r):g=s&&!e||"m"===e?(p+=m.abbreviations.million,a/=s):(g=t&&!e||"k"===e)&&(p+=m.abbreviations.thousand,a/=t)),b._.includes(c,"[.]")&&(o=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],k=c.indexOf(","),i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),u=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):u=b._.toFixed(a,i.length,d),h=u.split(".")[0],u=b._.includes(u,".")?m.delimiters.decimal+u.split(".")[1]:"",o&&0===Number(u.slice(1))&&(u="")):h=b._.toFixed(a,0,d),p&&!e&&Number(h)>=1e3&&p!==m.abbreviations.trillion)switch(h=String(Number(h)/1e3),p){case m.abbreviations.thousand:p=m.abbreviations.million;break;case m.abbreviations.million:p=m.abbreviations.billion;break;case m.abbreviations.billion:p=m.abbreviations.trillion}return b._.includes(h,"-")&&(h=h.slice(1),v=!0),k>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+m.delimiters.thousands)),0===c.indexOf(".")&&(h=""),l=h+u+(p?p:""),n?l=(n&&v?"(":"")+l+(n&&v?")":""):j>=0?l=0===j?(v?"-":"+")+l:l+(v?"-":"+"):v&&(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 a.indexOf(b)!==-1},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(;f=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;fd?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(a){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))&&(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))&&(i=new RegExp(e+"{2}"),!a.match(/[^\d.,]/g)&&(g=a.split(d),!(g.length>2)&&(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(){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"]};b.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp("("+a.suffixes.concat(c.suffixes).join("|")+")")},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&&d0&&(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(/[\-\)]/,"")):a<0&&!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)))}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 a*=100,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){return.01*b._.stringToNumber(a)}})}(),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+":"+(e<10?"0"+e:e)+":"+(f<10?"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}); ->>>>>>> develop ->>>>>>> develop +!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 f9216842..22726c9e 100644 --- a/numeral.js +++ b/numeral.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js - * version : 2.0.5 + * version : 2.0.6 * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ @@ -21,7 +21,7 @@ var numeral, _, - VERSION = '2.0.5', + VERSION = '2.0.6', formats = {}, locales = {}, defaults = { diff --git a/package.json b/package.json index 87f6521e..d3dafc78 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "numeral", - "version": "2.0.5", + "version": "2.0.6", "description": "Format and manipulate numbers.", "homepage": "http://numeraljs.com/", "author": { diff --git a/src/numeral.js b/src/numeral.js index 0c4d17d0..3a9d2521 100644 --- a/src/numeral.js +++ b/src/numeral.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js - * version : 2.0.5 + * version : 2.0.6 * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ @@ -21,7 +21,7 @@ var numeral, _, - VERSION = '2.0.5', + VERSION = '2.0.6', formats = {}, locales = {}, defaults = { diff --git a/templates/types.js b/templates/types.js index 87790286..c6256a5c 100644 --- a/templates/types.js +++ b/templates/types.js @@ -1,6 +1,6 @@ /*! @preserve * numeral.js - * <%= type %> : 2.0.5 + * <%= type %> : 2.0.6 * license : MIT * http://adamwdraper.github.com/Numeral-js/ */