@@ -114,6 +114,7 @@ __webpack_require__.d(other_namespaceObject, "bytes", function() { return other_
114114__webpack_require__ . d ( other_namespaceObject , "pluralize" , function ( ) { return other_pluralize ; } ) ;
115115__webpack_require__ . d ( other_namespaceObject , "ordinal" , function ( ) { return other_ordinal ; } ) ;
116116__webpack_require__ . d ( other_namespaceObject , "number" , function ( ) { return other_number ; } ) ;
117+ __webpack_require__ . d ( other_namespaceObject , "percent" , function ( ) { return other_percent ; } ) ;
117118
118119// CONCATENATED MODULE: ./src/util/index.js
119120function _toConsumableArray ( arr ) { return _arrayWithoutHoles ( arr ) || _iterableToArray ( arr ) || _nonIterableSpread ( ) ; }
@@ -780,13 +781,40 @@ function number_toFixed(num, precision) {
780781}
781782
782783/* 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 ) ;
783810// CONCATENATED MODULE: ./src/other/index.js
784811
785812
786813
787814
788815
789816
817+
790818// CONCATENATED MODULE: ./src/index.js
791819
792820
0 commit comments