@@ -14,7 +14,7 @@ function currency (value, symbol, decimals, options) {
1414 symbol = util . exist ( symbol ) ? symbol : globalOptions . symbol
1515 decimals = util . exist ( decimals ) ? decimals : globalOptions . decimalDigits
1616 options = options || globalOptions
17- var thousandsSeparator , symbolOnLeft , spaceBetweenAmountAndSymbol
17+ var thousandsSeparator , symbolOnLeft , spaceBetweenAmountAndSymbol , showPlusSign
1818 var digitsRE = / ( \d { 3 } ) (? = \d ) / g
1919 value = parseFloat ( value )
2020 if ( ! isFinite ( value ) || ( ! value && value !== 0 ) ) return ''
@@ -23,6 +23,7 @@ function currency (value, symbol, decimals, options) {
2323 thousandsSeparator = options . thousandsSeparator != null ? options . thousandsSeparator : ','
2424 symbolOnLeft = options . symbolOnLeft != null ? options . symbolOnLeft : true
2525 spaceBetweenAmountAndSymbol = options . spaceBetweenAmountAndSymbol != null ? options . spaceBetweenAmountAndSymbol : false
26+ showPlusSign = options . showPlusSign != null ? options . showPlusSign : false
2627 var number = Math . abs ( value )
2728 var stringified = toFixed ( number , decimals )
2829 stringified = options . decimalSeparator
@@ -47,7 +48,8 @@ function currency (value, symbol, decimals, options) {
4748 : head +
4849 _int . slice ( i ) . replace ( digitsRE , '$1' + thousandsSeparator ) + _float + symbol
4950 var sign = value < 0 ? '-' : ''
50- return sign + symbol
51+ var plusSign = ( value > 0 && showPlusSign ) ? '+' : ''
52+ return plusSign + sign + symbol
5153}
5254
5355function toFixed ( num , precision ) {
0 commit comments