@@ -16,7 +16,7 @@ var NumeralFormatter = function (numeralDecimalMark,
1616 owner . numeralIntegerScale = numeralIntegerScale > 0 ? numeralIntegerScale : 0 ;
1717 owner . numeralDecimalScale = numeralDecimalScale >= 0 ? numeralDecimalScale : 2 ;
1818 owner . numeralThousandsGroupStyle = numeralThousandsGroupStyle || NumeralFormatter . groupStyle . thousand ;
19- owner . numeralPositiveOnly = ! ! numeralPositiveOnly ;
19+ owner . numeralPositiveOnly = numeralPositiveOnly ;
2020 owner . stripLeadingZeroes = stripLeadingZeroes !== false ;
2121 owner . prefix = ( prefix || prefix === '' ) ? prefix : '' ;
2222 owner . signBeforePrefix = ! ! signBeforePrefix ;
@@ -29,7 +29,7 @@ NumeralFormatter.groupStyle = {
2929 thousand : 'thousand' ,
3030 lakh : 'lakh' ,
3131 wan : 'wan' ,
32- none : 'none'
32+ none : 'none'
3333} ;
3434
3535NumeralFormatter . prototype = {
@@ -39,6 +39,7 @@ NumeralFormatter.prototype = {
3939
4040 format : function ( value ) {
4141 var owner = this , parts , partSign , partSignAndPrefix , partInteger , partDecimal = '' ;
42+ var strStrict = 'strict' ; // const
4243
4344 // strip alphabet letters
4445 value = value . replace ( / [ A - Z a - z ] / g, '' )
@@ -56,11 +57,16 @@ NumeralFormatter.prototype = {
5657 . replace ( / \- / g, '' )
5758
5859 // replace the minus sign (if present)
59- . replace ( 'N' , owner . numeralPositiveOnly ? '' : '-' )
60+ . replace ( 'N' , ( owner . numeralPositiveOnly === true
61+ || owner . numeralPositiveOnly === strStrict ) ? '' : '-' )
6062
6163 // replace decimal mark
6264 . replace ( 'M' , owner . numeralDecimalMark ) ;
6365
66+ if ( owner . numeralPositiveOnly === strStrict && parseFloat ( value ) < Number . EPSILON ) {
67+ value = '' ;
68+ }
69+
6470 // strip any leading zeros
6571 if ( owner . stripLeadingZeroes ) {
6672 value = value . replace ( / ^ ( - ) ? 0 + (? = \d ) / , '$1' ) ;
@@ -76,7 +82,7 @@ NumeralFormatter.prototype = {
7682 } else {
7783 partSignAndPrefix = partSign ;
7884 }
79-
85+
8086 partInteger = value ;
8187
8288 if ( value . indexOf ( owner . numeralDecimalMark ) >= 0 ) {
0 commit comments