Comparing version 1.9.3 to 1.10.0
@@ -0,1 +1,12 @@ | ||
### 1.10.0 | ||
- Fix #213: Unhelpful Error Message with $ as Format String. Thanks @reustle. | ||
- Fix #221: update package.json license field. Thanks @mguida22. | ||
- Fix #190: Allow abbreviation precision for < 4. Thanks @chrisnicola. | ||
- Fix #227: Add Romanian locale. Thanks @herodrigues. | ||
- Fix #222: allow a decimal format for an integer. Thanks @mguida22. | ||
- Fix #233: Correct CZ and SK locales (finally). Thanks @smajl. | ||
- Fix #244: Fixes for fr-CH. Thanks @gwynjudd. | ||
- Fix #262: Better input validation. Thanks @BenjaminVanRyseghem. | ||
### 1.9.3 | ||
@@ -2,0 +13,0 @@ |
@@ -5,3 +5,3 @@ /*! | ||
* locale: Czech Republic | ||
* author : Anatoli Papirovski : https://github.com/apapirovski | ||
* author : Jan Pesa : https://github.com/smajl (based on work from Anatoli Papirovski : https://github.com/apapirovski) | ||
*/ | ||
@@ -15,3 +15,3 @@ (function () { | ||
delimiters: { | ||
thousands: ' ', | ||
thousands: '\u00a0', | ||
decimal: ',' | ||
@@ -22,4 +22,4 @@ }, | ||
million: 'mil.', | ||
billion: 'b', | ||
trillion: 't' | ||
billion: 'mld.', | ||
trillion: 'bil.' | ||
}, | ||
@@ -31,3 +31,4 @@ ordinal: function () { | ||
symbol: 'Kč', | ||
position: 'postfix' | ||
position: 'postfix', | ||
spaceSeparated: true | ||
}, | ||
@@ -785,3 +786,3 @@ defaults: { | ||
delimiters: { | ||
thousands: '\'', | ||
thousands: ' ', | ||
decimal: '.' | ||
@@ -1460,2 +1461,51 @@ }, | ||
/*! | ||
* numeral.js language configuration | ||
* language : Romanian | ||
* author : Andrei Alecu https://github.com/andreialecu | ||
*/ | ||
(function () { | ||
'use strict'; | ||
var language = { | ||
langLocaleCode: 'ro-RO', | ||
cultureCode: 'ro-RO', | ||
delimiters: { | ||
thousands: '.', | ||
decimal: ',' | ||
}, | ||
abbreviations: { | ||
thousand: 'mii', | ||
million: 'mil', | ||
billion: 'mld', | ||
trillion: 'bln' | ||
}, | ||
ordinal: function () { | ||
return '.'; | ||
}, | ||
currency: { | ||
symbol: ' lei', | ||
position: 'postfix' | ||
}, | ||
defaults: { | ||
currencyFormat: ',4 a' | ||
}, | ||
formats: { | ||
fourDigits: '4 a', | ||
fullWithTwoDecimals: ',0.00 $', | ||
fullWithTwoDecimalsNoCurrency: ',0.00', | ||
fullWithNoDecimals: ',0 $' | ||
} | ||
}; | ||
// CommonJS | ||
if (typeof module !== 'undefined' && module.exports) { | ||
module.exports = language; | ||
} | ||
// Browser | ||
if (typeof window !== 'undefined' && window.numbro && window.numbro.culture) { | ||
window.numbro.culture(language.cultureCode, language); | ||
} | ||
}.call(typeof window === 'undefined' ? this : window)); | ||
/*! | ||
* numbro.js language configuration | ||
@@ -1570,3 +1620,3 @@ * language : Russian | ||
* locale : Slovakia | ||
* author : Ahmed Al Hafoudh : http://www.freevision.sk | ||
* author : Jan Pesa : https://github.com/smajl (based on work from Ahmed Al Hafoudh : http://www.freevision.sk) | ||
*/ | ||
@@ -1580,3 +1630,3 @@ (function () { | ||
delimiters: { | ||
thousands: ' ', | ||
thousands: '\u00a0', | ||
decimal: ',' | ||
@@ -1587,4 +1637,4 @@ }, | ||
million: 'mil.', | ||
billion: 'b', | ||
trillion: 't' | ||
billion: 'mld.', | ||
trillion: 'bil.' | ||
}, | ||
@@ -1596,3 +1646,4 @@ ordinal: function () { | ||
symbol: '€', | ||
position: 'postfix' | ||
position: 'postfix', | ||
spaceSeparated: true | ||
}, | ||
@@ -1599,0 +1650,0 @@ defaults: { |
@@ -5,5 +5,5 @@ /*! | ||
* locale: Czech Republic | ||
* author : Anatoli Papirovski : https://github.com/apapirovski | ||
* author : Jan Pesa : https://github.com/smajl (based on work from Anatoli Papirovski : https://github.com/apapirovski) | ||
*/ | ||
(function(){"use strict";var a={langLocaleCode:"cs-CZ",cultureCode:"cs-CZ",delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"Kč",position:"postfix"},defaults:{currencyFormat:",4 a"},formats:{fourDigits:"4 a",fullWithTwoDecimals:",0.00 $",fullWithTwoDecimalsNoCurrency:",0.00",fullWithNoDecimals:",0 $"}}; | ||
(function(){"use strict";var a={langLocaleCode:"cs-CZ",cultureCode:"cs-CZ",delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"mld.",trillion:"bil."},ordinal:function(){return"."},currency:{symbol:"Kč",position:"postfix",spaceSeparated:!0},defaults:{currencyFormat:",4 a"},formats:{fourDigits:"4 a",fullWithTwoDecimals:",0.00 $",fullWithTwoDecimalsNoCurrency:",0.00",fullWithNoDecimals:",0 $"}}; | ||
// CommonJS | ||
@@ -163,3 +163,3 @@ "undefined"!=typeof module&&module.exports&&(module.exports=a), | ||
*/ | ||
function(){"use strict";var a={langLocaleCode:"fr-CH",cultureCode:"fr-CH",delimiters:{thousands:"'",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return 1===a?"er":"ème"},currency:{symbol:"CHF",position:"postfix"},defaults:{currencyFormat:",4 a"},formats:{fourDigits:"4 a",fullWithTwoDecimals:",0.00 $",fullWithTwoDecimalsNoCurrency:",0.00",fullWithNoDecimals:",0 $"}}; | ||
function(){"use strict";var a={langLocaleCode:"fr-CH",cultureCode:"fr-CH",delimiters:{thousands:" ",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return 1===a?"er":"ème"},currency:{symbol:"CHF",position:"postfix"},defaults:{currencyFormat:",4 a"},formats:{fourDigits:"4 a",fullWithTwoDecimals:",0.00 $",fullWithTwoDecimalsNoCurrency:",0.00",fullWithNoDecimals:",0 $"}}; | ||
// CommonJS | ||
@@ -302,2 +302,11 @@ "undefined"!=typeof module&&module.exports&&(module.exports=a), | ||
"undefined"!=typeof window&&window.numbro&&window.numbro.culture&&window.numbro.culture(a.cultureCode,a)}.call("undefined"==typeof window?this:window),/*! | ||
* numeral.js language configuration | ||
* language : Romanian | ||
* author : Andrei Alecu https://github.com/andreialecu | ||
*/ | ||
function(){"use strict";var a={langLocaleCode:"ro-RO",cultureCode:"ro-RO",delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mii",million:"mil",billion:"mld",trillion:"bln"},ordinal:function(){return"."},currency:{symbol:" lei",position:"postfix"},defaults:{currencyFormat:",4 a"},formats:{fourDigits:"4 a",fullWithTwoDecimals:",0.00 $",fullWithTwoDecimalsNoCurrency:",0.00",fullWithNoDecimals:",0 $"}}; | ||
// CommonJS | ||
"undefined"!=typeof module&&module.exports&&(module.exports=a), | ||
// Browser | ||
"undefined"!=typeof window&&window.numbro&&window.numbro.culture&&window.numbro.culture(a.cultureCode,a)}.call("undefined"==typeof window?this:window),/*! | ||
* numbro.js language configuration | ||
@@ -334,5 +343,5 @@ * language : Russian | ||
* locale : Slovakia | ||
* author : Ahmed Al Hafoudh : http://www.freevision.sk | ||
* author : Jan Pesa : https://github.com/smajl (based on work from Ahmed Al Hafoudh : http://www.freevision.sk) | ||
*/ | ||
function(){"use strict";var a={langLocaleCode:"sk-SK",cultureCode:"sk-SK",delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€",position:"postfix"},defaults:{currencyFormat:",4 a"},formats:{fourDigits:"4 a",fullWithTwoDecimals:",0.00 $",fullWithTwoDecimalsNoCurrency:",0.00",fullWithNoDecimals:",0 $"}}; | ||
function(){"use strict";var a={langLocaleCode:"sk-SK",cultureCode:"sk-SK",delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"mld.",trillion:"bil."},ordinal:function(){return"."},currency:{symbol:"€",position:"postfix",spaceSeparated:!0},defaults:{currencyFormat:",4 a"},formats:{fourDigits:"4 a",fullWithTwoDecimals:",0.00 $",fullWithTwoDecimalsNoCurrency:",0.00",fullWithNoDecimals:",0 $"}}; | ||
// CommonJS | ||
@@ -339,0 +348,0 @@ "undefined"!=typeof module&&module.exports&&(module.exports=a), |
@@ -5,5 +5,5 @@ /*! | ||
* locale: Czech Republic | ||
* author : Anatoli Papirovski : https://github.com/apapirovski | ||
* author : Jan Pesa : https://github.com/smajl (based on work from Anatoli Papirovski : https://github.com/apapirovski) | ||
*/ | ||
(function(){"use strict";var a={langLocaleCode:"cs-CZ",cultureCode:"cs-CZ",delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"Kč",position:"postfix"},defaults:{currencyFormat:",4 a"},formats:{fourDigits:"4 a",fullWithTwoDecimals:",0.00 $",fullWithTwoDecimalsNoCurrency:",0.00",fullWithNoDecimals:",0 $"}}; | ||
(function(){"use strict";var a={langLocaleCode:"cs-CZ",cultureCode:"cs-CZ",delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"mld.",trillion:"bil."},ordinal:function(){return"."},currency:{symbol:"Kč",position:"postfix",spaceSeparated:!0},defaults:{currencyFormat:",4 a"},formats:{fourDigits:"4 a",fullWithTwoDecimals:",0.00 $",fullWithTwoDecimalsNoCurrency:",0.00",fullWithNoDecimals:",0 $"}}; | ||
// CommonJS | ||
@@ -10,0 +10,0 @@ "undefined"!=typeof module&&module.exports&&(module.exports=a), |
@@ -7,3 +7,3 @@ /*! | ||
*/ | ||
(function(){"use strict";var a={langLocaleCode:"fr-CH",cultureCode:"fr-CH",delimiters:{thousands:"'",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return 1===a?"er":"ème"},currency:{symbol:"CHF",position:"postfix"},defaults:{currencyFormat:",4 a"},formats:{fourDigits:"4 a",fullWithTwoDecimals:",0.00 $",fullWithTwoDecimalsNoCurrency:",0.00",fullWithNoDecimals:",0 $"}}; | ||
(function(){"use strict";var a={langLocaleCode:"fr-CH",cultureCode:"fr-CH",delimiters:{thousands:" ",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){return 1===a?"er":"ème"},currency:{symbol:"CHF",position:"postfix"},defaults:{currencyFormat:",4 a"},formats:{fourDigits:"4 a",fullWithTwoDecimals:",0.00 $",fullWithTwoDecimalsNoCurrency:",0.00",fullWithNoDecimals:",0 $"}}; | ||
// CommonJS | ||
@@ -10,0 +10,0 @@ "undefined"!=typeof module&&module.exports&&(module.exports=a), |
@@ -1,1 +0,1 @@ | ||
exports["cs-CZ"]=require("./cs-CZ.js"),exports["da-DK"]=require("./da-DK.js"),exports["de-CH"]=require("./de-CH.js"),exports["de-DE"]=require("./de-DE.js"),exports["en-AU"]=require("./en-AU.js"),exports["en-GB"]=require("./en-GB.js"),exports["en-NZ"]=require("./en-NZ.js"),exports["en-ZA"]=require("./en-ZA.js"),exports["es-AR"]=require("./es-AR.js"),exports["es-ES"]=require("./es-ES.js"),exports["et-EE"]=require("./et-EE.js"),exports["fa-IR"]=require("./fa-IR.js"),exports["fi-FI"]=require("./fi-FI.js"),exports["fil-PH"]=require("./fil-PH.js"),exports["fr-CA"]=require("./fr-CA.js"),exports["fr-CH"]=require("./fr-CH.js"),exports["fr-FR"]=require("./fr-FR.js"),exports["he-IL"]=require("./he-IL.js"),exports["hu-HU"]=require("./hu-HU.js"),exports["it-IT"]=require("./it-IT.js"),exports["ja-JP"]=require("./ja-JP.js"),exports["ko-KR"]=require("./ko-KR.js"),exports["lv-LV"]=require("./lv-LV.js"),exports["nb-NO"]=require("./nb-NO.js"),exports["nl-BE"]=require("./nl-BE.js"),exports["nl-NL"]=require("./nl-NL.js"),exports["pl-PL"]=require("./pl-PL.js"),exports["pt-BR"]=require("./pt-BR.js"),exports["pt-PT"]=require("./pt-PT.js"),exports["ru-RU"]=require("./ru-RU.js"),exports["ru-UA"]=require("./ru-UA.js"),exports["sk-SK"]=require("./sk-SK.js"),exports["sv-SE"]=require("./sv-SE.js"),exports["th-TH"]=require("./th-TH.js"),exports["tr-TR"]=require("./tr-TR.js"),exports["uk-UA"]=require("./uk-UA.js"),exports["zh-CN"]=require("./zh-CN.js"),exports["zh-TW"]=require("./zh-TW.js"); | ||
exports["cs-CZ"]=require("./cs-CZ.js"),exports["da-DK"]=require("./da-DK.js"),exports["de-CH"]=require("./de-CH.js"),exports["de-DE"]=require("./de-DE.js"),exports["en-AU"]=require("./en-AU.js"),exports["en-GB"]=require("./en-GB.js"),exports["en-NZ"]=require("./en-NZ.js"),exports["en-ZA"]=require("./en-ZA.js"),exports["es-AR"]=require("./es-AR.js"),exports["es-ES"]=require("./es-ES.js"),exports["et-EE"]=require("./et-EE.js"),exports["fa-IR"]=require("./fa-IR.js"),exports["fi-FI"]=require("./fi-FI.js"),exports["fil-PH"]=require("./fil-PH.js"),exports["fr-CA"]=require("./fr-CA.js"),exports["fr-CH"]=require("./fr-CH.js"),exports["fr-FR"]=require("./fr-FR.js"),exports["he-IL"]=require("./he-IL.js"),exports["hu-HU"]=require("./hu-HU.js"),exports["it-IT"]=require("./it-IT.js"),exports["ja-JP"]=require("./ja-JP.js"),exports["ko-KR"]=require("./ko-KR.js"),exports["lv-LV"]=require("./lv-LV.js"),exports["nb-NO"]=require("./nb-NO.js"),exports["nl-BE"]=require("./nl-BE.js"),exports["nl-NL"]=require("./nl-NL.js"),exports["pl-PL"]=require("./pl-PL.js"),exports["pt-BR"]=require("./pt-BR.js"),exports["pt-PT"]=require("./pt-PT.js"),exports["ro-RO"]=require("./ro-RO.js"),exports["ru-RU"]=require("./ru-RU.js"),exports["ru-UA"]=require("./ru-UA.js"),exports["sk-SK"]=require("./sk-SK.js"),exports["sv-SE"]=require("./sv-SE.js"),exports["th-TH"]=require("./th-TH.js"),exports["tr-TR"]=require("./tr-TR.js"),exports["uk-UA"]=require("./uk-UA.js"),exports["zh-CN"]=require("./zh-CN.js"),exports["zh-TW"]=require("./zh-TW.js"); |
@@ -5,5 +5,5 @@ /*! | ||
* locale : Slovakia | ||
* author : Ahmed Al Hafoudh : http://www.freevision.sk | ||
* author : Jan Pesa : https://github.com/smajl (based on work from Ahmed Al Hafoudh : http://www.freevision.sk) | ||
*/ | ||
(function(){"use strict";var a={langLocaleCode:"sk-SK",cultureCode:"sk-SK",delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€",position:"postfix"},defaults:{currencyFormat:",4 a"},formats:{fourDigits:"4 a",fullWithTwoDecimals:",0.00 $",fullWithTwoDecimalsNoCurrency:",0.00",fullWithNoDecimals:",0 $"}}; | ||
(function(){"use strict";var a={langLocaleCode:"sk-SK",cultureCode:"sk-SK",delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"mld.",trillion:"bil."},ordinal:function(){return"."},currency:{symbol:"€",position:"postfix",spaceSeparated:!0},defaults:{currencyFormat:",4 a"},formats:{fourDigits:"4 a",fullWithTwoDecimals:",0.00 $",fullWithTwoDecimalsNoCurrency:",0.00",fullWithNoDecimals:",0 $"}}; | ||
// CommonJS | ||
@@ -10,0 +10,0 @@ "undefined"!=typeof module&&module.exports&&(module.exports=a), |
/*! | ||
* numbro.js | ||
* version : 1.9.3 | ||
* version : 1.10.0 | ||
* author : Företagsplatsen AB | ||
@@ -17,3 +17,3 @@ * license : MIT | ||
var numbro, | ||
VERSION = '1.9.3', | ||
VERSION = '1.10.0', | ||
binarySuffixes = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'], | ||
@@ -81,2 +81,7 @@ decimalSuffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], | ||
function numberLength(number) { | ||
if (number === 0) { return 1; } | ||
return Math.floor(Math.log(Math.abs(number)) / Math.LN10) + 1; | ||
} | ||
function zeroes(count) { | ||
@@ -477,3 +482,2 @@ var i, ret = ''; | ||
indexOpenP, | ||
size, | ||
indexMinus, | ||
@@ -504,3 +508,3 @@ paren = '', | ||
if (format.indexOf('}') === format.length - 1) { | ||
if (format.indexOf('}') === format.length - 1 && format.length) { | ||
var start = format.indexOf('{'); | ||
@@ -558,4 +562,3 @@ if (start === -1) { | ||
totalLength = Math.floor(Math.log(abs) / Math.LN10) + 1; | ||
totalLength = numberLength(value); | ||
minimumPrecision = totalLength % 3; | ||
@@ -565,20 +568,7 @@ minimumPrecision = minimumPrecision === 0 ? 3 : minimumPrecision; | ||
if (intPrecision && abs !== 0) { | ||
length = Math.floor(Math.log(abs) / Math.LN10) + 1 - intPrecision; | ||
pow = 3 * ~~((Math.min(intPrecision, totalLength) - minimumPrecision) / 3); | ||
abs = abs / Math.pow(10, pow); | ||
if (format.indexOf('.') === -1 && intPrecision > 3) { | ||
format += '[.]'; | ||
size = length === 0 ? 0 : 3 * ~~(length / 3) - length; | ||
size = size < 0 ? size + 3 : size; | ||
format += zeroes(size); | ||
} | ||
} | ||
if (Math.floor(Math.log(Math.abs(value)) / Math.LN10) + 1 !== intPrecision) { | ||
if (totalLength !== intPrecision) { | ||
if (abs >= Math.pow(10, 12) && !abbrForce || abbrT) { | ||
@@ -602,2 +592,8 @@ // trillion | ||
} | ||
length = numberLength(value); | ||
if (intPrecision && length < intPrecision && format.indexOf('.') === -1) { | ||
format += '[.]'; | ||
format += zeroes(intPrecision - length); | ||
} | ||
} | ||
@@ -648,3 +644,2 @@ | ||
w = value.toString().split('.')[0]; | ||
precision = format.split('.')[1]; | ||
@@ -654,4 +649,10 @@ thousands = format.indexOf(','); | ||
if (precision) { | ||
var dSplit = []; | ||
if (precision.indexOf('*') !== -1) { | ||
d = toFixed(value, value.toString().split('.')[1].length, roundingFunction); | ||
d = value.toString(); | ||
dSplit = d.split('.'); | ||
if (dSplit.length > 1) { | ||
d = toFixed(value, dSplit[1].length, roundingFunction); | ||
} | ||
} else { | ||
@@ -668,7 +669,8 @@ if (precision.indexOf('[') > -1) { | ||
w = d.split('.')[0]; | ||
dSplit = d.split('.'); | ||
w = dSplit[0]; | ||
if (d.split('.')[1].length) { | ||
if (dSplit.length > 1 && dSplit[1].length) { | ||
var p = sep ? abbr + sep : cultures[currentCulture].delimiters.decimal; | ||
d = p + d.split('.')[1]; | ||
d = p + dSplit[1]; | ||
} else { | ||
@@ -732,4 +734,6 @@ d = ''; | ||
input = 0; | ||
} else if (!Number(input)) { | ||
} else if (typeof input === 'string' || typeof input === 'number') { | ||
input = numbro.fn.unformat(input); | ||
} else { | ||
throw new Error('Invalid input'); | ||
} | ||
@@ -1063,3 +1067,3 @@ | ||
( | ||
process.title.indexOf('node') === 0 || | ||
process.title.indexOf('node') !== -1 || | ||
process.title.indexOf('meteor-tool') > 0 || | ||
@@ -1066,0 +1070,0 @@ process.title === 'grunt' || |
/*! | ||
* numbro.js | ||
* version : 1.9.3 | ||
* version : 1.10.0 | ||
* author : Företagsplatsen AB | ||
@@ -12,7 +12,7 @@ * license : MIT | ||
// Numbro prototype object | ||
function a(a){this._value=a}function b(a){var b,c="";for(b=0;a>b;b++)c+="0";return c}/** | ||
function a(a){this._value=a}function b(a){return 0===a?1:Math.floor(Math.log(Math.abs(a))/Math.LN10)+1}function c(a){var b,c="";for(b=0;a>b;b++)c+="0";return c}/** | ||
* Implementation of toFixed() for numbers with exponents | ||
* This function may return negative representations for zero values e.g. "-0.0" | ||
*/ | ||
function c(a,c){var d,e,f,g,h,i,j,k; | ||
function d(a,b){var d,e,f,g,h,i,j,k; | ||
// exponent is positive - add zeros after the numbers | ||
@@ -23,3 +23,3 @@ // exponent is negative | ||
// only add percision 0's if the exponent is positive | ||
return k=a.toString(),d=k.split("e")[0],g=k.split("e")[1],e=d.split(".")[0],f=d.split(".")[1]||"",+g>0?k=e+f+b(g-f.length):(h=0>+e?"-0":"0",c>0&&(h+="."),j=b(-1*g-1),i=(j+Math.abs(e)+f).substr(0,c),k=h+i),+g>0&&c>0&&(k+="."+b(c)),k}/** | ||
return k=a.toString(),d=k.split("e")[0],g=k.split("e")[1],e=d.split(".")[0],f=d.split(".")[1]||"",+g>0?k=e+f+c(g-f.length):(h=0>+e?"-0":"0",b>0&&(h+="."),j=c(-1*g-1),i=(j+Math.abs(e)+f).substr(0,b),k=h+i),+g>0&&b>0&&(k+="."+c(b)),k}/** | ||
* Implementation of toFixed() that treats floats more like decimals | ||
@@ -32,19 +32,19 @@ * | ||
*/ | ||
function d(a,b,d,e){var f,g,h=Math.pow(10,b); | ||
function e(a,b,c,e){var f,g,h=Math.pow(10,b); | ||
// toFixed returns scientific notation for numbers above 1e21 and below 1e-7 | ||
// remove the leading negative sign if it exists and should not be present (e.g. -0.00) | ||
// Multiply up by precision, round accurately, then divide and use native toFixed(): | ||
return a.toString().indexOf("e")>-1?(g=c(a,b),"-"===g.charAt(0)&&+g>=0&&(g=g.substr(1))):g=(d(a+"e+"+b)/h).toFixed(b),e&&(f=new RegExp("0{1,"+e+"}$"),g=g.replace(f,"")),g}/************************************ | ||
return a.toString().indexOf("e")>-1?(g=d(a,b),"-"===g.charAt(0)&&+g>=0&&(g=g.substr(1))):g=(c(a+"e+"+b)/h).toFixed(b),e&&(f=new RegExp("0{1,"+e+"}$"),g=g.replace(f,"")),g}/************************************ | ||
Formatting | ||
************************************/ | ||
// determine what type of formatting we need to do | ||
function e(a,b,c){var d,e=b.replace(/\{[^\{\}]*\}/g,""); | ||
function f(a,b,c){var d,e=b.replace(/\{[^\{\}]*\}/g,""); | ||
// return string | ||
// figure out what kind of format we are dealing with | ||
// currency!!!!! | ||
return d=e.indexOf("$")>-1?g(a,y[A].currency.symbol,b,c):e.indexOf("%")>-1?i(a,b,c):e.indexOf(":")>-1?j(a,b):m(a._value,b,c)} | ||
return d=e.indexOf("$")>-1?h(a,z[B].currency.symbol,b,c):e.indexOf("%")>-1?j(a,b,c):e.indexOf(":")>-1?k(a,b):n(a._value,b,c)} | ||
// revert to number | ||
function f(a,b){var c,d,e,f,g,h=b,i=!1;if(b.indexOf(":")>-1)a._value=k(b);else if(b===B)a._value=0;else{ | ||
function g(a,b){var c,d,e,f,g,h=b,i=!1;if(b.indexOf(":")>-1)a._value=l(b);else if(b===C)a._value=0;else{ | ||
// see if bytes are there so that we can multiply to the correct number | ||
for("."!==y[A].delimiters.decimal&&(b=b.replace(/\./g,"").replace(y[A].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+y[A].abbreviations.thousand+"(?:\\)|(\\"+y[A].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+y[A].abbreviations.million+"(?:\\)|(\\"+y[A].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+y[A].abbreviations.billion+"(?:\\)|(\\"+y[A].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+y[A].abbreviations.trillion+"(?:\\)|(\\"+y[A].currency.symbol+")?(?:\\))?)?$"),g=1;g<u.length&&!i;++g)b.indexOf(u[g])>-1?i=Math.pow(1024,g):b.indexOf(v[g])>-1&&(i=Math.pow(1e3,g));var j=b.replace(/[^0-9\.]+/g,"");""===j? | ||
for("."!==z[B].delimiters.decimal&&(b=b.replace(/\./g,"").replace(z[B].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+z[B].abbreviations.thousand+"(?:\\)|(\\"+z[B].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+z[B].abbreviations.million+"(?:\\)|(\\"+z[B].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+z[B].abbreviations.billion+"(?:\\)|(\\"+z[B].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+z[B].abbreviations.trillion+"(?:\\)|(\\"+z[B].currency.symbol+")?(?:\\))?)?$"),g=1;g<v.length&&!i;++g)b.indexOf(v[g])>-1?i=Math.pow(1024,g):b.indexOf(w[g])>-1&&(i=Math.pow(1e3,g));var j=b.replace(/[^0-9\.]+/g,"");""===j? | ||
// An empty string is not a number. | ||
@@ -55,11 +55,11 @@ a._value=NaN:( | ||
// round if we are talking about bytes | ||
a._value=i?Math.ceil(a._value):a._value)}return a._value}function g(a,b,c,d){var e,f,g=c,h=g.indexOf("$"),i=g.indexOf("("),j=g.indexOf("+"),k=g.indexOf("-"),l="",n="";if(-1===g.indexOf("$")? | ||
a._value=i?Math.ceil(a._value):a._value)}return a._value}function h(a,b,c,d){var e,f,g=c,h=g.indexOf("$"),i=g.indexOf("("),j=g.indexOf("+"),k=g.indexOf("-"),l="",m="";if(-1===g.indexOf("$")? | ||
// Use defaults instead of the format provided | ||
"infix"===y[A].currency.position?(n=b,y[A].currency.spaceSeparated&&(n=" "+n+" ")):y[A].currency.spaceSeparated&&(l=" "):g.indexOf(" $")>-1?(l=" ",g=g.replace(" $","")):g.indexOf("$ ")>-1?(l=" ",g=g.replace("$ ","")):g=g.replace("$",""),f=m(a._value,g,d,n),-1===c.indexOf("$")) | ||
"infix"===z[B].currency.position?(m=b,z[B].currency.spaceSeparated&&(m=" "+m+" ")):z[B].currency.spaceSeparated&&(l=" "):g.indexOf(" $")>-1?(l=" ",g=g.replace(" $","")):g.indexOf("$ ")>-1?(l=" ",g=g.replace("$ ","")):g=g.replace("$",""),f=n(a._value,g,d,m),-1===c.indexOf("$")) | ||
// Use defaults instead of the format provided | ||
switch(y[A].currency.position){case"postfix":f.indexOf(")")>-1?(f=f.split(""),f.splice(-1,0,l+b),f=f.join("")):f=f+l+b;break;case"infix":break;case"prefix":f.indexOf("(")>-1||f.indexOf("-")>-1?(f=f.split(""),e=Math.max(i,k)+1,f.splice(e,0,b+l),f=f.join("")):f=b+l+f;break;default:throw Error('Currency position should be among ["prefix", "infix", "postfix"]')}else | ||
switch(z[B].currency.position){case"postfix":f.indexOf(")")>-1?(f=f.split(""),f.splice(-1,0,l+b),f=f.join("")):f=f+l+b;break;case"infix":break;case"prefix":f.indexOf("(")>-1||f.indexOf("-")>-1?(f=f.split(""),e=Math.max(i,k)+1,f.splice(e,0,b+l),f=f.join("")):f=b+l+f;break;default:throw Error('Currency position should be among ["prefix", "infix", "postfix"]')}else | ||
// position the symbol | ||
1>=h?f.indexOf("(")>-1||f.indexOf("+")>-1||f.indexOf("-")>-1?(f=f.split(""),e=1,(i>h||j>h||k>h)&&(e=0),f.splice(e,0,b+l),f=f.join("")):f=b+l+f:f.indexOf(")")>-1?(f=f.split(""),f.splice(-1,0,l+b),f=f.join("")):f=f+l+b;return f}function h(a,b,c,d){return g(a,b,c,d)}function i(a,b,c){var d,e="",f=100*a._value; | ||
1>=h?f.indexOf("(")>-1||f.indexOf("+")>-1||f.indexOf("-")>-1?(f=f.split(""),e=1,(i>h||j>h||k>h)&&(e=0),f.splice(e,0,b+l),f=f.join("")):f=b+l+f:f.indexOf(")")>-1?(f=f.split(""),f.splice(-1,0,l+b),f=f.join("")):f=f+l+b;return f}function i(a,b,c,d){return h(a,b,c,d)}function j(a,b,c){var d,e="",f=100*a._value; | ||
// check for space before % | ||
return b.indexOf(" %")>-1?(e=" ",b=b.replace(" %","")):b=b.replace("%",""),d=m(f,b,c),d.indexOf(")")>-1?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function j(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 k(a){var b=a.split(":"),c=0; | ||
return b.indexOf(" %")>-1?(e=" ",b=b.replace(" %","")):b=b.replace("%",""),d=n(f,b,c),d.indexOf(")")>-1?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function k(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 l(a){var b=a.split(":"),c=0; | ||
// turn hours and minutes into seconds and add them all up | ||
@@ -71,5 +71,5 @@ // hours | ||
// seconds | ||
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,c){var d,e,f,g=b[0],h=Math.abs(a);if(h>=c){for(d=1;d<b.length;++d)if(e=Math.pow(c,d),f=Math.pow(c,d+1),h>=e&&f>h){g=b[d],a/=e;break} | ||
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,b,c){var d,e,f,g=b[0],h=Math.abs(a);if(h>=c){for(d=1;d<b.length;++d)if(e=Math.pow(c,d),f=Math.pow(c,d+1),h>=e&&f>h){g=b[d],a/=e;break} | ||
// values greater than or equal to [scale] YB never set the suffix | ||
g===b[0]&&(a/=Math.pow(c,b.length-1),g=b[b.length-1])}return{value:a,suffix:g}}function m(a,c,e,f){var g,h,i,j,k,m,n,o,p,q,r,s,t,u,v,w,z,C=!1,D=!1,E=!1,F="",G=!1,// force abbreviation to thousands | ||
g===b[0]&&(a/=Math.pow(c,b.length-1),g=b[b.length-1])}return{value:a,suffix:g}}function n(a,d,f,g){var h,i,j,k,l,n,o,p,q,r,s,t,u,v,w,x,A=!1,D=!1,E=!1,F="",G=!1,// force abbreviation to thousands | ||
H=!1,// force abbreviation to millions | ||
@@ -81,3 +81,3 @@ I=!1,// force abbreviation to billions | ||
// check if number is zero and a custom zero format has been set | ||
if(0===a&&null!==B)return B;if(!isFinite(a))return""+a;if(0===c.indexOf("{")){var S=c.indexOf("}");if(-1===S)throw Error('Format should also contain a "}"');q=c.slice(1,S),c=c.slice(S+1)}else q="";if(c.indexOf("}")===c.length-1){var T=c.indexOf("{");if(-1===T)throw Error('Format should also contain a "{"');r=c.slice(T+1,-1),c=c.slice(0,T+1)}else r=""; | ||
if(0===a&&null!==C)return C;if(!isFinite(a))return""+a;if(0===d.indexOf("{")){var S=d.indexOf("}");if(-1===S)throw Error('Format should also contain a "}"');r=d.slice(1,S),d=d.slice(S+1)}else r="";if(d.indexOf("}")===d.length-1&&d.length){var T=d.indexOf("{");if(-1===T)throw Error('Format should also contain a "{"');s=d.slice(T+1,-1),d=d.slice(0,T+1)}else s=""; | ||
// check for min length | ||
@@ -87,16 +87,16 @@ var U; | ||
// binary-decimal bytes (1024 MB), binary bytes (1024 MiB), or decimal bytes (1000 MB) | ||
for(U=-1===c.indexOf(".")?c.match(/([0-9]+).*/):c.match(/([0-9]+)\..*/),w=null===U?-1:U[1].length,-1!==c.indexOf("-")&&(P=!0),c.indexOf("(")>-1?(C=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(D=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(o=c.split(".")[0].match(/[0-9]+/g)||["0"],o=parseInt(o[0],10),G=c.indexOf("aK")>=0,H=c.indexOf("aM")>=0,I=c.indexOf("aB")>=0,J=c.indexOf("aT")>=0,K=G||H||I||J,c.indexOf(" a")>-1?(F=" ",c=c.replace(" a","")):c=c.replace("a",""),i=Math.floor(Math.log(N)/Math.LN10)+1,k=i%3,k=0===k?3:k,o&&0!==N&&(j=Math.floor(Math.log(N)/Math.LN10)+1-o,m=3*~~((Math.min(o,i)-k)/3),N/=Math.pow(10,m),-1===c.indexOf(".")&&o>3&&(c+="[.]",u=0===j?0:3*~~(j/3)-j,u=0>u?u+3:u,c+=b(u))),Math.floor(Math.log(Math.abs(a))/Math.LN10)+1!==o&&(N>=Math.pow(10,12)&&!K||J?(F+=y[A].abbreviations.trillion,a/=Math.pow(10,12)):N<Math.pow(10,12)&&N>=Math.pow(10,9)&&!K||I?(F+=y[A].abbreviations.billion,a/=Math.pow(10,9)):N<Math.pow(10,9)&&N>=Math.pow(10,6)&&!K||H?(F+=y[A].abbreviations.million,a/=Math.pow(10,6)):(N<Math.pow(10,6)&&N>=Math.pow(10,3)&&!K||G)&&(F+=y[A].abbreviations.thousand,a/=Math.pow(10,3)))),z=0;z<x.length;++z)if(g=x[z],c.indexOf(g.marker)>-1){ | ||
for(U=-1===d.indexOf(".")?d.match(/([0-9]+).*/):d.match(/([0-9]+)\..*/),w=null===U?-1:U[1].length,-1!==d.indexOf("-")&&(P=!0),d.indexOf("(")>-1?(A=!0,d=d.slice(1,-1)):d.indexOf("+")>-1&&(D=!0,d=d.replace(/\+/g,"")),d.indexOf("a")>-1&&(p=d.split(".")[0].match(/[0-9]+/g)||["0"],p=parseInt(p[0],10),G=d.indexOf("aK")>=0,H=d.indexOf("aM")>=0,I=d.indexOf("aB")>=0,J=d.indexOf("aT")>=0,K=G||H||I||J,d.indexOf(" a")>-1?(F=" ",d=d.replace(" a","")):d=d.replace("a",""),j=b(a),l=j%3,l=0===l?3:l,p&&0!==N&&(n=3*~~((Math.min(p,j)-l)/3),N/=Math.pow(10,n)),j!==p&&(N>=Math.pow(10,12)&&!K||J?(F+=z[B].abbreviations.trillion,a/=Math.pow(10,12)):N<Math.pow(10,12)&&N>=Math.pow(10,9)&&!K||I?(F+=z[B].abbreviations.billion,a/=Math.pow(10,9)):N<Math.pow(10,9)&&N>=Math.pow(10,6)&&!K||H?(F+=z[B].abbreviations.million,a/=Math.pow(10,6)):(N<Math.pow(10,6)&&N>=Math.pow(10,3)&&!K||G)&&(F+=z[B].abbreviations.thousand,a/=Math.pow(10,3))),k=b(a),p&&p>k&&-1===d.indexOf(".")&&(d+="[.]",d+=c(p-k))),x=0;x<y.length;++x)if(h=y[x],d.indexOf(h.marker)>-1){ | ||
// check for space before | ||
c.indexOf(" "+g.marker)>-1&&(L=" "), | ||
d.indexOf(" "+h.marker)>-1&&(L=" "), | ||
// remove the marker (with the space if it had one) | ||
c=c.replace(L+g.marker,""),h=l(a,g.suffixes,g.scale),a=h.value,L+=h.suffix;break}if( | ||
d=d.replace(L+h.marker,""),i=m(a,h.suffixes,h.scale),a=i.value,L+=i.suffix;break}if( | ||
// see if ordinal is wanted | ||
c.indexOf("o")>-1&&( | ||
d.indexOf("o")>-1&&( | ||
// check for space before | ||
c.indexOf(" o")>-1?(M=" ",c=c.replace(" o","")):c=c.replace("o",""),y[A].ordinal&&(M+=y[A].ordinal(a))),c.indexOf("[.]")>-1&&(E=!0,c=c.replace("[.]",".")),n=a.toString().split(".")[0],p=c.split(".")[1],s=c.indexOf(","),p){if(-1!==p.indexOf("*")?O=d(a,a.toString().split(".")[1].length,e):p.indexOf("[")>-1?(p=p.replace("]",""),p=p.split("["),O=d(a,p[0].length+p[1].length,e,p[1].length)):O=d(a,p.length,e),n=O.split(".")[0],O.split(".")[1].length){var V=f?F+f:y[A].delimiters.decimal;O=V+O.split(".")[1]}else O="";E&&0===Number(O.slice(1))&&(O="")}else n=d(a,0,e); | ||
d.indexOf(" o")>-1?(M=" ",d=d.replace(" o","")):d=d.replace("o",""),z[B].ordinal&&(M+=z[B].ordinal(a))),d.indexOf("[.]")>-1&&(E=!0,d=d.replace("[.]",".")),q=d.split(".")[1],t=d.indexOf(","),q){var V=[];if(-1!==q.indexOf("*")?(O=a.toString(),V=O.split("."),V.length>1&&(O=e(a,V[1].length,f))):q.indexOf("[")>-1?(q=q.replace("]",""),q=q.split("["),O=e(a,q[0].length+q[1].length,f,q[1].length)):O=e(a,q.length,f),V=O.split("."),o=V[0],V.length>1&&V[1].length){var W=g?F+g:z[B].delimiters.decimal;O=W+V[1]}else O="";E&&0===Number(O.slice(1))&&(O="")}else o=e(a,0,f); | ||
// format number | ||
return n.indexOf("-")>-1&&(n=n.slice(1),Q=!0),n.length<w&&(n=b(w-n.length)+n),s>-1&&(n=n.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+y[A].delimiters.thousands)),0===c.indexOf(".")&&(n=""),t=c.indexOf("("),v=c.indexOf("-"),R=v>t?(C&&Q?"(":"")+(P&&Q||!C&&Q?"-":""):(P&&Q||!C&&Q?"-":"")+(C&&Q?"(":""),q+R+(!Q&&D&&0!==a?"+":"")+n+O+(M?M:"")+(F&&!f?F:"")+(L?L:"")+(C&&Q?")":"")+r}/************************************ | ||
return o.indexOf("-")>-1&&(o=o.slice(1),Q=!0),o.length<w&&(o=c(w-o.length)+o),t>-1&&(o=o.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+z[B].delimiters.thousands)),0===d.indexOf(".")&&(o=""),u=d.indexOf("("),v=d.indexOf("-"),R=v>u?(A&&Q?"(":"")+(P&&Q||!A&&Q?"-":""):(P&&Q||!A&&Q?"-":"")+(A&&Q?"(":""),r+R+(!Q&&D&&0!==a?"+":"")+o+O+(M?M:"")+(F&&!g?F:"")+(L?L:"")+(A&&Q?")":"")+s}/************************************ | ||
Helpers | ||
************************************/ | ||
function n(a,b){y[a]=b}function o(a){A=a;var b=y[a].defaults;b&&b.format&&s.defaultFormat(b.format),b&&b.currencyFormat&&s.defaultCurrencyFormat(b.currencyFormat)}function p(){return"undefined"!=typeof process&&void 0===process.browser&&process.title&&(0===process.title.indexOf("node")||process.title.indexOf("meteor-tool")>0||"grunt"===process.title||"gulp"===process.title)&&"undefined"!=typeof require}/** | ||
function o(a,b){z[a]=b}function p(a){B=a;var b=z[a].defaults;b&&b.format&&t.defaultFormat(b.format),b&&b.currencyFormat&&t.defaultCurrencyFormat(b.currencyFormat)}function q(){return"undefined"!=typeof process&&void 0===process.browser&&process.title&&(-1!==process.title.indexOf("node")||process.title.indexOf("meteor-tool")>0||"grunt"===process.title||"gulp"===process.title)&&"undefined"!=typeof require}/** | ||
* Computes the multiplier necessary to make x >= 1, | ||
@@ -106,3 +106,3 @@ * effectively eliminating miscalculations caused by | ||
*/ | ||
function q(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}/** | ||
function r(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}/** | ||
* Given a variable number of arguments, returns the maximum | ||
@@ -112,15 +112,15 @@ * multiplier that must be used to normalize an operation involving | ||
*/ | ||
function r(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=q(a),d=q(b);return c>d?c:d},-(1/0))}/************************************ | ||
function s(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=r(a),d=r(b);return c>d?c:d},-(1/0))}/************************************ | ||
Constants | ||
************************************/ | ||
var s,t="1.9.3",u=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],v=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],w={general:{scale:1024,suffixes:v,marker:"bd"},binary:{scale:1024,suffixes:u,marker:"b"},decimal:{scale:1e3,suffixes:v,marker:"d"}}, | ||
var t,u="1.10.0",v=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],w=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],x={general:{scale:1024,suffixes:w,marker:"bd"},binary:{scale:1024,suffixes:v,marker:"b"},decimal:{scale:1e3,suffixes:w,marker:"d"}}, | ||
// general must be before the others because it reuses their characters! | ||
x=[w.general,w.binary,w.decimal], | ||
y=[x.general,x.binary,x.decimal], | ||
// internal storage for culture config files | ||
y={}, | ||
z={}, | ||
// Todo: Remove in 2.0.0 | ||
z=y,A="en-US",B=null,C="0,0",D="0$", | ||
A=z,B="en-US",C=null,D="0,0",E="0$", | ||
// check for nodeJS | ||
E="undefined"!=typeof module&&module.exports, | ||
F="undefined"!=typeof module&&module.exports, | ||
// default culture | ||
F={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===~~(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th"},currency:{symbol:"$",position:"prefix"},defaults:{currencyFormat:",0000 a"},formats:{fourDigits:"0000 a",fullWithTwoDecimals:"$ ,0.00",fullWithTwoDecimalsNoCurrency:",0.00"}};s=function(b){return s.isNumbro(b)?b=b.value():0===b||"undefined"==typeof b?b=0:Number(b)||(b=s.fn.unformat(b)),new a(Number(b))},s.version=t,s.isNumbro=function(b){return b instanceof a},s.setLanguage=function(a,b){console.warn("`setLanguage` is deprecated since version 1.6.0. Use `setCulture` instead");var c=a,d=a.split("-")[0],e=null;z[c]||(Object.keys(z).forEach(function(a){e||a.split("-")[0]!==d||(e=a)}),c=e||b||"en-US"),o(c)},s.setCulture=function(a,b){var c=a,d=a.split("-")[1],e=null;y[c]||(d&&Object.keys(y).forEach(function(a){e||a.split("-")[1]!==d||(e=a)}),c=e||b||"en-US"),o(c)},s.language=function(a,b){if(console.warn("`language` is deprecated since version 1.6.0. Use `culture` instead"),!a)return A;if(a&&!b){if(!z[a])throw new Error("Unknown language : "+a);o(a)}return!b&&z[a]||n(a,b),s},s.culture=function(a,b){if(!a)return A;if(a&&!b){if(!y[a])throw new Error("Unknown culture : "+a);o(a)}return!b&&y[a]||n(a,b),s},s.languageData=function(a){if(console.warn("`languageData` is deprecated since version 1.6.0. Use `cultureData` instead"),!a)return z[A];if(!z[a])throw new Error("Unknown language : "+a);return z[a]},s.cultureData=function(a){if(!a)return y[A];if(!y[a])throw new Error("Unknown culture : "+a);return y[a]},s.culture("en-US",F),s.languages=function(){return console.warn("`languages` is deprecated since version 1.6.0. Use `cultures` instead"),z},s.cultures=function(){return y},s.zeroFormat=function(a){B="string"==typeof a?a:null},s.defaultFormat=function(a){C="string"==typeof a?a:"0.0"},s.defaultCurrencyFormat=function(a){D="string"==typeof a?a:"0$"},s.validate=function(a,b){var c,d,e,f,g,h,i,j;if("string"!=typeof a&&(a+="",console.warn&&console.warn("Numbro.js: Value is not string. It has been co-erced to: ",a)),a=a.trim(),a=a.replace(/^[+-]?/,""),a.match(/^\d+$/))return!0;if(""===a)return!1;try{i=s.cultureData(b)}catch(k){i=s.cultureData(s.culture())}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):""===f[0]?!f[0].match(h)&&!!f[1].match(/^\d+$/):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+$/))))},s.loadLanguagesInNode=function(){console.warn("`loadLanguagesInNode` is deprecated since version 1.6.0. Use `loadCulturesInNode` instead"),s.loadCulturesInNode()},s.loadCulturesInNode=function(){var a=require("./languages");for(var b in a)b&&s.culture(b,a[b])},"function"!=typeof Array.prototype.reduce&&(Array.prototype.reduce=function(a,b){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(1<arguments.length&&(d=b,f=!0),c=0;e>c;++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}),s.fn=a.prototype={clone:function(){return s(this)},format:function(a,b){return e(this,a?a:C,void 0!==b?b:Math.round)},formatCurrency:function(a,b){return g(this,y[A].currency.symbol,a?a:D,void 0!==b?b:Math.round)},formatForeignCurrency:function(a,b,c){return h(this,a,b?b:D,void 0!==c?c:Math.round)},unformat:function(a){if("number"==typeof a)return a;if("string"==typeof a){var b=f(this,a);return isNaN(b)?void 0:b}},binaryByteUnits:function(){return l(this._value,w.binary.suffixes,w.binary.scale).suffix},byteUnits:function(){return l(this._value,w.general.suffixes,w.general.scale).suffix},decimalByteUnits:function(){return l(this._value,w.decimal.suffixes,w.decimal.scale).suffix},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=r.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=r.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=r(a,b),d=a*c;return d*=b*c,d/=c*c}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b){var c=r(a,b);return a*c/(b*c)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(s(this._value).subtract(a).value())}},p()&&s.loadCulturesInNode(),E?module.exports=s:("undefined"==typeof ender&&(this.numbro=s),"function"==typeof define&&define.amd&&define([],function(){return s}))}).call("undefined"==typeof window?this:window); | ||
G={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===~~(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th"},currency:{symbol:"$",position:"prefix"},defaults:{currencyFormat:",0000 a"},formats:{fourDigits:"0000 a",fullWithTwoDecimals:"$ ,0.00",fullWithTwoDecimalsNoCurrency:",0.00"}};t=function(b){if(t.isNumbro(b))b=b.value();else if(0===b||"undefined"==typeof b)b=0;else{if("string"!=typeof b&&"number"!=typeof b)throw new Error("Invalid input");b=t.fn.unformat(b)}return new a(Number(b))},t.version=u,t.isNumbro=function(b){return b instanceof a},t.setLanguage=function(a,b){console.warn("`setLanguage` is deprecated since version 1.6.0. Use `setCulture` instead");var c=a,d=a.split("-")[0],e=null;A[c]||(Object.keys(A).forEach(function(a){e||a.split("-")[0]!==d||(e=a)}),c=e||b||"en-US"),p(c)},t.setCulture=function(a,b){var c=a,d=a.split("-")[1],e=null;z[c]||(d&&Object.keys(z).forEach(function(a){e||a.split("-")[1]!==d||(e=a)}),c=e||b||"en-US"),p(c)},t.language=function(a,b){if(console.warn("`language` is deprecated since version 1.6.0. Use `culture` instead"),!a)return B;if(a&&!b){if(!A[a])throw new Error("Unknown language : "+a);p(a)}return!b&&A[a]||o(a,b),t},t.culture=function(a,b){if(!a)return B;if(a&&!b){if(!z[a])throw new Error("Unknown culture : "+a);p(a)}return!b&&z[a]||o(a,b),t},t.languageData=function(a){if(console.warn("`languageData` is deprecated since version 1.6.0. Use `cultureData` instead"),!a)return A[B];if(!A[a])throw new Error("Unknown language : "+a);return A[a]},t.cultureData=function(a){if(!a)return z[B];if(!z[a])throw new Error("Unknown culture : "+a);return z[a]},t.culture("en-US",G),t.languages=function(){return console.warn("`languages` is deprecated since version 1.6.0. Use `cultures` instead"),A},t.cultures=function(){return z},t.zeroFormat=function(a){C="string"==typeof a?a:null},t.defaultFormat=function(a){D="string"==typeof a?a:"0.0"},t.defaultCurrencyFormat=function(a){E="string"==typeof a?a:"0$"},t.validate=function(a,b){var c,d,e,f,g,h,i,j;if("string"!=typeof a&&(a+="",console.warn&&console.warn("Numbro.js: Value is not string. It has been co-erced to: ",a)),a=a.trim(),a=a.replace(/^[+-]?/,""),a.match(/^\d+$/))return!0;if(""===a)return!1;try{i=t.cultureData(b)}catch(k){i=t.cultureData(t.culture())}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):""===f[0]?!f[0].match(h)&&!!f[1].match(/^\d+$/):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+$/))))},t.loadLanguagesInNode=function(){console.warn("`loadLanguagesInNode` is deprecated since version 1.6.0. Use `loadCulturesInNode` instead"),t.loadCulturesInNode()},t.loadCulturesInNode=function(){var a=require("./languages");for(var b in a)b&&t.culture(b,a[b])},"function"!=typeof Array.prototype.reduce&&(Array.prototype.reduce=function(a,b){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(1<arguments.length&&(d=b,f=!0),c=0;e>c;++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}),t.fn=a.prototype={clone:function(){return t(this)},format:function(a,b){return f(this,a?a:D,void 0!==b?b:Math.round)},formatCurrency:function(a,b){return h(this,z[B].currency.symbol,a?a:E,void 0!==b?b:Math.round)},formatForeignCurrency:function(a,b,c){return i(this,a,b?b:E,void 0!==c?c:Math.round)},unformat:function(a){if("number"==typeof a)return a;if("string"==typeof a){var b=g(this,a);return isNaN(b)?void 0:b}},binaryByteUnits:function(){return m(this._value,x.binary.suffixes,x.binary.scale).suffix},byteUnits:function(){return m(this._value,x.general.suffixes,x.general.scale).suffix},decimalByteUnits:function(){return m(this._value,x.decimal.suffixes,x.decimal.scale).suffix},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=s.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=s.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=s(a,b),d=a*c;return d*=b*c,d/=c*c}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b){var c=s(a,b);return a*c/(b*c)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(t(this._value).subtract(a).value())}},q()&&t.loadCulturesInNode(),F?module.exports=t:("undefined"==typeof ender&&(this.numbro=t),"function"==typeof define&&define.amd&&define([],function(){return t}))}).call("undefined"==typeof window?this:window); |
@@ -5,3 +5,3 @@ /*! | ||
* locale: Czech Republic | ||
* author : Anatoli Papirovski : https://github.com/apapirovski | ||
* author : Jan Pesa : https://github.com/smajl (based on work from Anatoli Papirovski : https://github.com/apapirovski) | ||
*/ | ||
@@ -15,3 +15,3 @@ (function () { | ||
delimiters: { | ||
thousands: ' ', | ||
thousands: '\u00a0', | ||
decimal: ',' | ||
@@ -22,4 +22,4 @@ }, | ||
million: 'mil.', | ||
billion: 'b', | ||
trillion: 't' | ||
billion: 'mld.', | ||
trillion: 'bil.' | ||
}, | ||
@@ -31,3 +31,4 @@ ordinal: function () { | ||
symbol: 'Kč', | ||
position: 'postfix' | ||
position: 'postfix', | ||
spaceSeparated: true | ||
}, | ||
@@ -34,0 +35,0 @@ defaults: { |
@@ -14,3 +14,3 @@ /*! | ||
delimiters: { | ||
thousands: '\'', | ||
thousands: ' ', | ||
decimal: '.' | ||
@@ -17,0 +17,0 @@ }, |
@@ -30,2 +30,3 @@ exports['cs-CZ'] = require('./cs-CZ.js'); | ||
exports['pt-PT'] = require('./pt-PT.js'); | ||
exports['ro-RO'] = require('./ro-RO.js'); | ||
exports['ru-RU'] = require('./ru-RU.js'); | ||
@@ -32,0 +33,0 @@ exports['ru-UA'] = require('./ru-UA.js'); |
@@ -5,3 +5,3 @@ /*! | ||
* locale : Slovakia | ||
* author : Ahmed Al Hafoudh : http://www.freevision.sk | ||
* author : Jan Pesa : https://github.com/smajl (based on work from Ahmed Al Hafoudh : http://www.freevision.sk) | ||
*/ | ||
@@ -15,3 +15,3 @@ (function () { | ||
delimiters: { | ||
thousands: ' ', | ||
thousands: '\u00a0', | ||
decimal: ',' | ||
@@ -22,4 +22,4 @@ }, | ||
million: 'mil.', | ||
billion: 'b', | ||
trillion: 't' | ||
billion: 'mld.', | ||
trillion: 'bil.' | ||
}, | ||
@@ -31,3 +31,4 @@ ordinal: function () { | ||
symbol: '€', | ||
position: 'postfix' | ||
position: 'postfix', | ||
spaceSeparated: true | ||
}, | ||
@@ -34,0 +35,0 @@ defaults: { |
/*! | ||
* numbro.js | ||
* version : 1.9.3 | ||
* version : 1.10.0 | ||
* author : Företagsplatsen AB | ||
@@ -17,3 +17,3 @@ * license : MIT | ||
var numbro, | ||
VERSION = '1.9.3', | ||
VERSION = '1.10.0', | ||
binarySuffixes = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'], | ||
@@ -81,2 +81,7 @@ decimalSuffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], | ||
function numberLength(number) { | ||
if (number === 0) { return 1; } | ||
return Math.floor(Math.log(Math.abs(number)) / Math.LN10) + 1; | ||
} | ||
function zeroes(count) { | ||
@@ -477,3 +482,2 @@ var i, ret = ''; | ||
indexOpenP, | ||
size, | ||
indexMinus, | ||
@@ -504,3 +508,3 @@ paren = '', | ||
if (format.indexOf('}') === format.length - 1) { | ||
if (format.indexOf('}') === format.length - 1 && format.length) { | ||
var start = format.indexOf('{'); | ||
@@ -558,4 +562,3 @@ if (start === -1) { | ||
totalLength = Math.floor(Math.log(abs) / Math.LN10) + 1; | ||
totalLength = numberLength(value); | ||
minimumPrecision = totalLength % 3; | ||
@@ -565,20 +568,7 @@ minimumPrecision = minimumPrecision === 0 ? 3 : minimumPrecision; | ||
if (intPrecision && abs !== 0) { | ||
length = Math.floor(Math.log(abs) / Math.LN10) + 1 - intPrecision; | ||
pow = 3 * ~~((Math.min(intPrecision, totalLength) - minimumPrecision) / 3); | ||
abs = abs / Math.pow(10, pow); | ||
if (format.indexOf('.') === -1 && intPrecision > 3) { | ||
format += '[.]'; | ||
size = length === 0 ? 0 : 3 * ~~(length / 3) - length; | ||
size = size < 0 ? size + 3 : size; | ||
format += zeroes(size); | ||
} | ||
} | ||
if (Math.floor(Math.log(Math.abs(value)) / Math.LN10) + 1 !== intPrecision) { | ||
if (totalLength !== intPrecision) { | ||
if (abs >= Math.pow(10, 12) && !abbrForce || abbrT) { | ||
@@ -602,2 +592,8 @@ // trillion | ||
} | ||
length = numberLength(value); | ||
if (intPrecision && length < intPrecision && format.indexOf('.') === -1) { | ||
format += '[.]'; | ||
format += zeroes(intPrecision - length); | ||
} | ||
} | ||
@@ -648,3 +644,2 @@ | ||
w = value.toString().split('.')[0]; | ||
precision = format.split('.')[1]; | ||
@@ -654,4 +649,10 @@ thousands = format.indexOf(','); | ||
if (precision) { | ||
var dSplit = []; | ||
if (precision.indexOf('*') !== -1) { | ||
d = toFixed(value, value.toString().split('.')[1].length, roundingFunction); | ||
d = value.toString(); | ||
dSplit = d.split('.'); | ||
if (dSplit.length > 1) { | ||
d = toFixed(value, dSplit[1].length, roundingFunction); | ||
} | ||
} else { | ||
@@ -668,7 +669,8 @@ if (precision.indexOf('[') > -1) { | ||
w = d.split('.')[0]; | ||
dSplit = d.split('.'); | ||
w = dSplit[0]; | ||
if (d.split('.')[1].length) { | ||
if (dSplit.length > 1 && dSplit[1].length) { | ||
var p = sep ? abbr + sep : cultures[currentCulture].delimiters.decimal; | ||
d = p + d.split('.')[1]; | ||
d = p + dSplit[1]; | ||
} else { | ||
@@ -732,4 +734,6 @@ d = ''; | ||
input = 0; | ||
} else if (!Number(input)) { | ||
} else if (typeof input === 'string' || typeof input === 'number') { | ||
input = numbro.fn.unformat(input); | ||
} else { | ||
throw new Error('Invalid input'); | ||
} | ||
@@ -1063,3 +1067,3 @@ | ||
( | ||
process.title.indexOf('node') === 0 || | ||
process.title.indexOf('node') !== -1 || | ||
process.title.indexOf('meteor-tool') > 0 || | ||
@@ -1066,0 +1070,0 @@ process.title === 'grunt' || |
{ | ||
"name": "numbro", | ||
"version": "1.9.3", | ||
"version": "1.10.0", | ||
"description": "Format and manipulate numbers.", | ||
@@ -32,7 +32,3 @@ "homepage": "http://numbrojs.com", | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT" | ||
} | ||
], | ||
"license" : "MIT", | ||
"devDependencies": { | ||
@@ -39,0 +35,0 @@ "grunt": "^1.0.1", |
@@ -67,3 +67,3 @@ # [numbro](https://numbrojs.com/) | ||
Copyright © 2015 Företagsplatsen AB | ||
Copyright © 2015-2016 Företagsplatsen AB | ||
@@ -70,0 +70,0 @@ --- |
293802
92
7090