@@ -114,6 +114,7 @@ __webpack_require__.d(other_namespaceObject, "bytes", function() { return other_
114
114
__webpack_require__ . d ( other_namespaceObject , "pluralize" , function ( ) { return other_pluralize ; } ) ;
115
115
__webpack_require__ . d ( other_namespaceObject , "ordinal" , function ( ) { return other_ordinal ; } ) ;
116
116
__webpack_require__ . d ( other_namespaceObject , "number" , function ( ) { return other_number ; } ) ;
117
+ __webpack_require__ . d ( other_namespaceObject , "percent" , function ( ) { return other_percent ; } ) ;
117
118
118
119
// CONCATENATED MODULE: ./src/util/index.js
119
120
function _toConsumableArray ( arr ) { return _arrayWithoutHoles ( arr ) || _iterableToArray ( arr ) || _nonIterableSpread ( ) ; }
@@ -780,13 +781,40 @@ function number_toFixed(num, precision) {
780
781
}
781
782
782
783
/* harmony default export */ var other_number = ( number_number ) ;
784
+ // CONCATENATED MODULE: ./src/other/percent.js
785
+
786
+ /**
787
+ * 12 => '12%'
788
+ * 100 => '100%'
789
+ * 1000 => '1000%'
790
+ * 0.97 => '97%'
791
+ *
792
+ * @param {Number } value
793
+ * @param {Number } decimals Decimal places (default: 2)
794
+ */
795
+
796
+ function percent ( value , decimals ) {
797
+ var globalOptions = this && this . percent ? this . percent : { } ;
798
+ decimals = src_util . exist ( decimals ) ? decimals : globalOptions . decimalDigits ;
799
+ decimals = typeof decimals !== 'undefined' ? decimals : 0 ;
800
+ value = value === null || isNaN ( value ) ? 0 : value ;
801
+
802
+ if ( value <= 1 ) {
803
+ return "" . concat ( ( value * 100 ) . toFixed ( decimals ) , "%" ) ;
804
+ }
805
+
806
+ return "" . concat ( value . toFixed ( decimals ) , "%" ) ;
807
+ }
808
+
809
+ /* harmony default export */ var other_percent = ( percent ) ;
783
810
// CONCATENATED MODULE: ./src/other/index.js
784
811
785
812
786
813
787
814
788
815
789
816
817
+
790
818
// CONCATENATED MODULE: ./src/index.js
791
819
792
820
0 commit comments