@telerik/kendo-intl
Advanced tools
Comparing version 0.14.5 to 0.14.6
@@ -0,1 +1,3 @@ | ||
var MAX_PRECISION = 20; | ||
export default function round(value, precision) { | ||
@@ -11,4 +13,4 @@ var result = value; | ||
return result.toFixed(decimals); | ||
return result.toFixed(Math.min(decimals, MAX_PRECISION)); | ||
} | ||
//# sourceMappingURL=round.js.map |
@@ -185,2 +185,5 @@ import { localeInfo, firstDay } from '../cldr'; | ||
if (!isDate(date)) { | ||
if (date === undefined || date === null) { | ||
return ''; | ||
} | ||
return date; | ||
@@ -187,0 +190,0 @@ } |
@@ -16,3 +16,3 @@ import { formatDate } from './dates'; | ||
return value !== undefined ? value : ""; | ||
return value !== undefined && value !== null ? value : ""; | ||
} | ||
@@ -19,0 +19,0 @@ |
@@ -7,3 +7,3 @@ import formatCurrencySymbol from './format-currency-symbol'; | ||
var PERCENT_SYMBOL = "%"; | ||
var PLACEHOLDER = "??"; | ||
var PLACEHOLDER = "__??__"; | ||
var CURRENCY = "currency"; | ||
@@ -18,2 +18,4 @@ var PERCENT = "percent"; | ||
var literalRegExp = /(\\.)|(['][^']*[']?)|(["][^"]*["]?)/g; | ||
var trailingZerosRegExp = /(\.(?:[0-9]*[1-9])?)0+$/g; | ||
var trailingPointRegExp = /\.$/; | ||
var commaRegExp = /\,/g; | ||
@@ -36,2 +38,14 @@ | ||
function trimTrailingZeros(value, lastZero) { | ||
var trimRegex; | ||
if (lastZero === 0) { | ||
trimRegex = trailingZerosRegExp; | ||
} else { | ||
trimRegex = new RegExp(("(\\.[0-9]{" + lastZero + "}[1-9]*)0+$"), 'g'); | ||
} | ||
return value.replace(trimRegex, '$1').replace(trailingPointRegExp, ''); | ||
} | ||
function roundNumber(formatOptions) { | ||
@@ -56,3 +70,4 @@ var number = formatOptions.number; | ||
var idx = fraction.length; | ||
var precision = fraction.length; | ||
var trailingZeros = -1; | ||
@@ -62,15 +77,20 @@ if (!hasZero && !hasSharp) { | ||
decimalIndex = -1; | ||
idx = 0; | ||
precision = 0; | ||
} else if (hasZero && zeroIndex > sharpIndex) { | ||
idx = zeroIndex; | ||
precision = zeroIndex; | ||
} else if (sharpIndex > zeroIndex) { | ||
if (hasSharp && idx > sharpIndex) { | ||
idx = sharpIndex; | ||
} else if (hasZero && idx < zeroIndex) { | ||
idx = zeroIndex; | ||
if (hasSharp && precision > sharpIndex) { | ||
precision = sharpIndex; | ||
} else if (hasZero && precision < zeroIndex) { | ||
precision = zeroIndex; | ||
} | ||
trailingZeros = hasZero ? zeroIndex : 0; | ||
} | ||
if (idx > -1) { | ||
number = round(number, idx); | ||
if (precision > -1) { | ||
number = round(number, precision); | ||
if (trailingZeros > -1) { | ||
number = trimTrailingZeros(number, trailingZeros); | ||
} | ||
} | ||
@@ -250,3 +270,3 @@ } else { | ||
if (hasGroup) { | ||
number = groupInteger(number, start + (negative ? 1 : 0), Math.max(end, (integerLength + start)), info.numbers.decimal, info); | ||
number = groupInteger(number, start + (negative && !hasNegativeFormat ? 1 : 0), Math.max(end, (integerLength + start)), info.numbers.decimal, info); | ||
} | ||
@@ -253,0 +273,0 @@ |
@@ -27,3 +27,6 @@ export default function groupInteger(number, start, end, options, info) { | ||
if (groupSize === 0) { | ||
parts.push(integer.substring(0, idx)); | ||
value = integer.substring(0, idx); | ||
if (value) { | ||
parts.push(value); | ||
} | ||
break; | ||
@@ -30,0 +33,0 @@ } |
@@ -15,2 +15,3 @@ import formatCurrencySymbol from './format-currency-symbol'; | ||
var EMPTY = ""; | ||
var POINT = "."; | ||
@@ -75,2 +76,3 @@ function fractionOptions(options) { | ||
export default function standardNumberFormat(number, options, info) { | ||
var symbols = info.numbers.symbols; | ||
var style = options.style; | ||
@@ -80,6 +82,6 @@ | ||
if (style === "scientific") { | ||
return options.minimumFractionDigits !== undefined ? number.toExponential(options.minimumFractionDigits) : number.toExponential(); | ||
var exponential = options.minimumFractionDigits !== undefined ? number.toExponential(options.minimumFractionDigits) : number.toExponential(); | ||
return exponential.replace(POINT, symbols.decimal); | ||
} | ||
var symbols = info.numbers.symbols; | ||
var value = number; | ||
@@ -86,0 +88,0 @@ var symbol; |
{ | ||
"name": "@telerik/kendo-intl", | ||
"description": "A package exporting functions for date and number parsing and formatting", | ||
"version": "0.14.5", | ||
"version": "0.14.6", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
591405
5881